@remoteoss/json-schema-form 0.11.6-beta.0 → 0.11.7-beta.0
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/CHANGELOG.md +6 -0
- package/dist/index.cjs +8 -3
- package/dist/index.js +8 -3
- package/dist/standalone.js +8 -3
- package/package.json +1 -1
- package/src/tests/createHeadlessForm.test.js +40 -0
- package/src/tests/helpers.js +26 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
#### 0.11.7-beta.0 (2024-11-14)
|
|
2
|
+
|
|
3
|
+
##### Bug Fixes
|
|
4
|
+
|
|
5
|
+
* **validation:** validate radio with string-y types; ([#94](https://github.com/remoteoss/json-schema-form/pull/94)) ([606913d8](https://github.com/remoteoss/json-schema-form/commit/606913d8412a02d9a38a43e903add58b8e11a7e4))
|
|
6
|
+
|
|
1
7
|
#### 0.11.6-beta.0 (2024-10-15)
|
|
2
8
|
|
|
3
9
|
##### Bug Fixes
|
package/dist/index.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
|
|
2
2
|
/*!
|
|
3
3
|
Copyright (c) 2024 Remote Technology, Inc.
|
|
4
|
-
NPM Package: @remoteoss/json-schema-form@0.11.
|
|
5
|
-
Generated:
|
|
4
|
+
NPM Package: @remoteoss/json-schema-form@0.11.7-beta.0
|
|
5
|
+
Generated: Thu, 14 Nov 2024 17:43:01 GMT
|
|
6
6
|
|
|
7
7
|
MIT License
|
|
8
8
|
|
|
@@ -481,7 +481,12 @@ var yupSchemas = {
|
|
|
481
481
|
}).test(
|
|
482
482
|
"matchesOptionOrPattern",
|
|
483
483
|
({ value }) => `The option ${JSON.stringify(value)} is not valid.`,
|
|
484
|
-
(
|
|
484
|
+
(castValue, { originalValue }) => {
|
|
485
|
+
if (castValue !== void 0 && typeof originalValue !== "string") {
|
|
486
|
+
return false;
|
|
487
|
+
}
|
|
488
|
+
return validateRadioOrSelectOptions(castValue, options);
|
|
489
|
+
}
|
|
485
490
|
);
|
|
486
491
|
},
|
|
487
492
|
date: ({ minDate, maxDate }) => {
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
|
|
2
2
|
/*!
|
|
3
3
|
Copyright (c) 2024 Remote Technology, Inc.
|
|
4
|
-
NPM Package: @remoteoss/json-schema-form@0.11.
|
|
5
|
-
Generated:
|
|
4
|
+
NPM Package: @remoteoss/json-schema-form@0.11.7-beta.0
|
|
5
|
+
Generated: Thu, 14 Nov 2024 17:43:01 GMT
|
|
6
6
|
|
|
7
7
|
MIT License
|
|
8
8
|
|
|
@@ -444,7 +444,12 @@ var yupSchemas = {
|
|
|
444
444
|
}).test(
|
|
445
445
|
"matchesOptionOrPattern",
|
|
446
446
|
({ value }) => `The option ${JSON.stringify(value)} is not valid.`,
|
|
447
|
-
(
|
|
447
|
+
(castValue, { originalValue }) => {
|
|
448
|
+
if (castValue !== void 0 && typeof originalValue !== "string") {
|
|
449
|
+
return false;
|
|
450
|
+
}
|
|
451
|
+
return validateRadioOrSelectOptions(castValue, options);
|
|
452
|
+
}
|
|
448
453
|
);
|
|
449
454
|
},
|
|
450
455
|
date: ({ minDate, maxDate }) => {
|
package/dist/standalone.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
|
|
2
2
|
/*!
|
|
3
3
|
Copyright (c) 2024 Remote Technology, Inc.
|
|
4
|
-
NPM Package: @remoteoss/json-schema-form@0.11.
|
|
5
|
-
Generated:
|
|
4
|
+
NPM Package: @remoteoss/json-schema-form@0.11.7-beta.0
|
|
5
|
+
Generated: Thu, 14 Nov 2024 17:43:01 GMT
|
|
6
6
|
|
|
7
7
|
MIT License
|
|
8
8
|
|
|
@@ -11960,7 +11960,12 @@ var yupSchemas = {
|
|
|
11960
11960
|
}).test(
|
|
11961
11961
|
"matchesOptionOrPattern",
|
|
11962
11962
|
({ value }) => `The option ${JSON.stringify(value)} is not valid.`,
|
|
11963
|
-
(
|
|
11963
|
+
(castValue, { originalValue }) => {
|
|
11964
|
+
if (castValue !== void 0 && typeof originalValue !== "string") {
|
|
11965
|
+
return false;
|
|
11966
|
+
}
|
|
11967
|
+
return validateRadioOrSelectOptions(castValue, options);
|
|
11968
|
+
}
|
|
11964
11969
|
);
|
|
11965
11970
|
},
|
|
11966
11971
|
date: ({ minDate, maxDate }) => {
|
package/package.json
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
schemaInputTypeText,
|
|
10
10
|
schemaInputTypeRadioDeprecated,
|
|
11
11
|
schemaInputTypeRadioString,
|
|
12
|
+
schemaInputTypeRadioStringY,
|
|
12
13
|
schemaInputTypeRadioBoolean,
|
|
13
14
|
schemaInputTypeRadioNumber,
|
|
14
15
|
schemaInputTypeRadioRequiredAndOptional,
|
|
@@ -820,6 +821,45 @@ describe('createHeadlessForm', () => {
|
|
|
820
821
|
});
|
|
821
822
|
});
|
|
822
823
|
|
|
824
|
+
// @BUG COD-1859
|
|
825
|
+
// it should validate when type is string but value is not a boolean
|
|
826
|
+
it('support "radio" field string-y type', () => {
|
|
827
|
+
const { fields, handleValidation } = createHeadlessForm(schemaInputTypeRadioStringY);
|
|
828
|
+
|
|
829
|
+
const validateForm = (vals) => friendlyError(handleValidation(vals));
|
|
830
|
+
|
|
831
|
+
expect(fields).toMatchObject([
|
|
832
|
+
{
|
|
833
|
+
description: 'Do you have any siblings?',
|
|
834
|
+
label: 'Has siblings',
|
|
835
|
+
name: 'has_siblings',
|
|
836
|
+
options: [
|
|
837
|
+
{
|
|
838
|
+
label: 'Yes',
|
|
839
|
+
value: 'true',
|
|
840
|
+
},
|
|
841
|
+
{
|
|
842
|
+
label: 'No',
|
|
843
|
+
value: 'false',
|
|
844
|
+
},
|
|
845
|
+
],
|
|
846
|
+
required: true,
|
|
847
|
+
schema: expect.any(Object),
|
|
848
|
+
type: 'radio',
|
|
849
|
+
},
|
|
850
|
+
]);
|
|
851
|
+
|
|
852
|
+
assertOptionsAllowed({
|
|
853
|
+
handleValidation,
|
|
854
|
+
fieldName: 'has_siblings',
|
|
855
|
+
validOptions: ['true', 'false'],
|
|
856
|
+
});
|
|
857
|
+
|
|
858
|
+
expect(validateForm({ has_siblings: false })).toEqual({
|
|
859
|
+
has_siblings: 'The option "false" is not valid.',
|
|
860
|
+
});
|
|
861
|
+
});
|
|
862
|
+
|
|
823
863
|
it('support "radio" field number type', () => {
|
|
824
864
|
const { fields, handleValidation } = createHeadlessForm(schemaInputTypeRadioNumber);
|
|
825
865
|
|
package/src/tests/helpers.js
CHANGED
|
@@ -148,6 +148,25 @@ export const mockRadioInputBoolean = {
|
|
|
148
148
|
type: 'boolean',
|
|
149
149
|
};
|
|
150
150
|
|
|
151
|
+
export const mockRadioInputStringY = {
|
|
152
|
+
title: 'Has siblings',
|
|
153
|
+
description: 'Do you have any siblings?',
|
|
154
|
+
oneOf: [
|
|
155
|
+
{
|
|
156
|
+
title: 'Yes',
|
|
157
|
+
const: 'true',
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
title: 'No',
|
|
161
|
+
const: 'false',
|
|
162
|
+
},
|
|
163
|
+
],
|
|
164
|
+
'x-jsf-presentation': {
|
|
165
|
+
inputType: 'radio',
|
|
166
|
+
},
|
|
167
|
+
type: 'string',
|
|
168
|
+
};
|
|
169
|
+
|
|
151
170
|
export const mockRadioInputNumber = {
|
|
152
171
|
title: 'Number of siblings',
|
|
153
172
|
description: 'How many siblings do you have?',
|
|
@@ -899,6 +918,13 @@ export const schemaInputTypeRadioString = {
|
|
|
899
918
|
required: ['has_siblings'],
|
|
900
919
|
};
|
|
901
920
|
|
|
921
|
+
export const schemaInputTypeRadioStringY = {
|
|
922
|
+
properties: {
|
|
923
|
+
has_siblings: mockRadioInputStringY,
|
|
924
|
+
},
|
|
925
|
+
required: ['has_siblings'],
|
|
926
|
+
};
|
|
927
|
+
|
|
902
928
|
export const schemaInputTypeRadioBoolean = {
|
|
903
929
|
properties: {
|
|
904
930
|
over_18: mockRadioInputBoolean,
|