Skip to content

Latest commit

 

History

History
32 lines (29 loc) · 1.24 KB

AutoValidate.md

File metadata and controls

32 lines (29 loc) · 1.24 KB

<AutoValidate /> Component

This component is responsible for validating inputs on specified events. It requires context which is provided by <FormGroup />.

Usage

<Form {...FormProps}>
    <FormGroup name="phone" {...FormGroupProps}>
        <AutoValidate
            groupName="phone"
            onBlur={true}
            onLength={12}
            always={false}
            onChange={false}
            on={(nextValue: string, prevValue: string) => true}
            onValidated={(isValid: boolean) => console.log(isValid)}
        >
                // ...
        </AutoValidate>
    </FormGroup>
</Form>

where:

  • groupName - field model name, that must validated. Optinal. Default - value from FormGroup context.
  • onBlur - validate when input emit blur event. Optional. Default - true.
  • onChange - validate when input emit change event. Optional. Default - false.
  • onLength - validate when input value have specific length. Optional.
  • always - validate when any event was emitted. Optional. Default - false.
  • on - custom function, that specifies when to validate input. Optional.
  • onValidated - callback, that triggered when input was validated. Optional.