@remoteoss/json-schema-form 0.4.1-dev.20230702181843 → 0.4.1-dev.20230703082439

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.1-dev.20230702181843
5
- Generated: Sun, 02 Jul 2023 18:19:05 GMT
4
+ NPM Package: @remoteoss/json-schema-form@0.4.1-dev.20230703082439
5
+ Generated: Mon, 03 Jul 2023 08:24:57 GMT
6
6
 
7
7
  MIT License
8
8
 
@@ -422,13 +422,21 @@ function getRequiredErrorMessage(inputType, { inlineError, configError }) {
422
422
  var getJsonTypeInArray = (jsonType) => Array.isArray(jsonType) ? jsonType.find((val) => val !== "null") : jsonType;
423
423
  var getOptionsAllowed = (field) => {
424
424
  const onlyValues = field.options?.map((option) => option.value);
425
- const optionsBroken = [...onlyValues, ""];
425
+ const optionsBroken = [
426
+ ...onlyValues,
427
+ ""
428
+ // [1]
429
+ ];
426
430
  if (field.required) {
427
- return optionsBroken;
431
+ return [
432
+ ...optionsBroken,
433
+ null
434
+ // [2]
435
+ ];
428
436
  }
429
- const isOptionalWithNull = Array.isArray(field.jsonType) && // @TODO should also check the "oneOf" directly looking for "null" option
430
- // but we don't have direct access at this point. Otherwise
431
- // the JSON Schema validator will fail because setting jsonType is not enough.
437
+ const isOptionalWithNull = Array.isArray(field.jsonType) && // @TODO should also check the "oneOf" directly looking for "null"
438
+ // option but we don't have direct access at this point.
439
+ // Otherwise the JSON Schema validator will fail as explained in PR#18
432
440
  field.jsonType.includes("null");
433
441
  if (isOptionalWithNull) {
434
442
  return [...optionsBroken, null];
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.1-dev.20230702181843
5
- Generated: Sun, 02 Jul 2023 18:19:05 GMT
4
+ NPM Package: @remoteoss/json-schema-form@0.4.1-dev.20230703082439
5
+ Generated: Mon, 03 Jul 2023 08:24:57 GMT
6
6
 
7
7
  MIT License
8
8
 
@@ -386,13 +386,21 @@ function getRequiredErrorMessage(inputType, { inlineError, configError }) {
386
386
  var getJsonTypeInArray = (jsonType) => Array.isArray(jsonType) ? jsonType.find((val) => val !== "null") : jsonType;
387
387
  var getOptionsAllowed = (field) => {
388
388
  const onlyValues = field.options?.map((option) => option.value);
389
- const optionsBroken = [...onlyValues, ""];
389
+ const optionsBroken = [
390
+ ...onlyValues,
391
+ ""
392
+ // [1]
393
+ ];
390
394
  if (field.required) {
391
- return optionsBroken;
395
+ return [
396
+ ...optionsBroken,
397
+ null
398
+ // [2]
399
+ ];
392
400
  }
393
- const isOptionalWithNull = Array.isArray(field.jsonType) && // @TODO should also check the "oneOf" directly looking for "null" option
394
- // but we don't have direct access at this point. Otherwise
395
- // the JSON Schema validator will fail because setting jsonType is not enough.
401
+ const isOptionalWithNull = Array.isArray(field.jsonType) && // @TODO should also check the "oneOf" directly looking for "null"
402
+ // option but we don't have direct access at this point.
403
+ // Otherwise the JSON Schema validator will fail as explained in PR#18
396
404
  field.jsonType.includes("null");
397
405
  if (isOptionalWithNull) {
398
406
  return [...optionsBroken, null];
@@ -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.1-dev.20230702181843
5
- Generated: Sun, 02 Jul 2023 18:19:05 GMT
4
+ NPM Package: @remoteoss/json-schema-form@0.4.1-dev.20230703082439
5
+ Generated: Mon, 03 Jul 2023 08:24:57 GMT
6
6
 
7
7
  MIT License
8
8
 
@@ -11362,13 +11362,21 @@ function getRequiredErrorMessage(inputType, { inlineError, configError }) {
11362
11362
  var getJsonTypeInArray = (jsonType) => Array.isArray(jsonType) ? jsonType.find((val) => val !== "null") : jsonType;
11363
11363
  var getOptionsAllowed = (field) => {
11364
11364
  const onlyValues = field.options?.map((option) => option.value);
11365
- const optionsBroken = [...onlyValues, ""];
11365
+ const optionsBroken = [
11366
+ ...onlyValues,
11367
+ ""
11368
+ // [1]
11369
+ ];
11366
11370
  if (field.required) {
11367
- return optionsBroken;
11371
+ return [
11372
+ ...optionsBroken,
11373
+ null
11374
+ // [2]
11375
+ ];
11368
11376
  }
11369
- const isOptionalWithNull = Array.isArray(field.jsonType) && // @TODO should also check the "oneOf" directly looking for "null" option
11370
- // but we don't have direct access at this point. Otherwise
11371
- // the JSON Schema validator will fail because setting jsonType is not enough.
11377
+ const isOptionalWithNull = Array.isArray(field.jsonType) && // @TODO should also check the "oneOf" directly looking for "null"
11378
+ // option but we don't have direct access at this point.
11379
+ // Otherwise the JSON Schema validator will fail as explained in PR#18
11372
11380
  field.jsonType.includes("null");
11373
11381
  if (isOptionalWithNull) {
11374
11382
  return [...optionsBroken, null];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remoteoss/json-schema-form",
3
- "version": "0.4.1-dev.20230702181843",
3
+ "version": "0.4.1-dev.20230703082439",
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",
@@ -461,11 +461,14 @@ describe('createHeadlessForm', () => {
461
461
  });
462
462
 
463
463
  // As required field, empty string ("") is also considered empty. @BUG RMT-518
464
- expect(
465
- validateForm({
466
- [fieldName]: '',
467
- })
468
- ).toEqual({
464
+ // Expectation: The error to be "The option '' is not valid."
465
+ expect(validateForm({ [fieldName]: '' })).toEqual({
466
+ [fieldName]: 'Required field',
467
+ });
468
+
469
+ // As required field, null is also considered empty @BUG RMT-518
470
+ // Expectation: The error to be "The option null is not valid."
471
+ expect(validateForm({ [fieldName]: null })).toEqual({
469
472
  [fieldName]: 'Required field',
470
473
  });
471
474
  }