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
[ValidationError{path: [Array],property: 'instance.uuid',message: 'does not match pattern "/^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i"',schema: [Object],instance: 'f9d15cc5-1a53-4733-9ae7-f1675c8428a7',name: 'pattern',argument: /^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i,stack: 'instance.uuid does not match pattern "/^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i"'}]
/** * Validates whether the instance value matches the regular expression, when the instance value is a string. * @param instance * @param schema * @return {String|null} */validators.pattern=functionvalidatePattern(instance,schema,options,ctx){if(!this.types.string(instance))return;varresult=newValidatorResult(instance,schema,options,ctx);varpattern=schema.pattern;try{varregexp=newRegExp(pattern,'u');}catch(_e){// In the event the stricter handling causes an error, fall back on the forgiving handling// DEPRECATEDregexp=newRegExp(pattern);}if(!instance.match(regexp)){result.addError({name: 'pattern',argument: schema.pattern,message: "does not match pattern "+JSON.stringify(schema.pattern.toString()),});}returnresult;};
The code var regexp = new RegExp(pattern, 'u'); override the i modificator as case sensitive ignore.
regexp=newRegExp(pattern);}console.log(regexp);// <<-- Test output final regexpif(!instance.match(regexp)){
The old regexp: /^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i
The new regexp: /^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/u
But the documentation does not indicate that in these cases you can or cannot use modifiers like case insensitive in pattern object.
yhojann-cl
changed the title
Regexp does not work for strings validation
pattern does not work when use a regexp representation with attributes
Sep 1, 2023
yhojann-cl
changed the title
pattern does not work when use a regexp representation with attributes
pattern does not work when use a regexp with attributes
Sep 1, 2023
By example:
Says:
But the expression and value are valid:
The text was updated successfully, but these errors were encountered: