|
275 | 275 | } |
276 | 276 | } |
277 | 277 |
|
278 | | - if (schema.format && options.validateFormats) { |
279 | | - format = schema.format; |
280 | | - |
281 | | - if (options.validateFormatExtensions) { spec = validate.formatExtensions[format] } |
282 | | - if (!spec) { spec = validate.formats[format] } |
283 | | - if (!spec) { |
284 | | - if (options.validateFormatsStrict) { |
285 | | - return error('format', property, value, schema, errors); |
286 | | - } |
287 | | - } |
288 | | - else { |
289 | | - if (!spec.test(value)) { |
290 | | - return error('format', property, value, schema, errors); |
291 | | - } |
292 | | - } |
293 | | - } |
294 | | - |
295 | | - if (schema['enum'] && schema['enum'].indexOf(value) === -1) { |
296 | | - error('enum', property, value, schema, errors); |
297 | | - } |
298 | | - |
299 | 278 | // Dependencies (see 5.8) |
300 | 279 | if (typeof schema.dependencies === 'string' && |
301 | 280 | object[schema.dependencies] === undefined) { |
|
317 | 296 | checkType(value, schema.type, function(err, type) { |
318 | 297 | if (err) return error('type', property, typeof value, schema, errors); |
319 | 298 |
|
320 | | - constrain('conform', value, function (a, e) { return e(a, object) }); |
321 | | - |
322 | 299 | switch (type || (isArray(value) ? 'array' : typeof value)) { |
323 | 300 | case 'string': |
324 | 301 | constrain('allowEmpty', value, function (a, e) { return e ? e : a !== '' }); |
|
389 | 366 | } |
390 | 367 | break; |
391 | 368 | } |
| 369 | + |
| 370 | + constrain('conform', value, function (a, e) { return e(a, object) }); |
392 | 371 | }); |
| 372 | + |
| 373 | + if (schema.format && options.validateFormats) { |
| 374 | + format = schema.format; |
| 375 | + |
| 376 | + if (options.validateFormatExtensions) { spec = validate.formatExtensions[format] } |
| 377 | + if (!spec) { spec = validate.formats[format] } |
| 378 | + if (!spec) { |
| 379 | + if (options.validateFormatsStrict) { |
| 380 | + return error('format', property, value, schema, errors); |
| 381 | + } |
| 382 | + } |
| 383 | + else { |
| 384 | + if (!spec.test(value)) { |
| 385 | + return error('format', property, value, schema, errors); |
| 386 | + } |
| 387 | + } |
| 388 | + } |
| 389 | + |
| 390 | + if (schema['enum'] && schema['enum'].indexOf(value) === -1) { |
| 391 | + error('enum', property, value, schema, errors); |
| 392 | + } |
393 | 393 | } |
394 | 394 |
|
395 | 395 | function checkType(val, type, callback) { |
|
0 commit comments