Skip to content

Commit

Permalink
Merge 12b683a into 66e8a35
Browse files Browse the repository at this point in the history
  • Loading branch information
epoberezkin committed May 11, 2020
2 parents 66e8a35 + 12b683a commit 7b7faa5
Show file tree
Hide file tree
Showing 27 changed files with 126 additions and 126 deletions.
12 changes: 6 additions & 6 deletions .github/ISSUE_TEMPLATE.md
@@ -1,12 +1,12 @@
<!--
Frequently Asked Questions: https://github.com/epoberezkin/ajv/blob/master/FAQ.md
Frequently Asked Questions: https://github.com/ajv-validator/ajv/blob/master/FAQ.md
Please provide all info and reduce your schema and data to the smallest possible size.
This template is for bug or error reports. For other issues please use:
- security vulnerability: https://tidelift.com/security)
- a new feature/improvement: http://epoberezkin.github.io/ajv/contribute.html#changes
- browser/compatibility issues: http://epoberezkin.github.io/ajv/contribute.html#compatibility
- JSON-Schema standard: http://epoberezkin.github.io/ajv/contribute.html#json-schema
- a new feature/improvement: https://ajv.js.org/contribute.html#changes
- browser/compatibility issues: https://ajv.js.org/contribute.html#compatibility
- JSON-Schema standard: https://ajv.js.org/contribute.html#json-schema
- Ajv usage questions: https://gitter.im/ajv-validator/ajv
-->

Expand All @@ -16,7 +16,7 @@ This template is for bug or error reports. For other issues please use:

**Ajv options object**

<!-- See https://github.com/epoberezkin/ajv#options -->
<!-- See https://github.com/ajv-validator/ajv#options -->

```javascript

Expand Down Expand Up @@ -49,7 +49,7 @@ This template is for bug or error reports. For other issues please use:
<!--
Please:
- make it as small as posssible to reproduce the issue
- use one of the usage patterns from https://github.com/epoberezkin/ajv#getting-started
- use one of the usage patterns from https://github.com/ajv-validator/ajv#getting-started
- use `options`, `schema` and `data` as variables, do not repeat their values here
- post a working code sample in RunKit notebook cloned from https://runkit.com/esp/ajv-issue and include the link here.
Expand Down
8 changes: 4 additions & 4 deletions .github/ISSUE_TEMPLATE/bug-or-error-report.md
Expand Up @@ -8,11 +8,11 @@ assignees: ''
---

<!--
Frequently Asked Questions: https://github.com/epoberezkin/ajv/blob/master/FAQ.md
Frequently Asked Questions: https://github.com/ajv-validator/ajv/blob/master/FAQ.md
Please provide all info and reduce your schema and data to the smallest possible size.
This template is for bug or error reports.
For other issues please see https://github.com/epoberezkin/ajv/blob/master/CONTRIBUTING.md
For other issues please see https://github.com/ajv-validator/ajv/blob/master/CONTRIBUTING.md
-->

**What version of Ajv are you using? Does the issue happen if you use the latest version?**
Expand All @@ -21,7 +21,7 @@ For other issues please see https://github.com/epoberezkin/ajv/blob/master/CONTR

**Ajv options object**

<!-- See https://github.com/epoberezkin/ajv#options -->
<!-- See https://github.com/ajv-validator/ajv#options -->

```javascript

Expand Down Expand Up @@ -54,7 +54,7 @@ For other issues please see https://github.com/epoberezkin/ajv/blob/master/CONTR
<!--
Please:
- make it as small as posssible to reproduce the issue
- use one of the usage patterns from https://github.com/epoberezkin/ajv#getting-started
- use one of the usage patterns from https://github.com/ajv-validator/ajv#getting-started
- use `options`, `schema` and `data` as variables, do not repeat their values here
- post a working code sample in RunKit notebook cloned from https://runkit.com/esp/ajv-issue and include the link here.
Expand Down
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/change.md
Expand Up @@ -8,11 +8,11 @@ assignees: ''
---

<!--
Frequently Asked Questions: https://github.com/epoberezkin/ajv/blob/master/FAQ.md
Frequently Asked Questions: https://github.com/ajv-validator/ajv/blob/master/FAQ.md
Please provide all info and reduce your schema and data to the smallest possible size.
This template is for change proposals.
For other issues please see https://github.com/epoberezkin/ajv/blob/master/CONTRIBUTING.md
For other issues please see https://github.com/ajv-validator/ajv/blob/master/CONTRIBUTING.md
-->

**What version of Ajv you are you using?**
Expand Down
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/compatibility.md
Expand Up @@ -8,11 +8,11 @@ assignees: ''
---

<!--
Frequently Asked Questions: https://github.com/epoberezkin/ajv/blob/master/FAQ.md
Frequently Asked Questions: https://github.com/ajv-validator/ajv/blob/master/FAQ.md
Please provide all info and reduce your schema and data to the smallest possible size.
This template is for compatibility issues.
For other issues please see https://github.com/epoberezkin/ajv/blob/master/CONTRIBUTING.md
For other issues please see https://github.com/ajv-validator/ajv/blob/master/CONTRIBUTING.md
-->

**The version of Ajv you are using**
Expand Down
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/installation.md
Expand Up @@ -8,11 +8,11 @@ assignees: ''
---

<!--
Frequently Asked Questions: https://github.com/epoberezkin/ajv/blob/master/FAQ.md
Frequently Asked Questions: https://github.com/ajv-validator/ajv/blob/master/FAQ.md
Please provide all info and reduce your schema and data to the smallest possible size.
This template is for installation and dependency issues.
For other issues please see https://github.com/epoberezkin/ajv/blob/master/CONTRIBUTING.md
For other issues please see https://github.com/ajv-validator/ajv/blob/master/CONTRIBUTING.md
Before submitting the issue, please try the following:
- use the latest stable Node.js and npm
Expand Down
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/typescript.md
Expand Up @@ -8,10 +8,10 @@ assignees: ''
---

<!--
Frequently Asked Questions: https://github.com/epoberezkin/ajv/blob/master/FAQ.md
Frequently Asked Questions: https://github.com/ajv-validator/ajv/blob/master/FAQ.md
This template is for issues about missing or incorrect type definition and other typescript-related issues.
For other issues please see https://github.com/epoberezkin/ajv/blob/master/CONTRIBUTING.md
For other issues please see https://github.com/ajv-validator/ajv/blob/master/CONTRIBUTING.md
-->

