Skip to content

Commit aafb6fc

Browse files
Merge pull request #6 from amio-io/5-different-file-structure
feat: Different file structure #5
2 parents 87ea833 + b30e2be commit aafb6fc

File tree

5 files changed

+9
-5
lines changed

5 files changed

+9
-5
lines changed

index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports.SchemaValidatorError = require('./src/errors/schema-validator-error')
2+
module.exports.AsyncValidator = require('./src/async-validator')
3+
module.exports.SchemaValidator = require('./src/schema-validator')

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "json-validations-lib",
3-
"version": "1.0.0",
3+
"version": "1.1.0",
44
"scripts": {
55
"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",
66
"can-publish-nix": "npm info $npm_package_name version | npm-version-bump-checker",

src/async-validator.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
const convertValidationError = require("./utils/validation-errors-converter");
1+
const {convertValidationError} = require("./utils/validation-errors-converter");
22

33
class AsyncValidator {
44

5+
// noinspection JSUnusedLocalSymbols
56
async validate(data) {
67
throw Error('validate() must be implemented in children')
78
}

src/utils/validation-errors-converter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function convertValidationError(error) {
1515
return new SchemaValidatorError(`Property '${params.additionalProperty}' is not supported.`,
1616
errorObject.dataPath + '.' + params.additionalProperty)
1717
case 'required': {
18-
const fieldPath = (errorObject.dataPath) ? errorObject.dataPath : '.'
18+
const fieldPath = errorObject.dataPath || '.'
1919
return new SchemaValidatorError(`Missing property '${params.missingProperty}'.`, fieldPath)
2020
}
2121
case 'const':

test/test_unit/async-validator.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ describe('async-validator test', async () => {
1212
})
1313

1414
it('Validation failed', async () => {
15-
const result = asyncValidatorTest.validate({valid: false})
16-
await expect(result).to.be.rejectedWith('expected "valid" to be true').eventually.include({
15+
const validateFn = asyncValidatorTest.validate({valid: false})
16+
await expect(validateFn).to.be.rejectedWith('expected "valid" to be true').eventually.include({
1717
message: 'expected "valid" to be true',
1818
field: 'valid',
1919
rejected_value: false

0 commit comments

Comments
 (0)