validation

This commit is contained in:
mantikoros 2022-07-02 14:50:24 -04:00
parent 152b532d11
commit e73be631f5
3 changed files with 8 additions and 6 deletions

View File

@ -84,7 +84,7 @@ export type PseudoNumeric = {
isLogScale: boolean
resolutionValue?: number
// same as binary market; map to everything to probability
// same as binary market; map everything to probability
initialProbability: number
resolutionProbability?: number
}

View File

@ -46,10 +46,12 @@ const binarySchema = z.object({
initialProb: z.number().min(1).max(99),
})
const finite = () => z.number().gte(Number.MIN_SAFE_INTEGER).lte(Number.MAX_SAFE_INTEGER)
const numericSchema = z.object({
min: z.number(),
max: z.number(),
initialValue: z.number(),
min: finite(),
max: finite(),
initialValue: finite(),
isLogScale: z.boolean().optional(),
})

View File

@ -139,7 +139,7 @@ export function NewContract(props: {
const adjustIsLog = () => {
if (min === undefined || max === undefined) return
const lengthDiff = Math.abs(Math.log10(max) - Math.log10(min))
const lengthDiff = Math.log10(max - min)
if (lengthDiff > 2) {
setIsLogScale(true)
}
@ -322,7 +322,7 @@ export function NewContract(props: {
placeholder="Initial value"
onClick={(e) => e.stopPropagation()}
onChange={(e) => setInitialValueString(e.target.value)}
maxLength={6}
max={Number.MAX_SAFE_INTEGER}
disabled={isSubmitting}
value={initialValueString ?? ''}
/>