Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
efebarlas authored Nov 10, 2021
2 parents d9ea90c + 8fccddb commit 0ff99ed
Show file tree
Hide file tree
Showing 17 changed files with 358 additions and 87 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:

strategy:
matrix:
node-version: [10.x, 12.x, 14.x]
node-version: [12.x, 14.x, 16.x]

steps:
- uses: actions/checkout@v2
Expand All @@ -22,13 +22,13 @@ jobs:
node-version: ${{ matrix.node-version }}
- run: npm install
- run: git submodule update --init
# - name: update website
# if: ${{ github.event_name == 'push' && matrix.node-version == '14.x' }}
# run: ./scripts/publish-site
# env:
# GH_TOKEN_PUBLIC: ${{ secrets.GH_TOKEN_PUBLIC }}
# GIT_USER_EMAIL: ${{ secrets.GIT_USER_EMAIL }}
# GIT_USER_NAME: ${{ secrets.GIT_USER_NAME }}
- name: update website
if: ${{ github.event_name == 'push' && matrix.node-version == '14.x' }}
run: ./scripts/publish-site
env:
GH_TOKEN_PUBLIC: ${{ secrets.GH_TOKEN_PUBLIC }}
GIT_USER_EMAIL: ${{ secrets.GIT_USER_EMAIL }}
GIT_USER_NAME: ${{ secrets.GIT_USER_NAME }}
- run: npm run build
- run: npm run test-ci
- name: coveralls
Expand Down
24 changes: 6 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,13 @@ Supports JSON Schema draft-04/06/07/2019-09/2020-12 ([draft-04 support](https://
[![Gitter](https://img.shields.io/gitter/room/ajv-validator/ajv.svg)](https://gitter.im/ajv-validator/ajv)
[![GitHub Sponsors](https://img.shields.io/badge/$-sponsors-brightgreen)](https://github.com/sponsors/epoberezkin)

## Platinum sponsors
## Ajv sponsors

[<img src="https://ajv.js.org/img/mozilla.svg" width="45%">](https://www.mozilla.org)<img src="https://ajv.js.org/img/gap.svg" width="8%">[<img src="https://ajv.js.org/img/reserved.svg" width="45%">](https://opencollective.com/ajv)
[<img src="https://ajv.js.org/img/mozilla.svg" width="45%" alt="Mozilla">](https://www.mozilla.org)<img src="https://ajv.js.org/img/gap.svg" width="9%">[<img src="https://ajv.js.org/img/reserved.svg" width="45%">](https://opencollective.com/ajv)

## Ajv online event - May 20, 10am PT / 6pm UK
[<img src="https://ajv.js.org/img/microsoft.png" width="31%" alt="Microsoft">](https://opensource.microsoft.com)<img src="https://ajv.js.org/img/gap.svg" width="3%">[<img src="https://ajv.js.org/img/reserved.svg" width="31%">](https://opencollective.com/ajv)<img src="https://ajv.js.org/img/gap.svg" width="3%">[<img src="https://ajv.js.org/img/reserved.svg" width="31%">](https://opencollective.com/ajv)

We will talk about:
- new features of Ajv version 8.
- the improvements sponsored by Mozilla's MOSS grant.
- how Ajv is used in JavaScript applications.

Speakers:
- [Evgeny Poberezkin](https://github.com/epoberezkin), the creator of Ajv.
- [Mehan Jayasuriya](https://github.com/mehan), Program Officer at Mozilla Foundation, leading the [MOSS](https://www.mozilla.org/en-US/moss/) and other programs investing in the open source and community ecosystems.
- [Matteo Collina](https://github.com/mcollina), Technical Director at NearForm and Node.js Technical Steering Committee member, creator of Fastify web framework.
- [Kin Lane](https://github.com/kinlane), Chief Evangelist at Postman. Studying the tech, business & politics of APIs since 2010. Presidential Innovation Fellow during the Obama administration.
- [Ulysse Carion](https://github.com/ucarion), the creator of JSON Type Definition specification.

[Gajus Kuizinas](https://github.com/gajus) will host the event.

Please [register here](https://us02web.zoom.us/webinar/register/2716192553618/WN_erJ_t4ICTHOnGC1SOybNnw).
[<img src="https://ajv.js.org/img/retool.svg" width="22.5%" alt="Retool">](https://retool.com/?utm_source=sponsor&utm_campaign=ajv)<img src="https://ajv.js.org/img/gap.svg" width="3%">[<img src="https://ajv.js.org/img/tidelift.svg" width="22.5%" alt="Tidelift">](https://tidelift.com/subscription/pkg/npm-ajv?utm_source=npm-ajv&utm_medium=referral&utm_campaign=enterprise)<img src="https://ajv.js.org/img/gap.svg" width="3%">[<img src="https://ajv.js.org/img/reserved.svg" width="22.5%">](https://opencollective.com/ajv)<img src="https://ajv.js.org/img/gap.svg" width="3%">[<img src="https://ajv.js.org/img/reserved.svg" width="22.5%">](https://opencollective.com/ajv)

## Contributing

Expand Down Expand Up @@ -84,6 +70,8 @@ Thank you.
<a href="https://opencollective.com/ajv/organization/7/website"><img src="https://opencollective.com/ajv/organization/7/avatar.svg"></a>
<a href="https://opencollective.com/ajv/organization/8/website"><img src="https://opencollective.com/ajv/organization/8/avatar.svg"></a>
<a href="https://opencollective.com/ajv/organization/9/website"><img src="https://opencollective.com/ajv/organization/9/avatar.svg"></a>
<a href="https://opencollective.com/ajv/organization/10/website"><img src="https://opencollective.com/ajv/organization/10/avatar.svg"></a>
<a href="https://opencollective.com/ajv/organization/11/website"><img src="https://opencollective.com/ajv/organization/11/avatar.svg"></a>

## Performance

Expand Down
63 changes: 51 additions & 12 deletions docs/.vuepress/components/Sponsors.vue
Original file line number Diff line number Diff line change
@@ -1,29 +1,68 @@
<template>
<div class="sponsors">
<div class="sponsors" :class="level">
<slot />
</div>
</template>

<script>
export default {
props: {
level: {
type: String,
},
},
}
</script>

<style lang="stylus" scoped>
.sponsors
max-width 800px
margin 0 auto
h2
margin-left 0
text-decoration none
a.header-anchor
width auto
margin-right 0
p
font-size 24px
img
width 100%
&.platinum, &.gold, &.bronze
img
width 100%
a
margin-bottom 10px
display inline-block
@media only screen and (min-width: $MQMobileNarrow)
margin-bottom 0
a:last-child
margin-right 0
&.platinum
a
width 100%
display block
@media only screen and (min-width: $MQMobileNarrow)
display inline-block
width 45%
margin-right 8%
a
width 100%
display block
margin-bottom 10px
@media only screen and (min-width: $MQMobileNarrow)
&.gold
a
width 45%
display inline-block
margin-bottom 0
margin-right 4%
@media only screen and (min-width: $MQMobileNarrow)
width 31%
margin-right 2%
&.bronze
a
width 45%
margin-right 4%
@media only screen and (min-width: $MQMobileNarrow)
width 22%
margin-right 3%
a:first-child
margin-right 8%
</style>
Binary file added docs/.vuepress/public/img/microsoft.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/.vuepress/public/img/retool.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/.vuepress/public/img/retool.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 33 additions & 0 deletions docs/.vuepress/public/img/tidelift.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 20 additions & 2 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,32 @@ Use JSON Type Definition or JSON Schema
</Feature>
</Features>

<Sponsors>
<Sponsors level="platinum">

Platinum sponsors
## Ajv sponsors

[![mozilla](/img/mozilla.svg)](https://www.mozilla.org)
[![reserved](/img/reserved.svg)](https://opencollective.com/ajv)

</Sponsors>

<Sponsors level="gold">

[![microsoft](/img/microsoft.png)](https://opensource.microsoft.com)
[![reserved](/img/reserved.svg)](https://opencollective.com/ajv)
[![reserved](/img/reserved.svg)](https://opencollective.com/ajv)

</Sponsors>

<Sponsors level="bronze">

[![retool](/img/retool.svg)](https://retool.com/?utm_source=sponsor&utm_campaign=ajv)
[![tidelift](/img/tidelift.svg)](https://tidelift.com/subscription/pkg/npm-ajv?utm_source=npm-ajv&utm_medium=referral&utm_campaign=enterprise)
[![reserved](/img/reserved.svg)](https://opencollective.com/ajv)
[![reserved](/img/reserved.svg)](https://opencollective.com/ajv)

</Sponsors>

</HeroSection>

<HomeSection>
Expand Down
9 changes: 7 additions & 2 deletions docs/guide/typescript.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,15 +132,20 @@ const validData = {
bar: "abc"
}

if (validate(data)) {
if (validate(validData)) {
// data is MyData here
console.log(data.foo)
console.log(validData.foo)
} else {
console.log(validate.errors)
}
```
</code-block>
</code-group>


::: warning TypeScript limitation
Note that it's currently not possible for `JTDDataType` to know whether the compiler is inferring timestamps as strings or Dates, and so it conservatively types any timestamp as `string | Date`. This is accurate, but often requires extra validation on the part of the user to confirm they're getting the appropriate data type.
:::

## Type-safe error handling

Expand Down
Binary file modified docs/projects/tsed.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 9 additions & 1 deletion lib/vocabularies/applicator/contains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,19 @@ const def: CodeKeywordDefinition = {
validateItems(valid, () => gen.if(valid, () => gen.break()))
} else {
gen.let(valid, false)
if (min === 0) {
gen.if(_`${data}.length > 0`, validateItemsWithCount, () => gen.assign(valid, true))
} else {
validateItemsWithCount()
}
}
cxt.result(valid, () => cxt.reset())

function validateItemsWithCount(): void {
const schValid = gen.name("_valid")
const count = gen.let("count", 0)
validateItems(schValid, () => gen.if(schValid, () => checkLimits(count)))
}
cxt.result(valid, () => cxt.reset())

function validateItems(_valid: Name, block: () => void): void {
gen.forRange("i", 0, len, (i) => {
Expand Down
18 changes: 8 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ajv",
"version": "8.6.2",
"version": "8.7.1",
"description": "Another JSON Schema Validator",
"main": "dist/ajv.js",
"types": "dist/ajv.d.ts",
Expand All @@ -10,10 +10,10 @@
".runkit_example.js"
],
"scripts": {
"eslint": "eslint \"lib/**/*.ts\" \"spec/**/*.*s\" scripts --ignore-pattern spec/JSON-Schema-Test-Suite",
"eslint": "eslint \"lib/**/*.ts\" \"spec/**/*.*s\" --ignore-pattern spec/JSON-Schema-Test-Suite",
"prettier:write": "prettier --write \"./**/*.{json,yaml,js,ts}\"",
"prettier:check": "prettier --list-different \"./**/*.{json,yaml,js,ts}\"",
"test-spec": "cross-env TS_NODE_PROJECT=spec/tsconfig.json mocha -r ts-node/register \"spec/**/*.spec.{ts,js}\" -R dot -g \\(.recursiveRef.with.no..recursiveAnchor\\|.dynamicRef.with.no..dynamicAnchor\\).in.the.initial.target.schema.resource -i",
"test-spec": "cross-env TS_NODE_PROJECT=spec/tsconfig.json mocha -r ts-node/register \"spec/**/*.spec.{ts,js}\" -R dot",
"test-codegen": "nyc cross-env TS_NODE_PROJECT=spec/tsconfig.json mocha -r ts-node/register 'spec/codegen.spec.ts' -R spec",
"test-debug": "npm run test-spec -- --inspect-brk",
"test-cov": "nyc npm run test-spec",
Expand All @@ -23,10 +23,10 @@
"test-karma": "karma start",
"test-browser": "rm -rf .browser && npm run bundle && scripts/prepare-tests && karma start",
"test-all": "npm run test-cov && if-node-version 12 npm run test-browser",
"test": "npm run json-tests && npm run prettier:check && npm run eslint && npm link && npm link ajv && npm run test-cov",
"test": "npm run json-tests && npm run prettier:check && npm run eslint && npm link && npm link --legacy-peer-deps ajv && npm run test-cov",
"test-ci": "AJV_FULL_TEST=true npm test",
"prepublish": "npm run build",
"benchmark": "npm i && npm run build && npm link && cd ./benchmark && npm link ajv && npm i && node ./jtd",
"benchmark": "npm i && npm run build && npm link && cd ./benchmark && npm link --legacy-peer-deps ajv && npm i && node ./jtd",
"docs:dev": "./scripts/prepare-site && vuepress dev docs",
"docs:build": "./scripts/prepare-site && vuepress build docs"
},
Expand Down Expand Up @@ -64,7 +64,7 @@
},
"devDependencies": {
"@ajv-validator/config": "^0.3.0",
"@rollup/plugin-commonjs": "^20.0.0",
"@rollup/plugin-commonjs": "^21.0.0",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^13.0.0",
"@rollup/plugin-typescript": "^8.2.1",
Expand All @@ -74,8 +74,7 @@
"@types/require-from-string": "^1.2.0",
"@typescript-eslint/eslint-plugin": "^3.8.0",
"@typescript-eslint/parser": "^3.8.0",
"@vuepress/shared-utils": "^1.8.2",
"ajv-formats": "^2.0.0",
"ajv-formats": "^3.0.0-rc.0",
"chai": "^4.0.1",
"cross-env": "^7.0.2",
"dayjs": "^1.10.4",
Expand All @@ -101,8 +100,7 @@
"rollup-plugin-terser": "^7.0.2",
"ts-node": "^10.0.0",
"tsify": "^5.0.2",
"typescript": "^4.2.0",
"vuepress": "^1.8.2"
"typescript": "^4.2.0"
},
"collective": {
"type": "opencollective",
Expand Down
1 change: 1 addition & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@ function createBundleConfig(sourceFile, outFile, globalName) {
export default [
createBundleConfig("ajv", "ajv7", "av7"),
createBundleConfig("2019", "ajv2019", "ajv2019"),
createBundleConfig("2020", "ajv2020", "ajv2020"),
createBundleConfig("jtd", "ajvJTD", "ajvJTD"),
]
7 changes: 4 additions & 3 deletions scripts/get-contributors.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// https://github.com/sveltejs/svelte/blob/ce3a5791258ec6ecf8c1ea022cb871afe805a45c/site/scripts/get-contributors.js

const fs = require("fs")
const fetch = require("node-fetch")
const Jimp = require("jimp")

process.chdir(__dirname)
Expand All @@ -12,7 +11,11 @@ const {GH_TOKEN_PUBLIC} = process.env

const SIZE = 64

main()

async function main() {
const fetch = (await import("node-fetch")).default

const contributors = []
let page = 1

Expand Down Expand Up @@ -53,5 +56,3 @@ async function main() {
`module.exports = ${str}`
)
}

main()
2 changes: 2 additions & 0 deletions scripts/publish-site
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ set -ex
echo "About to publish $GITHUB_REF to gh-pages..."
rm -rf ../gh-pages

npm install vuepress@1
npm install @vuepress/shared-utils@1
npm run docs:build

git config --global user.name "$GIT_USER_NAME"
Expand Down
2 changes: 1 addition & 1 deletion spec/JSON-Schema-Test-Suite
Loading

0 comments on commit 0ff99ed

Please sign in to comment.