Skip to content

Commit

Permalink
docs: remove utils from docs
Browse files Browse the repository at this point in the history
  • Loading branch information
epoberezkin committed Sep 23, 2020
1 parent c31fec5 commit 871e947
Showing 1 changed file with 0 additions and 51 deletions.
51 changes: 0 additions & 51 deletions docs/keywords.md
Expand Up @@ -257,57 +257,6 @@ Schema compilation context [SchemaCxt](../lib/compile/index.ts) is available in

All function scoped variables available during validation are defined in [names](../lib/compile/names.ts).

## Ajv utilities

There are sevral useful functions you can use in your _code_ keywords. These functions can be imported from TODO:

##### .toHash(Array arr) -> Object

Converts the array of strings to the object where each string becomes the key with the value of `true`.

```javascript
toHash(["a", "b", "c"]) // { a: true, b: true, c: true }
```

##### .equal(value1, value2) -> Boolean

Performs deep equality comparison. This function is used in keywords `enum`, `constant`, `uniqueItems` and can be used in user-defined keywords.

##### gen.getProperty(String key) -> String

Converts the string that is the key/index to access the property/item to the JavaScript syntax to access the property (either "." notation or "[...]" notation).

```javascript
getProperty("a") // ".a"
getProperty("1") // "['1']"
getProperty("a'b") // "['a\\'b']"
getProperty(1) // "[1]"
```

##### .schemaHasRules(Object schema, Object rules) -> String

Determines whether the passed schema has rules that should be validated. This function should be used before calling `it.validate` to compile subschemas.

```javascript
schemaHasRules(schema, it.RULES.all) // true or false
```

##### .escapeJsonPointer(String str) -> String

Converts the property name to the JSON-Pointer fragment.

##### .unescapeJsonPointer (String str) -> String

Converts JSON-Pointer fragment to the property name.

##### .unescapeFragment(String str) -> String

Converts the property name to the JSON-Pointer fragment that can be used in URI.

##### .escapeFragment(String str) -> String

Converts the JSON-Pointer fragment from URI to the property name.

## Reporting errors

All keywords can define error messages with `KeywordErrorDefinition` object passed as `error` property of keyword definition:
Expand Down

0 comments on commit 871e947

Please sign in to comment.