@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 +15 -7
- package/dist/index.js +15 -7
- package/dist/standalone.js +15 -7
- package/package.json +1 -1
- package/src/tests/createHeadlessForm.test.js +8 -5
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.
|
|
5
|
-
Generated:
|
|
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 = [
|
|
425
|
+
const optionsBroken = [
|
|
426
|
+
...onlyValues,
|
|
427
|
+
""
|
|
428
|
+
// [1]
|
|
429
|
+
];
|
|
426
430
|
if (field.required) {
|
|
427
|
-
return
|
|
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"
|
|
430
|
-
// but we don't have direct access at this point.
|
|
431
|
-
// the JSON Schema validator will fail
|
|
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.
|
|
5
|
-
Generated:
|
|
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 = [
|
|
389
|
+
const optionsBroken = [
|
|
390
|
+
...onlyValues,
|
|
391
|
+
""
|
|
392
|
+
// [1]
|
|
393
|
+
];
|
|
390
394
|
if (field.required) {
|
|
391
|
-
return
|
|
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"
|
|
394
|
-
// but we don't have direct access at this point.
|
|
395
|
-
// the JSON Schema validator will fail
|
|
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];
|
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.1-dev.
|
|
5
|
-
Generated:
|
|
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 = [
|
|
11365
|
+
const optionsBroken = [
|
|
11366
|
+
...onlyValues,
|
|
11367
|
+
""
|
|
11368
|
+
// [1]
|
|
11369
|
+
];
|
|
11366
11370
|
if (field.required) {
|
|
11367
|
-
return
|
|
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"
|
|
11370
|
-
// but we don't have direct access at this point.
|
|
11371
|
-
// the JSON Schema validator will fail
|
|
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.
|
|
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
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
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
|
}
|