Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: ajv-validator/ajv
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v7.1.0
Choose a base ref
...
head repository: ajv-validator/ajv
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v7.1.1
Choose a head ref
  • 6 commits
  • 5 files changed
  • 3 contributors

Commits on Feb 11, 2021

  1. readme heading

    epoberezkin committed Feb 11, 2021
    Copy the full SHA
    5b715aa View commit details

Commits on Feb 13, 2021

  1. Issue 1441

    teq0 committed Feb 13, 2021

    Unverified

    The email in this signature doesn’t match the committer email.
    Copy the full SHA
    6bd9c45 View commit details
  2. Merge pull request #1442 from teq0/issue-1441

    Issue 1441
    epoberezkin authored Feb 13, 2021

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    6926312 View commit details

Commits on Feb 16, 2021

  1. fix: allow readonly arrays in interfaces

    Before this change, a readonly array would be inferred as "object":
    
    ```ts
    interface TransactionInput {
      items: readonly { count: number, productId: string }[]
    }
    
    const transactionInputValidator = ajv.compile<TransactionInput>({
      additionalProperties: false,
      properties: {
        items: { type: 'array' }, // <--- Error: TS wants this to be "object"
      },
      required: ['items'],
      type: 'object'
    })
    ```
    
    Now this is properly inferred as "array".
    LinusU authored Feb 16, 2021

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    3468e93 View commit details
  2. Merge pull request #1448 from LinusU/patch-1

    fix: allow readonly arrays in interfaces
    epoberezkin authored Feb 16, 2021

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    e63771c View commit details
  3. 7.1.1

    epoberezkin committed Feb 16, 2021
    Copy the full SHA
    77d788f View commit details
Showing with 10 additions and 4 deletions.
  1. +3 −1 README.md
  2. +1 −1 lib/core.ts
  3. +1 −1 lib/types/json-schema.ts
  4. +1 −1 package.json
  5. +4 −0 spec/keyword.spec.ts
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -2,7 +2,9 @@

# Ajv: Another JSON schema validator

The fastest JSON schema validator for Node.js and browser. Supports JSON Schema draft-06/07/2019-09 (draft-04 is supported in [version 6](https://github.com/ajv-validator/ajv/tree/v6)) and JSON Type Definition [RFC8927](https://datatracker.ietf.org/doc/rfc8927/).
The fastest JSON schema validator for Node.js and browser.

Supports JSON Schema draft-06/07/2019-09 (draft-04 is supported in [version 6](https://github.com/ajv-validator/ajv/tree/v6)) and JSON Type Definition [RFC8927](https://datatracker.ietf.org/doc/rfc8927/).

[![build](https://github.com/ajv-validator/ajv/workflows/build/badge.svg)](https://github.com/ajv-validator/ajv/actions?query=workflow%3Abuild)
[![npm](https://img.shields.io/npm/v/ajv.svg)](https://www.npmjs.com/package/ajv)
2 changes: 1 addition & 1 deletion lib/core.ts
Original file line number Diff line number Diff line change
@@ -742,7 +742,7 @@ function getLogger(logger?: Partial<Logger> | false): Logger {
throw new Error("logger must implement log, warn and error methods")
}

const KEYWORD_NAME = /^[a-z_$][a-z0-9_$-:]*$/i
const KEYWORD_NAME = /^[a-z_$][a-z0-9_$:-]*$/i

function checkKeyword(this: Ajv, keyword: string | string[], def?: KeywordDefinition): void {
const {RULES} = this
2 changes: 1 addition & 1 deletion lib/types/json-schema.ts
Original file line number Diff line number Diff line change
@@ -38,7 +38,7 @@ export type JSONSchemaType<T, _partial extends boolean = false> = (T extends num
} & {length: T["length"]}
minItems: T["length"]
} & ({maxItems: T["length"]} | {additionalItems: false})
: T extends any[]
: T extends readonly any[]
? {
type: JSONType<"array", _partial>
items: JSONSchemaType<T[0]>
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": "7.1.0",
"version": "7.1.1",
"description": "Another JSON Schema Validator",
"main": "dist/ajv.js",
"types": "dist/ajv.d.ts",
4 changes: 4 additions & 0 deletions spec/keyword.spec.ts
Original file line number Diff line number Diff line change
@@ -1099,6 +1099,10 @@ describe("User-defined keywords", () => {
ajv.addKeyword("colons:are-valid")
})

should.throw(() => {
ajv.addKeyword("single-'quote-not-valid")
}, /invalid name/)

should.throw(() => {
ajv.addKeyword("3-start-with-number-not-valid")
}, /invalid name/)