diff --git a/README.md b/README.md index d252736bf..62bbf96b8 100644 --- a/README.md +++ b/README.md @@ -928,6 +928,20 @@ __Please note__: If the keyword is validating data type that is different from t See [Defining custom keywords](#defining-custom-keywords) for more details. +##### .getKeyword(String keyword) -> Object|Boolean + +Returns custom keyword definition, `true` for pre-defined keywords and `false` if the keyword is unknown. + + +##### .removeKeyword(String keyword) + +Removes custom or pre-defined keyword so you can redefine them. + +While this method can be used to extend pre-defined keywords, it can also be used to completely change their meaning - it may lead to unexpected results. + +__Please note__: schemas compiled before the keyword is removed will continue to work without changes. To recompile schemas use `removeSchema` method and compile them again. + + ##### .errorsText([Array<Object> errors [, Object options]]) -> String Returns the text with all errors in a String. diff --git a/lib/ajv.d.ts b/lib/ajv.d.ts index 9a9d3a6ee..0e10c9a67 100644 --- a/lib/ajv.d.ts +++ b/lib/ajv.d.ts @@ -74,6 +74,19 @@ declare namespace ajv { */ addKeyword(keyword: string, definition: KeywordDefinition): void; /** + * Get keyword definition + * @this Ajv + * @param {String} keyword pre-defined or custom keyword. + * @return {Object|Boolean} custom keyword definition, `true` if it is a predefined keyword, `false` otherwise. + */ + getKeyword(keyword: string): Object | boolean; + /** + * Remove keyword + * @this Ajv + * @param {String} keyword pre-defined or custom keyword. + */ + removeKeyword(keyword: string): void; + /** * Convert array of error message objects to string * @param {Array} errors optional array of validation errors, if not passed errors from the instance are used. * @param {Object} options optional options with properties `separator` and `dataVar`. diff --git a/lib/keyword.js b/lib/keyword.js index e7cabde90..954bacaf1 100644 --- a/lib/keyword.js +++ b/lib/keyword.js @@ -91,7 +91,7 @@ function addKeyword(keyword, definition) { /** - * Get custom keyword + * Get keyword * @this Ajv * @param {String} keyword pre-defined or custom keyword. * @return {Object|Boolean} custom keyword definition, `true` if it is a predefined keyword, `false` otherwise. diff --git a/package.json b/package.json index b8d6f3ad2..aea85f31d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ajv", - "version": "4.9.3", + "version": "4.10.0", "description": "Another JSON Schema Validator", "main": "lib/ajv.js", "webpack": "dist/ajv.bundle.js",