validation
This commit is contained in:
parent
152b532d11
commit
e73be631f5
|
@ -84,7 +84,7 @@ export type PseudoNumeric = {
|
||||||
isLogScale: boolean
|
isLogScale: boolean
|
||||||
resolutionValue?: number
|
resolutionValue?: number
|
||||||
|
|
||||||
// same as binary market; map to everything to probability
|
// same as binary market; map everything to probability
|
||||||
initialProbability: number
|
initialProbability: number
|
||||||
resolutionProbability?: number
|
resolutionProbability?: number
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,10 +46,12 @@ const binarySchema = z.object({
|
||||||
initialProb: z.number().min(1).max(99),
|
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({
|
const numericSchema = z.object({
|
||||||
min: z.number(),
|
min: finite(),
|
||||||
max: z.number(),
|
max: finite(),
|
||||||
initialValue: z.number(),
|
initialValue: finite(),
|
||||||
isLogScale: z.boolean().optional(),
|
isLogScale: z.boolean().optional(),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -139,7 +139,7 @@ export function NewContract(props: {
|
||||||
|
|
||||||
const adjustIsLog = () => {
|
const adjustIsLog = () => {
|
||||||
if (min === undefined || max === undefined) return
|
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) {
|
if (lengthDiff > 2) {
|
||||||
setIsLogScale(true)
|
setIsLogScale(true)
|
||||||
}
|
}
|
||||||
|
@ -322,7 +322,7 @@ export function NewContract(props: {
|
||||||
placeholder="Initial value"
|
placeholder="Initial value"
|
||||||
onClick={(e) => e.stopPropagation()}
|
onClick={(e) => e.stopPropagation()}
|
||||||
onChange={(e) => setInitialValueString(e.target.value)}
|
onChange={(e) => setInitialValueString(e.target.value)}
|
||||||
maxLength={6}
|
max={Number.MAX_SAFE_INTEGER}
|
||||||
disabled={isSubmitting}
|
disabled={isSubmitting}
|
||||||
value={initialValueString ?? ''}
|
value={initialValueString ?? ''}
|
||||||
/>
|
/>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user