ejv 2.1.1 → 2.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/.mocharc.json +8 -8
  2. package/CHANGELOG.md +134 -135
  3. package/README-KR.md +597 -597
  4. package/README.md +603 -603
  5. package/build/cjs/constants.js +1 -0
  6. package/build/cjs/constants.js.map +1 -1
  7. package/build/cjs/ejv.js +3 -0
  8. package/build/cjs/ejv.js.map +1 -1
  9. package/build/cjs/tester.js +11 -1
  10. package/build/cjs/tester.js.map +1 -1
  11. package/build/constants.d.ts +1 -0
  12. package/build/esm/constants.js +1 -0
  13. package/build/esm/constants.js.map +1 -1
  14. package/build/esm/ejv.js +4 -1
  15. package/build/esm/ejv.js.map +1 -1
  16. package/build/esm/tester.js +9 -0
  17. package/build/esm/tester.js.map +1 -1
  18. package/build/tester.d.ts +1 -0
  19. package/eslint.config.mjs +66 -59
  20. package/package.json +54 -54
  21. package/scripts/add-js-extensions.ts +59 -59
  22. package/spec/ArrayScheme.ts +1021 -1021
  23. package/spec/CommonScheme.ts +251 -251
  24. package/spec/DateScheme.ts +472 -472
  25. package/spec/NumberScheme.ts +1160 -1160
  26. package/spec/ObjectScheme.ts +499 -499
  27. package/spec/RegExpScheme.ts +112 -112
  28. package/spec/StringScheme.ts +1407 -1336
  29. package/spec/common-test-util.ts +63 -63
  30. package/spec/ejv.spec.ts +235 -235
  31. package/spec/testers.spec.ts +833 -833
  32. package/src/constants.ts +164 -162
  33. package/src/ejv.ts +1751 -1746
  34. package/src/index.ts +14 -14
  35. package/src/interfaces.ts +144 -144
  36. package/src/tester.ts +323 -312
  37. package/src/util.ts +124 -124
  38. package/tsconfig.cjs.json +8 -8
  39. package/tsconfig.esm.json +7 -7
  40. package/tsconfig.json +19 -19
  41. package/tsconfig.scripts.json +14 -14
  42. package/tsconfig.types.json +9 -9
