@remoteoss/json-schema-form 0.11.3-dev.20240816092154 → 0.11.3-dev.20240819123216

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) 2024 Remote Technology, Inc.
4
- NPM Package: @remoteoss/json-schema-form@0.11.3-dev.20240816092154
5
- Generated: Fri, 16 Aug 2024 09:22:10 GMT
4
+ NPM Package: @remoteoss/json-schema-form@0.11.3-dev.20240819123216
5
+ Generated: Mon, 19 Aug 2024 12:32:44 GMT
6
6
 
7
7
  MIT License
8
8
 
@@ -534,13 +534,13 @@ var yupSchemas = {
534
534
  return value === null ? void 0 : value;
535
535
  }).test(
536
536
  "matchesOptionOrPattern",
537
- ({ value }) => {
538
- return `The option ${JSON.stringify(value)} is not valid.`;
537
+ ({ originalValue }) => {
538
+ return `The option ${JSON.stringify(originalValue)} is not valid.`;
539
539
  },
540
- (value) => {
541
- if (value !== void 0 && typeof value !== "boolean")
540
+ (castValue, { originalValue }) => {
541
+ if (typeof originalValue !== "boolean" && castValue !== void 0)
542
542
  return false;
543
- return validateRadioOrSelectOptions(value, options);
543
+ return validateRadioOrSelectOptions(castValue, options);
544
544
  }
545
545
  );
546
546
  },
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.3-dev.20240816092154
5
- Generated: Fri, 16 Aug 2024 09:22:10 GMT
4
+ NPM Package: @remoteoss/json-schema-form@0.11.3-dev.20240819123216
5
+ Generated: Mon, 19 Aug 2024 12:32:44 GMT
6
6
 
7
7
  MIT License
8
8
 
@@ -497,13 +497,13 @@ var yupSchemas = {
497
497
  return value === null ? void 0 : value;
498
498
  }).test(
499
499
  "matchesOptionOrPattern",
500
- ({ value }) => {
501
- return `The option ${JSON.stringify(value)} is not valid.`;
500
+ ({ originalValue }) => {
501
+ return `The option ${JSON.stringify(originalValue)} is not valid.`;
502
502
  },
503
- (value) => {
504
- if (value !== void 0 && typeof value !== "boolean")
503
+ (castValue, { originalValue }) => {
504
+ if (typeof originalValue !== "boolean" && castValue !== void 0)
505
505
  return false;
506
- return validateRadioOrSelectOptions(value, options);
506
+ return validateRadioOrSelectOptions(castValue, options);
507
507
  }
508
508
  );
509
509
  },
@@ -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.3-dev.20240816092154
5
- Generated: Fri, 16 Aug 2024 09:22:10 GMT
4
+ NPM Package: @remoteoss/json-schema-form@0.11.3-dev.20240819123216
5
+ Generated: Mon, 19 Aug 2024 12:32:44 GMT
6
6
 
7
7
  MIT License
8
8
 
@@ -12013,13 +12013,13 @@ var yupSchemas = {
12013
12013
  return value === null ? void 0 : value;
12014
12014
  }).test(
12015
12015
  "matchesOptionOrPattern",
12016
- ({ value }) => {
12017
- return `The option ${JSON.stringify(value)} is not valid.`;
12016
+ ({ originalValue }) => {
12017
+ return `The option ${JSON.stringify(originalValue)} is not valid.`;
12018
12018
  },
12019
- (value) => {
12020
- if (value !== void 0 && typeof value !== "boolean")
12019
+ (castValue, { originalValue }) => {
12020
+ if (typeof originalValue !== "boolean" && castValue !== void 0)
12021
12021
  return false;
12022
- return validateRadioOrSelectOptions(value, options);
12022
+ return validateRadioOrSelectOptions(castValue, options);
12023
12023
  }
12024
12024
  );
12025
12025
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remoteoss/json-schema-form",
3
- "version": "0.11.3-dev.20240816092154",
3
+ "version": "0.11.3-dev.20240819123216",
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",
@@ -783,6 +783,8 @@ describe('createHeadlessForm', () => {
783
783
  it('support "radio" field boolean type', () => {
784
784
  const { fields, handleValidation } = createHeadlessForm(schemaInputTypeRadioBoolean);
785
785
 
786
+ const validateForm = (vals) => friendlyError(handleValidation(vals));
787
+
786
788
  expect(fields).toMatchObject([
787
789
  {
788
790
  description: 'Are you over 18 years old?',
@@ -808,13 +810,19 @@ describe('createHeadlessForm', () => {
808
810
  handleValidation,
809
811
  fieldName: 'over_18',
810
812
  validOptions: [true, false],
811
- type: 'boolean',
813
+ type: schemaInputTypeRadioBoolean.properties.over_18.type,
814
+ });
815
+
816
+ expect(validateForm({ over_18: 'true' })).toEqual({
817
+ over_18: 'The option "true" is not valid.',
812
818
  });
813
819
  });
814
820
 
815
821
  it('support "radio" field number type', () => {
816
822
  const { fields, handleValidation } = createHeadlessForm(schemaInputTypeRadioNumber);
817
823
 
824
+ const validateForm = (vals) => friendlyError(handleValidation(vals));
825
+
818
826
  expect(fields).toMatchObject([
819
827
  {
820
828
  description: 'How many siblings do you have?',
@@ -845,6 +853,11 @@ describe('createHeadlessForm', () => {
845
853
  fieldName: 'siblings_count',
846
854
  validOptions: [1, 2, 3],
847
855
  type: 'number',
856
+ type: schemaInputTypeRadioBoolean.properties.siblings_count.type,
857
+ });
858
+
859
+ expect(validateForm({ siblings_count: '3' })).toEqual({
860
+ siblings_count: 'The option "3" is not valid.',
848
861
  });
849
862
  });
850
863