@remoteoss/json-schema-form 0.1.1-dev.20230613092121 → 0.1.1-dev.20230614173637
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 +6 -11
- package/dist/index.js +6 -11
- package/dist/standalone.js +6 -11
- package/package.json +1 -1
- package/src/tests/createHeadlessForm.test.js +10 -8
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.1.1-dev.
|
|
5
|
-
Generated:
|
|
4
|
+
NPM Package: @remoteoss/json-schema-form@0.1.1-dev.20230614173637
|
|
5
|
+
Generated: Wed, 14 Jun 2023 17:37:05 GMT
|
|
6
6
|
|
|
7
7
|
MIT License
|
|
8
8
|
|
|
@@ -371,14 +371,8 @@ var baseString = (0, import_yup.string)().trim();
|
|
|
371
371
|
var todayDateHint = (/* @__PURE__ */ new Date()).toISOString().substring(0, 10);
|
|
372
372
|
var convertBytesToKB = convertDiskSizeFromTo("Bytes", "KB");
|
|
373
373
|
var convertKbBytesToMB = convertDiskSizeFromTo("KB", "MB");
|
|
374
|
-
var useOnlyStrings = (value, originalValue) => {
|
|
375
|
-
if (typeof originalValue === "string") {
|
|
376
|
-
return originalValue;
|
|
377
|
-
}
|
|
378
|
-
return null;
|
|
379
|
-
};
|
|
380
374
|
var yupSchemas = {
|
|
381
|
-
text: (0, import_yup.string)().
|
|
375
|
+
text: (0, import_yup.string)().trim().nullable(),
|
|
382
376
|
select: (0, import_yup.string)().trim().nullable(),
|
|
383
377
|
radio: (0, import_yup.string)().trim().nullable(),
|
|
384
378
|
date: (0, import_yup.string)().nullable().trim().matches(
|
|
@@ -597,7 +591,7 @@ function getField(fieldName, fields) {
|
|
|
597
591
|
}
|
|
598
592
|
function validateFieldSchema(field, value) {
|
|
599
593
|
const validator = buildYupSchema(field);
|
|
600
|
-
return validator().isValidSync(value);
|
|
594
|
+
return validator().isValidSync(value, { strict: true });
|
|
601
595
|
}
|
|
602
596
|
function compareFormValueWithSchemaValue(formValue, schemaValue) {
|
|
603
597
|
const currentPropertyValue = typeof schemaValue === "number" ? schemaValue : schemaValue || void 0;
|
|
@@ -905,7 +899,8 @@ var handleValuesChange = (fields, jsonSchema, config) => (values) => {
|
|
|
905
899
|
let errors;
|
|
906
900
|
try {
|
|
907
901
|
lazySchema.validateSync(values, {
|
|
908
|
-
abortEarly: false
|
|
902
|
+
abortEarly: false,
|
|
903
|
+
strict: true
|
|
909
904
|
});
|
|
910
905
|
} catch (err) {
|
|
911
906
|
if (err.name === "ValidationError") {
|
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.1.1-dev.
|
|
5
|
-
Generated:
|
|
4
|
+
NPM Package: @remoteoss/json-schema-form@0.1.1-dev.20230614173637
|
|
5
|
+
Generated: Wed, 14 Jun 2023 17:37:05 GMT
|
|
6
6
|
|
|
7
7
|
MIT License
|
|
8
8
|
|
|
@@ -335,14 +335,8 @@ var baseString = string().trim();
|
|
|
335
335
|
var todayDateHint = (/* @__PURE__ */ new Date()).toISOString().substring(0, 10);
|
|
336
336
|
var convertBytesToKB = convertDiskSizeFromTo("Bytes", "KB");
|
|
337
337
|
var convertKbBytesToMB = convertDiskSizeFromTo("KB", "MB");
|
|
338
|
-
var useOnlyStrings = (value, originalValue) => {
|
|
339
|
-
if (typeof originalValue === "string") {
|
|
340
|
-
return originalValue;
|
|
341
|
-
}
|
|
342
|
-
return null;
|
|
343
|
-
};
|
|
344
338
|
var yupSchemas = {
|
|
345
|
-
text: string().
|
|
339
|
+
text: string().trim().nullable(),
|
|
346
340
|
select: string().trim().nullable(),
|
|
347
341
|
radio: string().trim().nullable(),
|
|
348
342
|
date: string().nullable().trim().matches(
|
|
@@ -561,7 +555,7 @@ function getField(fieldName, fields) {
|
|
|
561
555
|
}
|
|
562
556
|
function validateFieldSchema(field, value) {
|
|
563
557
|
const validator = buildYupSchema(field);
|
|
564
|
-
return validator().isValidSync(value);
|
|
558
|
+
return validator().isValidSync(value, { strict: true });
|
|
565
559
|
}
|
|
566
560
|
function compareFormValueWithSchemaValue(formValue, schemaValue) {
|
|
567
561
|
const currentPropertyValue = typeof schemaValue === "number" ? schemaValue : schemaValue || void 0;
|
|
@@ -869,7 +863,8 @@ var handleValuesChange = (fields, jsonSchema, config) => (values) => {
|
|
|
869
863
|
let errors;
|
|
870
864
|
try {
|
|
871
865
|
lazySchema.validateSync(values, {
|
|
872
|
-
abortEarly: false
|
|
866
|
+
abortEarly: false,
|
|
867
|
+
strict: true
|
|
873
868
|
});
|
|
874
869
|
} catch (err) {
|
|
875
870
|
if (err.name === "ValidationError") {
|
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.1.1-dev.
|
|
5
|
-
Generated:
|
|
4
|
+
NPM Package: @remoteoss/json-schema-form@0.1.1-dev.20230614173637
|
|
5
|
+
Generated: Wed, 14 Jun 2023 17:37:05 GMT
|
|
6
6
|
|
|
7
7
|
MIT License
|
|
8
8
|
|
|
@@ -11739,14 +11739,8 @@ var baseString = StringSchema().trim();
|
|
|
11739
11739
|
var todayDateHint = (/* @__PURE__ */ new Date()).toISOString().substring(0, 10);
|
|
11740
11740
|
var convertBytesToKB = convertDiskSizeFromTo("Bytes", "KB");
|
|
11741
11741
|
var convertKbBytesToMB = convertDiskSizeFromTo("KB", "MB");
|
|
11742
|
-
var useOnlyStrings = (value, originalValue) => {
|
|
11743
|
-
if (typeof originalValue === "string") {
|
|
11744
|
-
return originalValue;
|
|
11745
|
-
}
|
|
11746
|
-
return null;
|
|
11747
|
-
};
|
|
11748
11742
|
var yupSchemas = {
|
|
11749
|
-
text: StringSchema().
|
|
11743
|
+
text: StringSchema().trim().nullable(),
|
|
11750
11744
|
select: StringSchema().trim().nullable(),
|
|
11751
11745
|
radio: StringSchema().trim().nullable(),
|
|
11752
11746
|
date: StringSchema().nullable().trim().matches(
|
|
@@ -11965,7 +11959,7 @@ function getField(fieldName, fields) {
|
|
|
11965
11959
|
}
|
|
11966
11960
|
function validateFieldSchema(field, value) {
|
|
11967
11961
|
const validator = buildYupSchema(field);
|
|
11968
|
-
return validator().isValidSync(value);
|
|
11962
|
+
return validator().isValidSync(value, { strict: true });
|
|
11969
11963
|
}
|
|
11970
11964
|
function compareFormValueWithSchemaValue(formValue, schemaValue) {
|
|
11971
11965
|
const currentPropertyValue = typeof schemaValue === "number" ? schemaValue : schemaValue || void 0;
|
|
@@ -12273,7 +12267,8 @@ var handleValuesChange = (fields, jsonSchema, config) => (values2) => {
|
|
|
12273
12267
|
let errors;
|
|
12274
12268
|
try {
|
|
12275
12269
|
lazySchema.validateSync(values2, {
|
|
12276
|
-
abortEarly: false
|
|
12270
|
+
abortEarly: false,
|
|
12271
|
+
strict: true
|
|
12277
12272
|
});
|
|
12278
12273
|
} catch (err) {
|
|
12279
12274
|
if (err.name === "ValidationError") {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remoteoss/json-schema-form",
|
|
3
|
-
"version": "0.1.1-dev.
|
|
3
|
+
"version": "0.1.1-dev.20230614173637",
|
|
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",
|
|
@@ -419,7 +419,7 @@ describe('createHeadlessForm', () => {
|
|
|
419
419
|
|
|
420
420
|
describe('field support', () => {
|
|
421
421
|
it('support "text" field type', () => {
|
|
422
|
-
const { fields } = createHeadlessForm(schemaInputTypeText);
|
|
422
|
+
const { fields, handleValidation } = createHeadlessForm(schemaInputTypeText);
|
|
423
423
|
|
|
424
424
|
expect(fields[0]).toMatchObject({
|
|
425
425
|
description: 'The number of your national identification (max 10 digits)',
|
|
@@ -435,10 +435,14 @@ describe('createHeadlessForm', () => {
|
|
|
435
435
|
});
|
|
436
436
|
|
|
437
437
|
const fieldValidator = fields[0].schema;
|
|
438
|
-
expect(fieldValidator.isValidSync('CI007')).toBe(true);
|
|
439
|
-
expect(fieldValidator.isValidSync(true)).toBe(false);
|
|
440
|
-
expect(fieldValidator.isValidSync(1)).toBe(false);
|
|
441
|
-
expect(fieldValidator.isValidSync(0)).toBe(false);
|
|
438
|
+
expect(fieldValidator.isValidSync('CI007', { strict: true })).toBe(true);
|
|
439
|
+
expect(fieldValidator.isValidSync(true, { strict: true })).toBe(false);
|
|
440
|
+
expect(fieldValidator.isValidSync(1, { strict: true })).toBe(false);
|
|
441
|
+
expect(fieldValidator.isValidSync(0, { strict: true })).toBe(false);
|
|
442
|
+
|
|
443
|
+
expect(handleValidation({ id_number: 1 }).formErrors).toEqual({
|
|
444
|
+
id_number: 'id_number must be a `string` type, but the final value was: `1`.',
|
|
445
|
+
});
|
|
442
446
|
|
|
443
447
|
expect(() => fieldValidator.validateSync('')).toThrowError('Required field');
|
|
444
448
|
});
|
|
@@ -1307,9 +1311,7 @@ describe('createHeadlessForm', () => {
|
|
|
1307
1311
|
|
|
1308
1312
|
// The "child.has_child" is required
|
|
1309
1313
|
expect(validateForm({})).toEqual({
|
|
1310
|
-
child:
|
|
1311
|
-
has_child: 'Required field',
|
|
1312
|
-
},
|
|
1314
|
+
child: 'Required field',
|
|
1313
1315
|
});
|
|
1314
1316
|
|
|
1315
1317
|
// The "child.no" is valid
|