Skip to content
Snippets Groups Projects
Unverified Commit f0222593 authored by gabriellsh's avatar gabriellsh Committed by GitHub
Browse files

[FIX] Custom fields required if minLength set and no text typed (#18838)

parent 45774d44
No related branches found
No related tags found
No related merge requests found
......@@ -37,7 +37,7 @@ export const validateCustomFields = function(fields) {
throw new Meteor.Error('error-user-registration-custom-field', `Max length of field ${ fieldName } ${ field.maxLength }`, { method: 'registerUser' });
}
if (field.minLength && fieldValue.length < field.minLength) {
if (field.minLength && fieldValue.length > 0 && fieldValue.length < field.minLength) {
throw new Meteor.Error('error-user-registration-custom-field', `Min length of field ${ fieldName } ${ field.minLength }`, { method: 'registerUser' });
}
});
......
......@@ -11,7 +11,7 @@ const CustomTextInput = ({ name, required, minLength, maxLength, setState, state
const verify = useMemo(() => {
const error = [];
if (!state && required) { error.push(t('Field_required')); }
if (state.length < minLength) { error.push(t('Min_length_is', minLength)); }
if (state.length < minLength && state.length > 0) { error.push(t('Min_length_is', minLength)); }
return error.join(', ');
}, [state, required, minLength, t]);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment