You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Dec 19, 2022. It is now read-only.
Can we be able to override the specific validation error message by a other message.
For example: username: s.optional(s.regex(/^(?=.*[a-z])[1-9a-z][0-9a-z]{3,19}$/i))
change to : username: s.optional(s.regex(/^(?=.*[a-z])[1-9a-z][0-9a-z]{3,19}$/i, message:'Please follow this rules for your username: Alphanumeric characters only, maximum of 20 characters, minimum of 4 characters, at least one letter, first character cannot be 0, whitespace is not allowed'))
The text was updated successfully, but these errors were encountered:
That would be nice, especially for regexes. In your example, another option that's quite clean is to wrap it into a higher-level matcher, e.g. something like
varUsername=s.createMatcher({initialize: function(){this.regex=s.regex(/^(?=.*[a-z])[1-9a-z][0-9a-z]{3,19}$/i);},match: function(path,value){varerrors=this.regex.match(path,value);if(errors){return'Please follow these rules for your username: ....';}}});// and thenvarschema={username: s.optional(newUsername())};
Can we be able to override the specific validation error message by a other message.
For example:
username: s.optional(s.regex(/^(?=.*[a-z])[1-9a-z][0-9a-z]{3,19}$/i))
change to :
username: s.optional(s.regex(/^(?=.*[a-z])[1-9a-z][0-9a-z]{3,19}$/i, message:'Please follow this rules for your username: Alphanumeric characters only, maximum of 20 characters, minimum of 4 characters, at least one letter, first character cannot be 0, whitespace is not allowed'))
The text was updated successfully, but these errors were encountered: