Comments (1)
I found the problem in lib/attribute.js:687
:
/**
* 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 = function validatePattern (instance, schema, options, ctx) {
if (!this.types.string(instance)) return;
var result = new ValidatorResult(instance, schema, options, ctx);
var pattern = schema.pattern;
try {
var regexp = new RegExp(pattern, 'u');
} catch(_e) {
// In the event the stricter handling causes an error, fall back on the forgiving handling
// DEPRECATED
regexp = new RegExp(pattern);
}
if (!instance.match(regexp)) {
result.addError({
name: 'pattern',
argument: schema.pattern,
message: "does not match pattern " + JSON.stringify(schema.pattern.toString()),
});
}
return result;
};
The code var regexp = new RegExp(pattern, 'u');
override the i
modificator as case sensitive ignore.
regexp = new RegExp(pattern);
}
console.log(regexp); // <<-- Test output final regexp
if (!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
In the examples says can use regexp in plain method https://github.com/tdegrunt/jsonschema/blob/master/examples/all.js#L207 :
"validatePattern2": {
"type": "string",
"pattern": /str/
},
But the documentation does not indicate that in these cases you can or cannot use modifiers like case insensitive in pattern object.
from jsonschema.
Related Issues (20)
- v1.4.1 does not support chrome 49 HOT 4
- Cannot find module 'url' HOT 7
- TypeScript readonly arrays?
- How to enforce `enum` validation on a specific property? HOT 1
- Date as custom type HOT 2
- Deeper arrays are not being validated HOT 1
- Validation errors in firefox not constructing properly HOT 1
- Nested Schema in the definitions object unsupported attribute when allowUnknownAttributes is set to false
- Support for unevaluatedProperties
- validation error reported onOf object incorrectly HOT 3
- v.validate() on a specific property of a schema? HOT 1
- OpenHarmony support
- Validation error (Not supporting anyOf property)
- $id is incompatible with allowUnknownAttributes: false
- Unable to update the git submodules HOT 1
- [DEP0169] DeprecationWarning: `url.parse()` behavior is not standardized and prone to errors that have security implications. Use the WHATWG URL API instead. CVEs are not issued for `url.parse()` vulnerabilities. HOT 1
- bug?: Object literal may only specify known properties, and 'default' does not exist in type 'Schema' HOT 1
- Vite Module "url" has been externalized for browser compatibility HOT 1
- Validator does not honor "nullable" property for `type: "string", enum: [...]` HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jsonschema.