rules

Specification

Form-specific validation rules schema.
Providing form-specific rules is designed to extend/rewrite the validation behavior of certian forms. For general usage it is recommended to provide the validation rules and messages through the FormProvider component to be applied application-wide.

Example

1
import React from 'react'
2
import { Form } from 'react-advanced-form'
3
4
const formRules = {
5
extend: true, // merge the current schema with the FormProvider's one
6
type: {
7
tel: ({ value }) => customPhoneValidationForThisFormOnly(value),
8
},
9
}
10
11
export default class Example extends React.Component {
12
render() {
13
return (
14
<Form rules={formRules}>
15
{/* Fields here */}
16
</Form>
17
)
18
}
19
}
Copied!

Materials

Last modified 3yr ago