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.
stringThe name attribute of the field group.
stringIt is label of the field group.
stringIf there are multiple errors, it will be the first error.
string[]All error strings held by the field group.
booleanIt is true if all validation associated with the field group is passed.
booleanThe opposite of meta.valid.
booleantrue if the field group is touched even once.
input.onBlur() is used to determine if you are touching.
booleanThe opposite of meta.untouched.
booleantrue if the value of any field group has been changed.
booleanThe opposite of meta.dirty.
booleantrue if the field group is validating.
Components after wrapping can specify the following Props.
booleanfalsefalseIf you need an array value like Checkbox, specify true.
stringtrueA string representing the name of the field.
The string specified here will be used as a subscript to values.
anyfalseSpecify 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.
stringnullfalseSpecify the label of the field. It is mainly used in error messages.
ObjectnullfalseYou can specify a validation rule.
Please refer to drip-form-validator Built-in Rules for specifiable rules.
ObjectnullfalseYou can specify Normalizers.
Please refer to drip-form-validator Built-in Normalizers for specifiable rules.
ObjectnullfalseSpecify the error message corresponding to the validation rule.