diff --git a/src/useFieldArray.js b/src/useFieldArray.js index d516b76..ef1eca1 100644 --- a/src/useFieldArray.js +++ b/src/useFieldArray.js @@ -39,19 +39,20 @@ const useFieldArray = ( }, {}) ) - const validate: FieldValidator = useConstant( - () => (value, allValues, meta) => { - if (!validateProp) return undefined - const error = validateProp(value, allValues, meta) - if (!error || Array.isArray(error)) { - return error - } else { - const arrayError = [] - // gross, but we have to set a string key on the array - ;((arrayError: any): Object)[ARRAY_ERROR] = error - return arrayError - } - } + const validate: FieldValidator = useConstant(() => + !validateProp + ? undefined + : (value, allValues, meta) => { + const error = validateProp(value, allValues, meta) + if (!error || Array.isArray(error)) { + return error + } else { + const arrayError = [] + // gross, but we have to set a string key on the array + ;((arrayError: any): Object)[ARRAY_ERROR] = error + return arrayError + } + } ) const {