-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from amio-io/schema-validator
feat: Schema validator
- Loading branch information
Showing
12 changed files
with
230 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
|
||
version: 2.1 | ||
|
||
defaults: &defaults | ||
working_directory: ~/json-validations-lib | ||
docker: | ||
- image: circleci/node:12.13.1 | ||
|
||
commands: | ||
npm_install: | ||
description: Installs & caches npm dependencies. | ||
parameters: | ||
cache_version: | ||
type: integer | ||
default: 1 | ||
steps: | ||
- restore_cache: | ||
keys: | ||
- v<< parameters.cache_version >>-dependencies-{{ checksum "package.json" }} | ||
# fallback to using the latest cache if no exact match is found | ||
- v<< parameters.cache_version >>-dependencies- | ||
- run: npm install | ||
- save_cache: | ||
paths: | ||
- node_modules | ||
key: v<< parameters.cache_version >>-dependencies-{{ checksum "package.json" }} | ||
|
||
jobs: | ||
build: | ||
<<: *defaults | ||
|
||
steps: | ||
- checkout | ||
- npm_install: | ||
cache_version: 1 | ||
|
||
- run: | ||
name: Test - units | ||
command: npm run-script test-units | ||
|
||
- persist_to_workspace: | ||
root: ~/json-validations-lib | ||
paths: . | ||
|
||
publish_prod: | ||
<<: *defaults | ||
|
||
steps: | ||
- attach_workspace: | ||
at: ~/json-validations-lib | ||
- run: | ||
name: Can publish to NPM? | ||
command: npm run-script can-publish-nix | ||
- run: | ||
name: Authenticate with registry | ||
command: echo "//registry.npmjs.org/:_authToken=$npm_TOKEN" > ~/json-validations-lib/.npmrc | ||
- run: | ||
name: Publish package | ||
command: npm publish --access public | ||
|
||
workflows: | ||
build_and_publish: | ||
jobs: | ||
- build: | ||
filters: | ||
tags: | ||
# PROD - run CircleCI on tag create | ||
only: /^v[0-9]+(\.[0-9]+)*/ | ||
- publish_prod: | ||
requires: | ||
- build | ||
filters: | ||
tags: | ||
# run CircleCI on tag create | ||
only: /^v[0-9]+(\.[0-9]+)*/ | ||
branches: | ||
ignore: /.*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
# json-validations-lib | ||
Private lib. We do not recommend to use it. | ||
We do not recommend to use this lib, it is for Amio purposes. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,25 @@ | ||
{ | ||
"name": "json-validations-lib", | ||
"version": "0.0.0", | ||
"private": true, | ||
"version": "1.0.0", | ||
"scripts": { | ||
"test-units": "cross-env BUILD_ENV=test DEBUG=amio* mocha test/test_unit/**/*.test.js --reporter mocha-multi-reporters --reporter-options configFile=test/mocha-reporters-config.json" | ||
"test-units": "cross-env BUILD_ENV=test DEBUG=amio* mocha test/test_unit/**/*.test.js --reporter mocha-multi-reporters --reporter-options configFile=test/mocha-reporters-config.json", | ||
"can-publish-nix": "npm info $npm_package_name version | npm-version-bump-checker", | ||
"can-publish-win": "npm info %npm_package_name% version | npm-version-bump-checker" | ||
}, | ||
"dependencies": { | ||
"ajv": "6.10.2", | ||
"logzio-node-debug": "^2.0.0", | ||
"logzio-node-debug": "2.0.0", | ||
"ramda": "0.26.1", | ||
"valid-url": "1.0.9" | ||
}, | ||
"devDependencies": { | ||
"chai": "4.2.0", | ||
"chai-as-promised": "7.1.1", | ||
"cross-env": "6.0.3", | ||
"mocha": "6.1.4", | ||
"mocha-junit-reporter": "1.22.0", | ||
"mocha-multi-reporters": "1.1.7", | ||
"mochawesome": "3.1.2" | ||
"mochawesome": "3.1.2", | ||
"npm-version-bump-checker": "1.0.4" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
const chai = require('chai') | ||
const expect = chai.expect | ||
const AsyncValidatorTest = require('../utils/async-validator-test') | ||
chai.use(require('chai-as-promised')) | ||
|
||
describe('async-validator test', async () => { | ||
const asyncValidatorTest = new AsyncValidatorTest() | ||
|
||
it('Validation passed', async () => { | ||
const result = await asyncValidatorTest.validate({valid: true}) | ||
expect(result).to.be.true | ||
}) | ||
|
||
it('Validation failed', async () => { | ||
const result = asyncValidatorTest.validate({valid: false}) | ||
await expect(result).to.be.rejectedWith('expected "valid" to be true').eventually.include({ | ||
message: 'expected "valid" to be true', | ||
field: 'valid', | ||
rejected_value: false | ||
}) | ||
}) | ||
|
||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.