@@ -1,112 +1,112 @@
1
- import { describe, it } from 'mocha';
2
- import { expect } from 'chai';
3
-
4
- import { ejv } from '../src/ejv';
5
-
6
- import { EjvError } from '../src/interfaces';
7
- import { ERROR_MESSAGE, ERROR_TYPE } from '../src/constants';
8
- import { createErrorMsg } from '../src/util';
9
- import { TypeTester, typeTesterArr } from './common-test-util';
10
-
11
-
12
- describe('RegExpScheme', () => {
13
- describe('type', () => {
14
- describe('mismatch', () => {
15
- typeTesterArr
16
- .filter((obj: TypeTester): boolean => obj.type !== 'regexp')
17
- .forEach((obj: TypeTester): void => {
18
- it(obj.type, () => {
19
- const testData = {
20
- a: obj.value
21
- };
22
-
23
- const error: EjvError | null = ejv(testData, [{
24
- key: 'a',
25
- type: 'regexp'
26
- }]);
27
-
28
- expect(error).to.be.instanceof(EjvError);
29
-
30
- if (!error) {
31
- throw new Error('spec failed');
32
- }
33
-
34
- expect(error.type).to.be.eql(ERROR_TYPE.TYPE_MISMATCH);
35
- expect(error.message).to.be.eql(createErrorMsg(ERROR_MESSAGE.TYPE_MISMATCH, {
36
- placeholders: ['regexp']
37
- }));
38
- expect(error.path).to.be.eql('a');
39
- expect(error.data).to.be.deep.equal(testData);
40
- expect(error.errorData).to.be.eql(obj.value);
41
- });
42
- });
43
-
44
- it('multiple types', () => {
45
- const value = 'ejv';
46
- const typeArr: string[] = ['boolean', 'regexp'];
47
-
48
- const testData = {
49
- a: value
50
- };
51
-
52
- const error: EjvError | null = ejv(testData, [{
53
- key: 'a',
54
- type: typeArr
55
- }]);
56
-
57
- expect(error).to.be.instanceof(EjvError);
58
-
59
- if (!error) {
60
- throw new Error('spec failed');
61
- }
62
-
63
- expect(error.type).to.be.eql(ERROR_TYPE.TYPE_MISMATCH_ONE_OF);
64
- expect(error.message).to.be.eql(createErrorMsg(ERROR_MESSAGE.TYPE_MISMATCH_ONE_OF, {
65
- placeholders: [JSON.stringify(typeArr)]
66
- }));
67
- expect(error.path).to.be.eql('a');
68
- expect(error.data).to.be.deep.equal(testData);
69
- expect(error.errorData).to.be.eql(value);
70
- });
71
- });
72
-
73
- describe('match', () => {
74
- it('optional', () => {
75
- expect(ejv({
76
- a: undefined
77
- }, [{
78
- key: 'a',
79
- type: 'regexp',
80
- optional: true
81
- }])).to.be.null;
82
- });
83
-
84
- it('single type', () => {
85
- expect(ejv({
86
- a: /./
87
- }, [{
88
- key: 'a',
89
- type: 'regexp'
90
- }])).to.be.null;
91
- });
92
-
93
- it('multiple types', () => {
94
- expect(ejv({
95
- a: /./
96
- }, [{
97
- key: 'a',
98
- type: ['regexp', 'number']
99
- }])).to.be.null;
100
- });
101
-
102
- it('multiple types', () => {
103
- expect(ejv({
104
- a: /./
105
- }, [{
106
- key: 'a',
107
- type: ['number', 'regexp']
108
- }])).to.be.null;
109
- });
110
- });
111
- });
112
- });
1
+ import { describe, it } from 'mocha';
2
+ import { expect } from 'chai';
3
+
4
+ import { ejv } from '../src/ejv';
5
+
6
+ import { EjvError } from '../src/interfaces';
7
+ import { ERROR_MESSAGE, ERROR_TYPE } from '../src/constants';
8
+ import { createErrorMsg } from '../src/util';
9
+ import { TypeTester, typeTesterArr } from './common-test-util';
10
+
11
+
12
+ describe('RegExpScheme', () => {
13
+ describe('type', () => {
14
+ describe('mismatch', () => {
15
+ typeTesterArr
16
+ .filter((obj: TypeTester): boolean => obj.type !== 'regexp')
17
+ .forEach((obj: TypeTester): void => {
18
+ it(obj.type, () => {
19
+ const testData = {
20
+ a: obj.value
21
+ };
22
+
23
+ const error: EjvError | null = ejv(testData, [{
24
+ key: 'a',
25
+ type: 'regexp'
26
+ }]);
27
+
28
+ expect(error).to.be.instanceof(EjvError);
29
+
30
+ if (!error) {
31
+ throw new Error('spec failed');
32
+ }
33
+
34
+ expect(error.type).to.be.eql(ERROR_TYPE.TYPE_MISMATCH);
35
+ expect(error.message).to.be.eql(createErrorMsg(ERROR_MESSAGE.TYPE_MISMATCH, {
36
+ placeholders: ['regexp']
37
+ }));
38
+ expect(error.path).to.be.eql('a');
39
+ expect(error.data).to.be.deep.equal(testData);
40
+ expect(error.errorData).to.be.eql(obj.value);
41
+ });
42
+ });
43
+
44
+ it('multiple types', () => {
45
+ const value = 'ejv';
46
+ const typeArr: string[] = ['boolean', 'regexp'];
47
+
48
+ const testData = {
49
+ a: value
50
+ };
51
+
52
+ const error: EjvError | null = ejv(testData, [{
53
+ key: 'a',
54
+ type: typeArr
55
+ }]);
56
+
57
+ expect(error).to.be.instanceof(EjvError);
58
+
59
+ if (!error) {
60
+ throw new Error('spec failed');
61
+ }
62
+
63
+ expect(error.type).to.be.eql(ERROR_TYPE.TYPE_MISMATCH_ONE_OF);
64
+ expect(error.message).to.be.eql(createErrorMsg(ERROR_MESSAGE.TYPE_MISMATCH_ONE_OF, {
65
+ placeholders: [JSON.stringify(typeArr)]
66
+ }));
67
+ expect(error.path).to.be.eql('a');
68
+ expect(error.data).to.be.deep.equal(testData);
69
+ expect(error.errorData).to.be.eql(value);
70
+ });
71
+ });
72
+
73
+ describe('match', () => {
74
+ it('optional', () => {
75
+ expect(ejv({
76
+ a: undefined
77
+ }, [{
78
+ key: 'a',
79
+ type: 'regexp',
80
+ optional: true
81
+ }])).to.be.null;
82
+ });
83
+
84
+ it('single type', () => {
85
+ expect(ejv({
86
+ a: /./
87
+ }, [{
88
+ key: 'a',
89
+ type: 'regexp'
90
+ }])).to.be.null;
91
+ });
92
+
93
+ it('multiple types', () => {
94
+ expect(ejv({
95
+ a: /./
96
+ }, [{
97
+ key: 'a',
98
+ type: ['regexp', 'number']
99
+ }])).to.be.null;
100
+ });
101
+
102
+ it('multiple types', () => {
103
+ expect(ejv({
104
+ a: /./
105
+ }, [{
106
+ key: 'a',
107
+ type: ['number', 'regexp']
108
+ }])).to.be.null;
109
+ });
110
+ });
111
+ });
112
+ });