Defines the shape of your form data
FormValue
s are:
Forms.string()
.default(value : string)
Sets a default value to return when no value is entered by the user.
useForm()
hook..multiline()
Will cause the string input to be multiline.
<textarea />
rather than an <input type="text" />
in DOM-speak.optional()
By default, strings are required. This will change that to let null
, undefined
, and ""
pass validation.
Forms.number()
.default(value : number)
Sets a default value to return when no value is entered by the user.
useForm()
hook..optional()
By default, numbers are required. This will change that to let null
and undefined
pass validation.
.min(min: number)
Provide a minimum value. Validation will fail if the user inputs number < min
.
.max(max: number)
Provide a maximum value. Validation will fail if the user inputs number > max
.
Forms.array(FormValue | Record<string, FormValue>)
name
prop like "addresses[0].street"
..optional()
By default, arrays are required. This will change that to let null
and undefined
pass validation.