radio field validation on options
This commit is contained in:
@@ -31,9 +31,9 @@ const RadioGroup = (props) => {
|
||||
const path = pathFromProps || name;
|
||||
|
||||
const memoizedValidate = useCallback((value) => {
|
||||
const validationResult = validate(value, { required });
|
||||
const validationResult = validate(value, { required, options });
|
||||
return validationResult;
|
||||
}, [validate, required]);
|
||||
}, [validate, required, options]);
|
||||
|
||||
const {
|
||||
value,
|
||||
|
||||
@@ -157,7 +157,7 @@ const optionsToValidatorMap = {
|
||||
return defaultMessage;
|
||||
},
|
||||
radio: (value, options = {}) => {
|
||||
if (value || !options.required) return true;
|
||||
if ((value || !options.required) && (options.options.find((option) => option.value === value))) return true;
|
||||
return defaultMessage;
|
||||
},
|
||||
blocks: (value, options) => {
|
||||
|
||||
Reference in New Issue
Block a user