Skip to content

Commit 8a7a657

Browse files
author
Robert Kesterson
committed
feat: permissive mode
cleaned up unit test and ts config
1 parent 13efde2 commit 8a7a657

12 files changed

+6594
-78
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@ Options:
105105
one single type. [boolean] [default: false]
106106
--useNamedExport Type name is a named export, rather than the default
107107
export of the file [boolean] [default: false]
108+
--generatePermissive If --noExtraProps is true then generate validators that
109+
clean the object [boolean] [default: false]
110+
--output overrides filename [string]
108111
-* [default: []]
109112
110113
```

package-lock.json

Lines changed: 6158 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@
4242
"ts-jest": "^23.0.0",
4343
"ts-node": "^8.3.0",
4444
"tslint": "^5.10.0",
45-
"typescript": "^3.4.5"
45+
"typescript": "^3.4.5",
46+
"ajv": "^6.12.0"
4647
},
4748
"jest": {
4849
"watchPathIgnorePatterns": [
@@ -59,7 +60,12 @@
5960
"^.+\\.ts$": "ts-jest"
6061
},
6162
"transformIgnorePatterns": [],
62-
"testRegex": ".*/__tests__/.*\\.(test|spec)\\.ts$"
63+
"testRegex": ".*/__tests__/.*\\.(test|spec)\\.ts$",
64+
"globals": {
65+
"ts-jest": {
66+
"diagnostics": false
67+
}
68+
}
6369
},
6470
"dependencies": {
6571
"@types/ajv": "^1.0.0",
@@ -74,5 +80,8 @@
7480
"tsconfig-loader": "^1.1.0",
7581
"typescript-json-schema": "^0.38.3",
7682
"yargs": "^13.2.4"
83+
},
84+
"peerDependencies": {
85+
"ajv": "^6.12.0"
7786
}
7887
}

src/DisjointUnionExample.validator.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,21 @@ import {
88
Entity,
99
Value,
1010
} from './DisjointUnionExample';
11+
undefined;
1112
export const ajv = new Ajv({
1213
allErrors: true,
1314
coerceTypes: false,
1415
format: 'fast',
1516
nullable: true,
17+
removeAdditional: false,
1618
unicode: true,
1719
uniqueItems: true,
1820
useDefaults: true,
1921
});
20-
2122
ajv.addMetaSchema(require('ajv/lib/refs/json-schema-draft-06.json'));
2223

2324
export {EntityTypes, EntityOne, EntityTwo, Entity, Value};
24-
export const Schema = {
25+
export const Schema: object = {
2526
$schema: 'http://json-schema.org/draft-07/schema#',
2627
definitions: {
2728
Entity: {

0 commit comments

Comments
 (0)