Wrap the field group component and provide Props related to the form.
FieldGroup mainly contains multiple FieldComponent such as checbox
and radio
, but use it when you want to display single error.
import React from 'react';
import { dripFormGroup } from 'react-drip-form';
const FieldGroup = (props) => {
/* field component */
};
export default dripFormGroup(/* options */)(FieldGroup);
All options are Optional.
Object
{}
You can specify the default Props For the wrapped component.
Props other than meta
are basically passed as is.
An object with properties with the following meta state.
string
The name
attribute of the field group.
string
It is label
of the field group.
string
If there are multiple errors, it will be the first error.
string[]
All error strings held by the field group.
boolean
It is true
if all validation associated with the field group is passed.
boolean
The opposite of meta.valid
.
boolean
true
if the field group is touched even once.
input.onBlur()
is used to determine if you are touching.
boolean
The opposite of meta.untouched
.
boolean
true
if the value of any field group has been changed.
boolean
The opposite of meta.dirty
.
boolean
true
if the field group is validating.
Components after wrapping can specify the following Props.
boolean
false
false
If you need an array value like Checkbox, specify true
.
string
true
A string representing the name of the field.
The string specified here will be used as a subscript to values
.
any
false
Specify the value of the field.
The value specified here will be used as the initial value.
Also, if it is detected that componentWillReceiveProps()
is not equivalent, overwrite the current form value.
string
null
false
Specify the label of the field. It is mainly used in error messages.
Object
null
false
You can specify a validation rule.
Please refer to drip-form-validator
Built-in Rules for specifiable rules.
Object
null
false
You can specify Normalizers.
Please refer to drip-form-validator
Built-in Normalizers for specifiable rules.
Object
null
false
Specify the error message corresponding to the validation rule.