@remoteoss/json-schema-form 0.4.4-dev.20230829102031 → 0.4.4-dev.20230829191632
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.
- package/dist/index.cjs +2 -2
- package/dist/index.js +2 -2
- package/dist/standalone.js +2 -2
- package/package.json +1 -1
- package/src/tests/const.test.js +71 -63
- package/src/tests/helpers.custom.js +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
|
|
2
2
|
/*!
|
|
3
3
|
Copyright (c) 2023 Remote Technology, Inc.
|
|
4
|
-
NPM Package: @remoteoss/json-schema-form@0.4.4-dev.
|
|
5
|
-
Generated: Tue, 29 Aug 2023
|
|
4
|
+
NPM Package: @remoteoss/json-schema-form@0.4.4-dev.20230829191632
|
|
5
|
+
Generated: Tue, 29 Aug 2023 19:17:06 GMT
|
|
6
6
|
|
|
7
7
|
MIT License
|
|
8
8
|
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
|
|
2
2
|
/*!
|
|
3
3
|
Copyright (c) 2023 Remote Technology, Inc.
|
|
4
|
-
NPM Package: @remoteoss/json-schema-form@0.4.4-dev.
|
|
5
|
-
Generated: Tue, 29 Aug 2023
|
|
4
|
+
NPM Package: @remoteoss/json-schema-form@0.4.4-dev.20230829191632
|
|
5
|
+
Generated: Tue, 29 Aug 2023 19:17:06 GMT
|
|
6
6
|
|
|
7
7
|
MIT License
|
|
8
8
|
|
package/dist/standalone.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
|
|
2
2
|
/*!
|
|
3
3
|
Copyright (c) 2023 Remote Technology, Inc.
|
|
4
|
-
NPM Package: @remoteoss/json-schema-form@0.4.4-dev.
|
|
5
|
-
Generated: Tue, 29 Aug 2023
|
|
4
|
+
NPM Package: @remoteoss/json-schema-form@0.4.4-dev.20230829191632
|
|
5
|
+
Generated: Tue, 29 Aug 2023 19:17:06 GMT
|
|
6
6
|
|
|
7
7
|
MIT License
|
|
8
8
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remoteoss/json-schema-form",
|
|
3
|
-
"version": "0.4.4-dev.
|
|
3
|
+
"version": "0.4.4-dev.20230829191632",
|
|
4
4
|
"description": "Headless UI form powered by JSON Schemas",
|
|
5
5
|
"author": "Remote.com <engineering@remote.com> (https://remote.com/)",
|
|
6
6
|
"license": "MIT",
|
package/src/tests/const.test.js
CHANGED
|
@@ -1,78 +1,86 @@
|
|
|
1
1
|
import { createHeadlessForm } from '../createHeadlessForm';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
{
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
describe('validations: const', () => {
|
|
4
|
+
it('Should work for number', () => {
|
|
5
|
+
const { handleValidation } = createHeadlessForm(
|
|
6
|
+
{
|
|
7
|
+
properties: {
|
|
8
|
+
ten_only: { type: 'number', const: 10 },
|
|
9
|
+
},
|
|
8
10
|
},
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
{ strictInputType: false }
|
|
12
|
+
);
|
|
13
|
+
expect(handleValidation({}).formErrors).toEqual(undefined);
|
|
14
|
+
expect(handleValidation({ ten_only: 1 }).formErrors).toEqual({
|
|
15
|
+
ten_only: 'The only accepted value is 10.',
|
|
16
|
+
});
|
|
17
|
+
expect(handleValidation({ ten_only: 10 }).formErrors).toBeUndefined();
|
|
18
|
+
// null is also considered valid until we fix @BUG RMT-518
|
|
19
|
+
// Expectation: To fail with error "The only accepted value is 10."
|
|
20
|
+
expect(handleValidation({ ten_only: null }).formErrors).toBeUndefined();
|
|
15
21
|
});
|
|
16
|
-
expect(handleValidation({ ten_only: 10 }).formErrors).toEqual(undefined);
|
|
17
|
-
});
|
|
18
22
|
|
|
19
|
-
it('Should work for text', () => {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
it('Should work for text', () => {
|
|
24
|
+
const { handleValidation } = createHeadlessForm(
|
|
25
|
+
{
|
|
26
|
+
properties: {
|
|
27
|
+
hello_only: { type: 'string', const: 'hello' },
|
|
28
|
+
},
|
|
24
29
|
},
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
30
|
+
{ strictInputType: false }
|
|
31
|
+
);
|
|
32
|
+
expect(handleValidation({}).formErrors).toEqual(undefined);
|
|
33
|
+
expect(handleValidation({ hello_only: 'what' }).formErrors).toEqual({
|
|
34
|
+
hello_only: 'The only accepted value is hello.',
|
|
35
|
+
});
|
|
36
|
+
expect(handleValidation({ hello_only: 'hello' }).formErrors).toEqual(undefined);
|
|
31
37
|
});
|
|
32
|
-
expect(handleValidation({ hello_only: 'hello' }).formErrors).toEqual(undefined);
|
|
33
|
-
});
|
|
34
38
|
|
|
35
|
-
it('Should work for a conditionally applied const', () => {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
if: { properties: { answer: { const: 'yes' } }, required: ['answer'] },
|
|
45
|
-
then: { properties: { amount: { const: 10 } }, required: ['amount'] },
|
|
39
|
+
it('Should work for a conditionally applied const', () => {
|
|
40
|
+
const { handleValidation } = createHeadlessForm(
|
|
41
|
+
{
|
|
42
|
+
properties: {
|
|
43
|
+
answer: { type: 'string', oneOf: [{ const: 'yes' }, { const: 'no' }] },
|
|
44
|
+
amount: {
|
|
45
|
+
description: 'If you select yes, this needs to be exactly 10.',
|
|
46
|
+
type: 'number',
|
|
47
|
+
},
|
|
46
48
|
},
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
49
|
+
allOf: [
|
|
50
|
+
{
|
|
51
|
+
if: { properties: { answer: { const: 'yes' } }, required: ['answer'] },
|
|
52
|
+
then: { properties: { amount: { const: 10 } }, required: ['amount'] },
|
|
53
|
+
},
|
|
54
|
+
],
|
|
55
|
+
},
|
|
56
|
+
{ strictInputType: false }
|
|
57
|
+
);
|
|
58
|
+
expect(handleValidation({}).formErrors).toEqual(undefined);
|
|
59
|
+
expect(handleValidation({ answer: 'no' }).formErrors).toEqual(undefined);
|
|
60
|
+
expect(handleValidation({ answer: 'yes' }).formErrors).toEqual({ amount: 'Required field' });
|
|
61
|
+
expect(handleValidation({ answer: 'yes', amount: 1 }).formErrors).toEqual({
|
|
62
|
+
amount: 'The only accepted value is 10.',
|
|
63
|
+
});
|
|
64
|
+
expect(handleValidation({ answer: 'yes', amount: 10 }).formErrors).toEqual(undefined);
|
|
56
65
|
});
|
|
57
|
-
expect(handleValidation({ answer: 'yes', amount: 10 }).formErrors).toEqual(undefined);
|
|
58
|
-
});
|
|
59
66
|
|
|
60
|
-
it('Should show the custom error message', () => {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
67
|
+
it('Should show the custom error message', () => {
|
|
68
|
+
const { handleValidation } = createHeadlessForm(
|
|
69
|
+
{
|
|
70
|
+
properties: {
|
|
71
|
+
string: {
|
|
72
|
+
type: 'string',
|
|
73
|
+
const: 'hello',
|
|
74
|
+
'x-jsf-errorMessage': { const: 'You must say hello!!!' },
|
|
75
|
+
},
|
|
68
76
|
},
|
|
69
77
|
},
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
78
|
+
{ strictInputType: false }
|
|
79
|
+
);
|
|
80
|
+
expect(handleValidation({}).formErrors).toEqual(undefined);
|
|
81
|
+
expect(handleValidation({ string: 'hi' }).formErrors).toEqual({
|
|
82
|
+
string: 'You must say hello!!!',
|
|
83
|
+
});
|
|
84
|
+
expect(handleValidation({ string: 'hello' }).formErrors).toEqual(undefined);
|
|
76
85
|
});
|
|
77
|
-
expect(handleValidation({ string: 'hello' }).formErrors).toEqual(undefined);
|
|
78
86
|
});
|