Skip to content

Commit

Permalink
docs: getKeyword, removeKeywords methods
Browse files Browse the repository at this point in the history
  • Loading branch information
epoberezkin committed Dec 11, 2016
1 parent 7bfc868 commit 8a470f3
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
13 changes: 13 additions & 0 deletions lib/ajv.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Object>} 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`.
Expand Down
2 changes: 1 addition & 1 deletion lib/keyword.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit 8a470f3

Please sign in to comment.