**What version of Ajv are you using? Does the issue happen if you use the latest version?**
Expand Down
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Expand Up @@ -2,7 +2,7 @@
Thank you for submitting a pull request to Ajv.
Before continuing, please read the guidelines:
https://github.com/epoberezkin/ajv/blob/master/CONTRIBUTING.md#pull-requests
https://github.com/ajv-validator/ajv/blob/master/CONTRIBUTING.md#pull-requests
If the pull request contains code please make sure there is an issue that we agreed to resolve (if it is a documentation improvement there is no need for an issue).
Expand Down
4 changes: 2 additions & 2 deletions .github/config.yml
Expand Up @@ -25,8 +25,8 @@ githubLabels:
- [Tutorial by Space Telescope Science Institute](http://json-schema.org/understanding-json-schema/)
- [validation keywords](https://github.com/epoberezkin/ajv#validation-keywords) (in Ajv docs)
- [validation keywords](https://github.com/ajv-validator/ajv#validation-keywords) (in Ajv docs)
- [combining schemas](https://github.com/epoberezkin/ajv#ref) (in Ajv docs)
- [combining schemas](https://github.com/ajv-validator/ajv#ref) (in Ajv docs)
- [Tutorial by @epoberezkin](https://code.tutsplus.com/tutorials/validating-data-with-json-schema-part-1--cms-25343)
2 changes: 1 addition & 1 deletion COERCION.md
@@ -1,6 +1,6 @@
# Ajv type coercion rules

To enable type coercion pass option `coerceTypes` to Ajv with `true` or `array` (it is `false` by default). See [example](https://github.com/epoberezkin/ajv#coercing-data-types).
To enable type coercion pass option `coerceTypes` to Ajv with `true` or `array` (it is `false` by default). See [example](https://github.com/ajv-validator/ajv#coercing-data-types).

The coercion rules are different from JavaScript:
- to validate user input as expected
Expand Down
18 changes: 9 additions & 9 deletions CONTRIBUTING.md
Expand Up @@ -24,7 +24,7 @@ Ajv has a lot of features and maintaining documentation takes time. I appreciate

## Issues

Before submitting the issue please search the existing issues and also review [Frequently Asked Questions](https://github.com/epoberezkin/ajv/blob/master/FAQ.md).
Before submitting the issue please search the existing issues and also review [Frequently Asked Questions](https://github.com/ajv-validator/ajv/blob/master/FAQ.md).

I would really appreciate the time you spend providing all the information and reducing both your schema and data to the smallest possible size when they still have the issue. Simplifying the issue also makes it more valuable for other users (in cases it turns out to be an incorrect usage rather than a bug).

Expand All @@ -34,15 +34,15 @@ I would really appreciate the time you spend providing all the information and r
Please make sure to include the following information in the issue:

1. What version of Ajv are you using? Does the issue happen if you use the latest version?
2. Ajv options object (see https://github.com/epoberezkin/ajv#options).
2. Ajv options object (see https://github.com/ajv-validator/ajv#options).
3. JSON Schema and the data you are validating (please make it as small as possible to reproduce the issue).
4. Your code (please use `options`, `schema` and `data` as variables).
5. Validation result, data AFTER validation, error messages.
6. What results did you expect?

Please include the link to the working code sample at Runkit.com (please clone https://runkit.com/esp/ajv-issue) - it will speed up investigation and fixing.

[Create bug report](https://github.com/epoberezkin/ajv/issues/new?template=bug-or-error-report.md).
[Create bug report](https://github.com/ajv-validator/ajv/issues/new?template=bug-or-error-report.md).


#### Security vulnerabilities
Expand All @@ -56,7 +56,7 @@ Please do NOT report security vulnerabilities via GitHub issues.

#### <a name="changes"></a>Change proposals

[Create a proposal](https://github.com/epoberezkin/ajv/issues/new?template=change.md) for a new feature, option or some other improvement.
[Create a proposal](https://github.com/ajv-validator/ajv/issues/new?template=change.md) for a new feature, option or some other improvement.

Please include this information:

Expand All @@ -76,7 +76,7 @@ Please include as much details as possible.

#### <a name="compatibility"></a>Browser and compatibility issues

[Create an issue](https://github.com/epoberezkin/ajv/issues/new?template=compatibility.md) to report a compatibility problem that only happens in a particular environment (when your code works correctly in node.js v8+ in linux systems but fails in some other environment).
[Create an issue](https://github.com/ajv-validator/ajv/issues/new?template=compatibility.md) to report a compatibility problem that only happens in a particular environment (when your code works correctly in node.js v8+ in linux systems but fails in some other environment).

Please include this information:

Expand All @@ -90,7 +90,7 @@ Please include this information:

#### <a name="installation"></a>Installation and dependency issues

[Create an issue](https://github.com/epoberezkin/ajv/issues/new?template=installation.md) to report problems that happen during Ajv installation or when Ajv is missing some dependency.
[Create an issue](https://github.com/ajv-validator/ajv/issues/new?template=installation.md) to report problems that happen during Ajv installation or when Ajv is missing some dependency.

Before submitting the issue, please try the following:
- use the latest stable Node.js and `npm`
Expand Down Expand Up @@ -143,9 +143,9 @@ npm run test-fast
git commit -nm 'type: message'
```

All validation functions are generated using doT templates in [dot](https://github.com/epoberezkin/ajv/tree/master/lib/dot) folder. Templates are precompiled so doT is not a run-time dependency.
All validation functions are generated using doT templates in [dot](https://github.com/ajv-validator/ajv/tree/master/lib/dot) folder. Templates are precompiled so doT is not a run-time dependency.

`npm run build` - compiles templates to [dotjs](https://github.com/epoberezkin/ajv/tree/master/lib/dotjs) folder.
`npm run build` - compiles templates to [dotjs](https://github.com/ajv-validator/ajv/tree/master/lib/dotjs) folder.

`npm run watch` - automatically compiles templates when files in dot folder change

Expand All @@ -154,7 +154,7 @@ All validation functions are generated using doT templates in [dot](https://gith

To make accepting your changes faster please follow these steps:

1. Submit an [issue with the bug](https://github.com/epoberezkin/ajv/issues/new) or with the proposed change (unless the contribution is to fix the documentation typos and mistakes).
1. Submit an [issue with the bug](https://github.com/ajv-validator/ajv/issues/new) or with the proposed change (unless the contribution is to fix the documentation typos and mistakes).
2. Please describe the proposed api and implementation plan (unless the issue is a relatively simple bug and fixing it doesn't change any api).
3. Once agreed, please write as little code as possible to achieve the desired result.
4. Please avoid unnecessary changes, refactoring or changing coding styles as part of your change (unless the change was proposed as refactoring).
Expand Down
14 changes: 7 additions & 7 deletions CUSTOM.md
Expand Up @@ -34,7 +34,7 @@ This way to define keywords is useful for:
- testing your keywords before converting them to compiled/inlined keywords
- defining keywords that do not depend on the schema value (e.g., when the value is always `true`). In this case you can add option `schema: false` to the keyword definition and the schemas won't be passed to the validation function, it will only receive the same 4 parameters as compiled validation function (see the next section).
- defining keywords where the schema is a value used in some expression.
- defining keywords that support [$data reference](https://github.com/epoberezkin/ajv#data-reference) - in this case validation function is required, either as the only option or in addition to compile, macro or inline function (see below).
- defining keywords that support [$data reference](https://github.com/ajv-validator/ajv#data-reference) - in this case validation function is required, either as the only option or in addition to compile, macro or inline function (see below).

__Please note__: In cases when validation flow is different depending on the schema and you have to use `if`s, this way to define keywords will have worse performance than compiled keyword returning different validation functions depending on the schema.

Expand Down Expand Up @@ -197,7 +197,7 @@ console.log(validate([3,4,5])); // true, number 5 matches schema inside "contain

`contains` keyword is already available in Ajv with option `v5: true`.

See the example of defining recursive macro keyword `deepProperties` in the [test](https://github.com/epoberezkin/ajv/blob/master/spec/custom.spec.js#L151).
See the example of defining recursive macro keyword `deepProperties` in the [test](https://github.com/ajv-validator/ajv/blob/master/spec/custom.spec.js#L151).


### Define keyword with "inline" compilation function
Expand Down Expand Up @@ -294,7 +294,7 @@ The first parameter passed to inline keyword compilation function (and the 3rd p
- _opts_ - Ajv instance option. You should not be changing them.
- _formats_ - all formats available in Ajv instance, including the custom ones.
- _compositeRule_ - boolean indicating that the current schema is inside the compound keyword where failing some rule doesn't mean validation failure (`anyOf`, `oneOf`, `not`, `if` in `switch`). This flag is used to determine whether you can return validation result immediately after any error in case the option `allErrors` is not `true. You only need to do it if you have many steps in your keywords and potentially can define multiple errors.
- _validate_ - the function you need to use to compile subschemas in your keywords (see the [implementation](https://github.com/epoberezkin/ajv-keywords/blob/master/keywords/dot/switch.jst) of `switch` keyword for example).
- _validate_ - the function you need to use to compile subschemas in your keywords (see the [implementation](https://github.com/ajv-validator/ajv-keywords/blob/master/keywords/dot/switch.jst) of `switch` keyword for example).
- _util_ - [Ajv utilities](#ajv-utilities) you can use in your inline compilation functions.
- _self_ - Ajv instance.

Expand All @@ -311,8 +311,8 @@ There is a number of variables and expressions you can use in the generated (val
- `'validate.schema' + it.schemaPath` - current level schema available at validation time (the same schema at compile time is `it.schema`).
- `'validate.schema' + it.schemaPath + '.' + keyword` - the value of your custom keyword at validation-time. Keyword is passed as the second parameter to the inline compilation function to allow using the same function to compile multiple keywords.
- `'valid' + it.level` - the variable that you have to declare and to assign the validation result to if your keyword returns statements rather than expression (`statements: true`).
- `'errors'` - the number of encountered errors. See [Reporting errors in custom keywords](https://github.com/epoberezkin/ajv/blob/master/CUSTOM.md#reporting-errors-in-custom-keywords).
- `'vErrors'` - the array with errors collected so far. See [Reporting errors in custom keywords](https://github.com/epoberezkin/ajv/blob/master/CUSTOM.md#reporting-errors-in-custom-keywords).
- `'errors'` - the number of encountered errors. See [Reporting errors in custom keywords](https://github.com/ajv-validator/ajv/blob/master/CUSTOM.md#reporting-errors-in-custom-keywords).
- `'vErrors'` - the array with errors collected so far. See [Reporting errors in custom keywords](https://github.com/ajv-validator/ajv/blob/master/CUSTOM.md#reporting-errors-in-custom-keywords).


## Ajv utilities
Expand Down Expand Up @@ -410,7 +410,7 @@ All custom keywords but macro keywords can optionally create custom error messag

Synchronous validating and compiled keywords should define errors by assigning them to `.errors` property of the validation function. Asynchronous keywords can return promise that rejects with `new Ajv.ValidationError(errors)`, where `errors` is an array of custom validation errors (if you don't want to define custom errors in asynchronous keyword, its validation function can return the promise that resolves with `false`).

Inline custom keyword should increase error counter `errors` and add error to `vErrors` array (it can be null). This can be done for both synchronous and asynchronous keywords. See [example range keyword](https://github.com/epoberezkin/ajv/blob/master/spec/custom_rules/range_with_errors.jst).
Inline custom keyword should increase error counter `errors` and add error to `vErrors` array (it can be null). This can be done for both synchronous and asynchronous keywords. See [example range keyword](https://github.com/ajv-validator/ajv/blob/master/spec/custom_rules/range_with_errors.jst).

When inline keyword performs validation Ajv checks whether it created errors by comparing errors count before and after validation. To skip this check add option `errors` (can be `"full"`, `true` or `false`) to keyword definition:

Expand All @@ -429,7 +429,7 @@ Each error object should at least have properties `keyword`, `message` and `para

Inlined keywords can optionally define `dataPath` and `schemaPath` properties in error objects, that will be assigned by Ajv unless `errors` option of the keyword is `"full"`.

If custom keyword doesn't create errors, the default error will be created in case the keyword fails validation (see [Validation errors](https://github.com/epoberezkin/ajv#validation-errors)).
If custom keyword doesn't create errors, the default error will be created in case the keyword fails validation (see [Validation errors](https://github.com/ajv-validator/ajv#validation-errors)).


## Short-circuit validation
Expand Down

0 comments on commit 7b7faa5

Please sign in to comment.