@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 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.20230829102031
5
- Generated: Tue, 29 Aug 2023 10:20:47 GMT
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.20230829102031
5
- Generated: Tue, 29 Aug 2023 10:20:47 GMT
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
 
@@ -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.20230829102031
5
- Generated: Tue, 29 Aug 2023 10:20:47 GMT
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.20230829102031",
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",
@@ -1,78 +1,86 @@
1
1
  import { createHeadlessForm } from '../createHeadlessForm';
2
2
 
3
- it('Should work for number', () => {
4
- const { handleValidation } = createHeadlessForm(
5
- {
6
- properties: {
7
- ten_only: { type: 'number', const: 10 },
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
- { strictInputType: false }
11
- );
12
- expect(handleValidation({}).formErrors).toEqual(undefined);
13
- expect(handleValidation({ ten_only: 1 }).formErrors).toEqual({
14
- ten_only: 'The only accepted value is 10.',
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
- const { handleValidation } = createHeadlessForm(
21
- {
22
- properties: {
23
- hello_only: { type: 'string', const: 'hello' },
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
- { strictInputType: false }
27
- );
28
- expect(handleValidation({}).formErrors).toEqual(undefined);
29
- expect(handleValidation({ hello_only: 'what' }).formErrors).toEqual({
30
- hello_only: 'The only accepted value is hello.',
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
- const { handleValidation } = createHeadlessForm(
37
- {
38
- properties: {
39
- answer: { type: 'string', oneOf: [{ const: 'yes' }, { const: 'no' }] },
40
- amount: { description: 'If you select yes, this needs to be exactly 10.', type: 'number' },
41
- },
42
- allOf: [
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
- { strictInputType: false }
50
- );
51
- expect(handleValidation({}).formErrors).toEqual(undefined);
52
- expect(handleValidation({ answer: 'no' }).formErrors).toEqual(undefined);
53
- expect(handleValidation({ answer: 'yes' }).formErrors).toEqual({ amount: 'Required field' });
54
- expect(handleValidation({ answer: 'yes', amount: 1 }).formErrors).toEqual({
55
- amount: 'The only accepted value is 10.',
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
- const { handleValidation } = createHeadlessForm(
62
- {
63
- properties: {
64
- string: {
65
- type: 'string',
66
- const: 'hello',
67
- 'x-jsf-errorMessage': { const: 'You must say hello!!!' },
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
- { strictInputType: false }
72
- );
73
- expect(handleValidation({}).formErrors).toEqual(undefined);
74
- expect(handleValidation({ string: 'hi' }).formErrors).toEqual({
75
- string: 'You must say hello!!!',
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
  });
@@ -207,7 +207,6 @@ export const schemaInputTypeHidden = {
207
207
  title: 'Select multi hidden',
208
208
  default: ['Albania, Algeria'],
209
209
  'x-jsf-presentation': { inputType: 'hidden' },
210
- const: ['Albania, Algeria'],
211
210
  type: 'array',
212
211
  },
213
212
  },