diff --git a/README.md b/README.md index d462cf5..8ce6662 100644 --- a/README.md +++ b/README.md @@ -93,7 +93,7 @@ _* This will create a new object rather than mutating existing ones so you're sa ## API ``` js -import createPropTypes, {getComponentSchema, Schema, SchemaSymbol} from 'react-json-schema-proptypes'; +import createPropTypes, {getComponentSchema, Schema, SchemaSymbol, ajv} from 'react-json-schema-proptypes'; ``` @@ -120,6 +120,8 @@ Is a schema that validates a React node. (Gives a schema represetation equivale #### Schema.func Is a schema that validates a function. +### ajv +The internally used instance of Ajv(https://github.com/epoberezkin/ajv). This instance may be configured e.g. to support nested schema's (See (https://github.com/epoberezkin/ajv#api)[https://github.com/epoberezkin/ajv#api]) ## Caveats diff --git a/package.json b/package.json index bf5bf08..aa551ed 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "sinon": "^1.17.3" }, "dependencies": { - "ajv": "^3.8.5", + "ajv": "^5.2.2", "ajv-i18n": "^1.2.0", "faker": "^3.1.0", "json-schema-faker": "^0.3.0", diff --git a/src/ajvEx.js b/src/ajvEx.js index e6103dd..276eff2 100644 --- a/src/ajvEx.js +++ b/src/ajvEx.js @@ -2,7 +2,10 @@ import AJV from 'ajv'; import * as React from 'react'; import isFunction from 'lodash/isFunction'; -const ajv = AJV({errorDataPath: 'property'}); // restore pre v2.0 behavior +const ajv = AJV({ + errorDataPath: 'property', // restore pre v2.0 behavior + unknownFormats: 'ignore' // restore pre v5.0 behavior +}); function safeEscapeQuotes(str) { return str.replace(/\\([\s\S])|(')/g,"\\$1$2").replace(/\\([\s\S])|(")/g,"\\$1$2"); // escape only if not escaped already @@ -21,4 +24,4 @@ ajv.addKeyword('isFunction', { compile: function() { return isFunction; }}); -export default ajv; \ No newline at end of file +export default ajv; diff --git a/src/index.js b/src/index.js index 9659e0a..944c19a 100644 --- a/src/index.js +++ b/src/index.js @@ -4,7 +4,7 @@ import omitDeprecated from './util'; export * as Schema from './schemas'; export fake from './fake'; - +export { ajv }; export const SchemaSymbol = Symbol.for('react-json-schema-proptypes'); function name(component) {