validation
This commit is contained in:
parent
152b532d11
commit
e73be631f5
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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(),
|
||||
})
|
||||
|
||||
|
|
|
@ -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 ?? ''}
|
||||
/>
|
||||
|
|
Loading…
Reference in New Issue
Block a user