Merge branch 'master' into master

master
Simon Chan 2018-12-17 10:26:48 +08:00 committed by GitHub
commit 3f686531c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 8 additions and 17 deletions

View File

@ -244,7 +244,7 @@ The following formats are supported for string validation with "format" keyword:
- _uri_: full URI.
- _uri-reference_: URI reference, including full and relative URIs.
- _uri-template_: URI template according to [RFC6570](https://tools.ietf.org/html/rfc6570)
- _url_: [URL record](https://url.spec.whatwg.org/#concept-url).
- _url_ (deprecated): [URL record](https://url.spec.whatwg.org/#concept-url).
- _email_: email address.
- _hostname_: host name according to [RFC1034](http://tools.ietf.org/html/rfc1034#section-3.5).
- _ipv4_: IP address v4.

View File

@ -55,8 +55,6 @@ function Ajv(opts) {
this._refs = {};
this._fragments = {};
this._formats = formats(opts.format);
var schemaUriFormat = this._schemaUriFormat = this._formats['uri-reference'];
this._schemaUriFormatFunc = function (str) { return schemaUriFormat.test(str); };
this._cache = opts.cache || new Cache;
this._loadingSchemas = {};
@ -171,13 +169,7 @@ function validateSchema(schema, throwOrLogError) {
this.errors = null;
return true;
}
var currentUriFormat = this._formats.uri;
this._formats.uri = typeof currentUriFormat == 'function'
? this._schemaUriFormatFunc
: this._schemaUriFormat;
var valid;
try { valid = this.validate($schema, schema); }
finally { this._formats.uri = currentUriFormat; }
var valid = this.validate($schema, schema);
if (!valid && throwOrLogError) {
var message = 'schema is invalid: ' + this.errorsText();
if (this._opts.validateSchema == 'log') this.logger.error(message);

View File

@ -28,12 +28,10 @@
"type": "object",
"properties": {
"id": {
"type": "string",
"format": "uri"
"type": "string"
},
"$schema": {
"type": "string",
"format": "uri"
"type": "string"
},
"title": {
"type": "string"
@ -137,6 +135,7 @@
}
]
},
"format": { "type": "string" },
"allOf": { "$ref": "#/definitions/schemaArray" },
"anyOf": { "$ref": "#/definitions/schemaArray" },
"oneOf": { "$ref": "#/definitions/schemaArray" },

View File

@ -1,6 +1,6 @@
{
"name": "ajv",
"version": "6.6.1",
"version": "6.6.2",
"description": "Another JSON Schema Validator",
"main": "lib/ajv.js",
"typings": "lib/ajv.d.ts",
@ -84,7 +84,7 @@
"karma": "^3.0.0",
"karma-chrome-launcher": "^2.2.0",
"karma-mocha": "^1.1.1",
"karma-sauce-launcher": "^1.1.0",
"karma-sauce-launcher": "^2.0.0",
"mocha": "^5.1.1",
"nyc": "^12.0.1",
"pre-commit": "^1.1.1",

View File

@ -1194,7 +1194,7 @@ describe('Ajv Options', function () {
describe('= "id"', function() {
it('should use id and ignore $id', function() {
var ajv = new Ajv({schemaId: 'id', meta: false});
ajv.addMetaSchema(require('ajv/lib/refs/json-schema-draft-04.json'));
ajv.addMetaSchema(require('../lib/refs/json-schema-draft-04.json'));
ajv._opts.defaultMeta = 'http://json-schema.org/draft-04/schema#';
ajv.addSchema({ id: 'mySchema1', type: 'string' });