@remoteoss/json-schema-form 0.5.0-dev.20230717103306 → 0.5.0-dev.20230719114157
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 +13 -37
- package/dist/index.js +13 -37
- package/dist/standalone.js +13 -37
- package/package.json +1 -1
- package/src/tests/createHeadlessForm.test.js +74 -42
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.5.0-dev.
|
|
5
|
-
Generated:
|
|
4
|
+
NPM Package: @remoteoss/json-schema-form@0.5.0-dev.20230719114157
|
|
5
|
+
Generated: Wed, 19 Jul 2023 11:42:22 GMT
|
|
6
6
|
|
|
7
7
|
MIT License
|
|
8
8
|
|
|
@@ -393,16 +393,10 @@ var compareDates = (d1, d2) => {
|
|
|
393
393
|
}
|
|
394
394
|
};
|
|
395
395
|
var validateMinDate = (value, minDate) => {
|
|
396
|
-
if (!value) {
|
|
397
|
-
return true;
|
|
398
|
-
}
|
|
399
396
|
const compare = compareDates(value, minDate);
|
|
400
397
|
return compare === "GREATER" || compare === "EQUAL" ? true : false;
|
|
401
398
|
};
|
|
402
399
|
var validateMaxDate = (value, minDate) => {
|
|
403
|
-
if (!value) {
|
|
404
|
-
return true;
|
|
405
|
-
}
|
|
406
400
|
const compare = compareDates(value, minDate);
|
|
407
401
|
return compare === "LESSER" || compare === "EQUAL" ? true : false;
|
|
408
402
|
};
|
|
@@ -420,44 +414,25 @@ var yupSchemas = {
|
|
|
420
414
|
return `The option ${JSON.stringify(value)} is not valid.`;
|
|
421
415
|
}),
|
|
422
416
|
date: ({ minDate, maxDate }) => {
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
).test(
|
|
428
|
-
"minDate",
|
|
429
|
-
`The date must be ${minDate} or after`,
|
|
430
|
-
(value) => validateMinDate(value, minDate)
|
|
431
|
-
).test(
|
|
432
|
-
"maxDate",
|
|
433
|
-
`The date must be ${maxDate} or before`,
|
|
434
|
-
(value) => validateMaxDate(value, maxDate)
|
|
435
|
-
);
|
|
436
|
-
}
|
|
417
|
+
let dateString = (0, import_yup.string)().nullable().trim().matches(
|
|
418
|
+
/(?:\d){4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-9]|3[0-1])/,
|
|
419
|
+
`Must be a valid date in ${DEFAULT_DATE_FORMAT.toLocaleLowerCase()} format. e.g. ${todayDateHint}`
|
|
420
|
+
);
|
|
437
421
|
if (minDate) {
|
|
438
|
-
|
|
439
|
-
/(?:\d){4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-9]|3[0-1])/,
|
|
440
|
-
`Must be a valid date in ${DEFAULT_DATE_FORMAT.toLocaleLowerCase()} format. e.g. ${todayDateHint}`
|
|
441
|
-
).test(
|
|
422
|
+
dateString = dateString.test(
|
|
442
423
|
"minDate",
|
|
443
|
-
`The date must be ${minDate} or after
|
|
424
|
+
`The date must be ${minDate} or after.`,
|
|
444
425
|
(value) => validateMinDate(value, minDate)
|
|
445
426
|
);
|
|
446
427
|
}
|
|
447
428
|
if (maxDate) {
|
|
448
|
-
|
|
449
|
-
/(?:\d){4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-9]|3[0-1])/,
|
|
450
|
-
`Must be a valid date in ${DEFAULT_DATE_FORMAT.toLocaleLowerCase()} format. e.g. ${todayDateHint}`
|
|
451
|
-
).test(
|
|
429
|
+
dateString = dateString.test(
|
|
452
430
|
"maxDate",
|
|
453
|
-
`The date must be ${maxDate} or before
|
|
431
|
+
`The date must be ${maxDate} or before.`,
|
|
454
432
|
(value) => validateMaxDate(value, maxDate)
|
|
455
433
|
);
|
|
456
434
|
}
|
|
457
|
-
return
|
|
458
|
-
/(?:\d){4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-9]|3[0-1])/,
|
|
459
|
-
`Must be a valid date in ${DEFAULT_DATE_FORMAT.toLocaleLowerCase()} format. e.g. ${todayDateHint}`
|
|
460
|
-
);
|
|
435
|
+
return dateString;
|
|
461
436
|
},
|
|
462
437
|
number: (0, import_yup.number)().typeError("The value must be a number").nullable(),
|
|
463
438
|
file: (0, import_yup.array)().nullable(),
|
|
@@ -503,7 +478,7 @@ var getYupSchema = ({ inputType, ...field }) => {
|
|
|
503
478
|
const optionValues = getOptions(field);
|
|
504
479
|
return yupSchemas.radioOrSelect(optionValues);
|
|
505
480
|
}
|
|
506
|
-
if (
|
|
481
|
+
if (field.format === "date") {
|
|
507
482
|
return yupSchemas.date({ minDate: field.minDate, maxDate: field.maxDate });
|
|
508
483
|
}
|
|
509
484
|
return yupSchemas[inputType] || yupSchemasToJsonTypes[jsonType];
|
|
@@ -965,6 +940,7 @@ function extractParametersFromNode(schemaNode) {
|
|
|
965
940
|
maxFileSize: node.maxFileSize,
|
|
966
941
|
// @deprecated in favor of presentation.maxFileSize
|
|
967
942
|
default: node.default,
|
|
943
|
+
format: node.format,
|
|
968
944
|
// Checkboxes conditions
|
|
969
945
|
// — For checkboxes that only accept one value (string)
|
|
970
946
|
...presentation?.inputType === "checkbox" && { checkboxValue: node.const },
|
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.5.0-dev.
|
|
5
|
-
Generated:
|
|
4
|
+
NPM Package: @remoteoss/json-schema-form@0.5.0-dev.20230719114157
|
|
5
|
+
Generated: Wed, 19 Jul 2023 11:42:22 GMT
|
|
6
6
|
|
|
7
7
|
MIT License
|
|
8
8
|
|
|
@@ -357,16 +357,10 @@ var compareDates = (d1, d2) => {
|
|
|
357
357
|
}
|
|
358
358
|
};
|
|
359
359
|
var validateMinDate = (value, minDate) => {
|
|
360
|
-
if (!value) {
|
|
361
|
-
return true;
|
|
362
|
-
}
|
|
363
360
|
const compare = compareDates(value, minDate);
|
|
364
361
|
return compare === "GREATER" || compare === "EQUAL" ? true : false;
|
|
365
362
|
};
|
|
366
363
|
var validateMaxDate = (value, minDate) => {
|
|
367
|
-
if (!value) {
|
|
368
|
-
return true;
|
|
369
|
-
}
|
|
370
364
|
const compare = compareDates(value, minDate);
|
|
371
365
|
return compare === "LESSER" || compare === "EQUAL" ? true : false;
|
|
372
366
|
};
|
|
@@ -384,44 +378,25 @@ var yupSchemas = {
|
|
|
384
378
|
return `The option ${JSON.stringify(value)} is not valid.`;
|
|
385
379
|
}),
|
|
386
380
|
date: ({ minDate, maxDate }) => {
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
).test(
|
|
392
|
-
"minDate",
|
|
393
|
-
`The date must be ${minDate} or after`,
|
|
394
|
-
(value) => validateMinDate(value, minDate)
|
|
395
|
-
).test(
|
|
396
|
-
"maxDate",
|
|
397
|
-
`The date must be ${maxDate} or before`,
|
|
398
|
-
(value) => validateMaxDate(value, maxDate)
|
|
399
|
-
);
|
|
400
|
-
}
|
|
381
|
+
let dateString = string().nullable().trim().matches(
|
|
382
|
+
/(?:\d){4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-9]|3[0-1])/,
|
|
383
|
+
`Must be a valid date in ${DEFAULT_DATE_FORMAT.toLocaleLowerCase()} format. e.g. ${todayDateHint}`
|
|
384
|
+
);
|
|
401
385
|
if (minDate) {
|
|
402
|
-
|
|
403
|
-
/(?:\d){4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-9]|3[0-1])/,
|
|
404
|
-
`Must be a valid date in ${DEFAULT_DATE_FORMAT.toLocaleLowerCase()} format. e.g. ${todayDateHint}`
|
|
405
|
-
).test(
|
|
386
|
+
dateString = dateString.test(
|
|
406
387
|
"minDate",
|
|
407
|
-
`The date must be ${minDate} or after
|
|
388
|
+
`The date must be ${minDate} or after.`,
|
|
408
389
|
(value) => validateMinDate(value, minDate)
|
|
409
390
|
);
|
|
410
391
|
}
|
|
411
392
|
if (maxDate) {
|
|
412
|
-
|
|
413
|
-
/(?:\d){4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-9]|3[0-1])/,
|
|
414
|
-
`Must be a valid date in ${DEFAULT_DATE_FORMAT.toLocaleLowerCase()} format. e.g. ${todayDateHint}`
|
|
415
|
-
).test(
|
|
393
|
+
dateString = dateString.test(
|
|
416
394
|
"maxDate",
|
|
417
|
-
`The date must be ${maxDate} or before
|
|
395
|
+
`The date must be ${maxDate} or before.`,
|
|
418
396
|
(value) => validateMaxDate(value, maxDate)
|
|
419
397
|
);
|
|
420
398
|
}
|
|
421
|
-
return
|
|
422
|
-
/(?:\d){4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-9]|3[0-1])/,
|
|
423
|
-
`Must be a valid date in ${DEFAULT_DATE_FORMAT.toLocaleLowerCase()} format. e.g. ${todayDateHint}`
|
|
424
|
-
);
|
|
399
|
+
return dateString;
|
|
425
400
|
},
|
|
426
401
|
number: number().typeError("The value must be a number").nullable(),
|
|
427
402
|
file: array().nullable(),
|
|
@@ -467,7 +442,7 @@ var getYupSchema = ({ inputType, ...field }) => {
|
|
|
467
442
|
const optionValues = getOptions(field);
|
|
468
443
|
return yupSchemas.radioOrSelect(optionValues);
|
|
469
444
|
}
|
|
470
|
-
if (
|
|
445
|
+
if (field.format === "date") {
|
|
471
446
|
return yupSchemas.date({ minDate: field.minDate, maxDate: field.maxDate });
|
|
472
447
|
}
|
|
473
448
|
return yupSchemas[inputType] || yupSchemasToJsonTypes[jsonType];
|
|
@@ -929,6 +904,7 @@ function extractParametersFromNode(schemaNode) {
|
|
|
929
904
|
maxFileSize: node.maxFileSize,
|
|
930
905
|
// @deprecated in favor of presentation.maxFileSize
|
|
931
906
|
default: node.default,
|
|
907
|
+
format: node.format,
|
|
932
908
|
// Checkboxes conditions
|
|
933
909
|
// — For checkboxes that only accept one value (string)
|
|
934
910
|
...presentation?.inputType === "checkbox" && { checkboxValue: node.const },
|
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.5.0-dev.
|
|
5
|
-
Generated:
|
|
4
|
+
NPM Package: @remoteoss/json-schema-form@0.5.0-dev.20230719114157
|
|
5
|
+
Generated: Wed, 19 Jul 2023 11:42:22 GMT
|
|
6
6
|
|
|
7
7
|
MIT License
|
|
8
8
|
|
|
@@ -11333,16 +11333,10 @@ var compareDates = (d1, d2) => {
|
|
|
11333
11333
|
}
|
|
11334
11334
|
};
|
|
11335
11335
|
var validateMinDate = (value, minDate) => {
|
|
11336
|
-
if (!value) {
|
|
11337
|
-
return true;
|
|
11338
|
-
}
|
|
11339
11336
|
const compare = compareDates(value, minDate);
|
|
11340
11337
|
return compare === "GREATER" || compare === "EQUAL" ? true : false;
|
|
11341
11338
|
};
|
|
11342
11339
|
var validateMaxDate = (value, minDate) => {
|
|
11343
|
-
if (!value) {
|
|
11344
|
-
return true;
|
|
11345
|
-
}
|
|
11346
11340
|
const compare = compareDates(value, minDate);
|
|
11347
11341
|
return compare === "LESSER" || compare === "EQUAL" ? true : false;
|
|
11348
11342
|
};
|
|
@@ -11360,44 +11354,25 @@ var yupSchemas = {
|
|
|
11360
11354
|
return `The option ${JSON.stringify(value)} is not valid.`;
|
|
11361
11355
|
}),
|
|
11362
11356
|
date: ({ minDate, maxDate }) => {
|
|
11363
|
-
|
|
11364
|
-
|
|
11365
|
-
|
|
11366
|
-
|
|
11367
|
-
).test(
|
|
11368
|
-
"minDate",
|
|
11369
|
-
`The date must be ${minDate} or after`,
|
|
11370
|
-
(value) => validateMinDate(value, minDate)
|
|
11371
|
-
).test(
|
|
11372
|
-
"maxDate",
|
|
11373
|
-
`The date must be ${maxDate} or before`,
|
|
11374
|
-
(value) => validateMaxDate(value, maxDate)
|
|
11375
|
-
);
|
|
11376
|
-
}
|
|
11357
|
+
let dateString = StringSchema().nullable().trim().matches(
|
|
11358
|
+
/(?:\d){4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-9]|3[0-1])/,
|
|
11359
|
+
`Must be a valid date in ${DEFAULT_DATE_FORMAT.toLocaleLowerCase()} format. e.g. ${todayDateHint}`
|
|
11360
|
+
);
|
|
11377
11361
|
if (minDate) {
|
|
11378
|
-
|
|
11379
|
-
/(?:\d){4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-9]|3[0-1])/,
|
|
11380
|
-
`Must be a valid date in ${DEFAULT_DATE_FORMAT.toLocaleLowerCase()} format. e.g. ${todayDateHint}`
|
|
11381
|
-
).test(
|
|
11362
|
+
dateString = dateString.test(
|
|
11382
11363
|
"minDate",
|
|
11383
|
-
`The date must be ${minDate} or after
|
|
11364
|
+
`The date must be ${minDate} or after.`,
|
|
11384
11365
|
(value) => validateMinDate(value, minDate)
|
|
11385
11366
|
);
|
|
11386
11367
|
}
|
|
11387
11368
|
if (maxDate) {
|
|
11388
|
-
|
|
11389
|
-
/(?:\d){4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-9]|3[0-1])/,
|
|
11390
|
-
`Must be a valid date in ${DEFAULT_DATE_FORMAT.toLocaleLowerCase()} format. e.g. ${todayDateHint}`
|
|
11391
|
-
).test(
|
|
11369
|
+
dateString = dateString.test(
|
|
11392
11370
|
"maxDate",
|
|
11393
|
-
`The date must be ${maxDate} or before
|
|
11371
|
+
`The date must be ${maxDate} or before.`,
|
|
11394
11372
|
(value) => validateMaxDate(value, maxDate)
|
|
11395
11373
|
);
|
|
11396
11374
|
}
|
|
11397
|
-
return
|
|
11398
|
-
/(?:\d){4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-9]|3[0-1])/,
|
|
11399
|
-
`Must be a valid date in ${DEFAULT_DATE_FORMAT.toLocaleLowerCase()} format. e.g. ${todayDateHint}`
|
|
11400
|
-
);
|
|
11375
|
+
return dateString;
|
|
11401
11376
|
},
|
|
11402
11377
|
number: NumberSchema().typeError("The value must be a number").nullable(),
|
|
11403
11378
|
file: array_default().nullable(),
|
|
@@ -11443,7 +11418,7 @@ var getYupSchema = ({ inputType, ...field }) => {
|
|
|
11443
11418
|
const optionValues = getOptions(field);
|
|
11444
11419
|
return yupSchemas.radioOrSelect(optionValues);
|
|
11445
11420
|
}
|
|
11446
|
-
if (
|
|
11421
|
+
if (field.format === "date") {
|
|
11447
11422
|
return yupSchemas.date({ minDate: field.minDate, maxDate: field.maxDate });
|
|
11448
11423
|
}
|
|
11449
11424
|
return yupSchemas[inputType] || yupSchemasToJsonTypes[jsonType];
|
|
@@ -11905,6 +11880,7 @@ function extractParametersFromNode(schemaNode) {
|
|
|
11905
11880
|
maxFileSize: node.maxFileSize,
|
|
11906
11881
|
// @deprecated in favor of presentation.maxFileSize
|
|
11907
11882
|
default: node.default,
|
|
11883
|
+
format: node.format,
|
|
11908
11884
|
// Checkboxes conditions
|
|
11909
11885
|
// — For checkboxes that only accept one value (string)
|
|
11910
11886
|
...presentation?.inputType === "checkbox" && { checkboxValue: node.const },
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remoteoss/json-schema-form",
|
|
3
|
-
"version": "0.5.0-dev.
|
|
3
|
+
"version": "0.5.0-dev.20230719114157",
|
|
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",
|
|
@@ -1036,59 +1036,91 @@ describe('createHeadlessForm', () => {
|
|
|
1036
1036
|
});
|
|
1037
1037
|
|
|
1038
1038
|
it('support "date" field type with a minDate', () => {
|
|
1039
|
-
const
|
|
1039
|
+
const { fields, handleValidation } = createHeadlessForm(schemaInputTypeDate);
|
|
1040
1040
|
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1041
|
+
const validateForm = (vals) => friendlyError(handleValidation(vals));
|
|
1042
|
+
|
|
1043
|
+
expect(fields[0]).toMatchObject({
|
|
1044
|
+
label: 'Birthdate',
|
|
1045
|
+
name: 'birthdate',
|
|
1046
|
+
required: true,
|
|
1047
|
+
schema: expect.any(Object),
|
|
1048
|
+
type: 'date',
|
|
1049
|
+
maxLength: 10,
|
|
1050
|
+
minDate: '1922-03-01',
|
|
1051
|
+
maxDate: '2022-03-01',
|
|
1052
|
+
});
|
|
1053
|
+
|
|
1054
|
+
expect(validateForm({})).toEqual({
|
|
1055
|
+
birthdate: 'Required field',
|
|
1054
1056
|
});
|
|
1055
1057
|
|
|
1056
|
-
const fieldValidator = result.fields[0].schema;
|
|
1057
1058
|
const todayDateHint = new Date().toISOString().substring(0, 10);
|
|
1058
|
-
|
|
1059
|
-
expect(
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
)
|
|
1059
|
+
|
|
1060
|
+
expect(validateForm({ birthdate: '' })).toEqual({
|
|
1061
|
+
birthdate: `Must be a valid date in yyyy-mm-dd format. e.g. ${todayDateHint}`,
|
|
1062
|
+
});
|
|
1063
|
+
|
|
1064
|
+
expect(validateForm({ birthdate: '1922-02-01' })).toEqual({
|
|
1065
|
+
birthdate: 'The date must be 1922-03-01 or after.',
|
|
1066
|
+
});
|
|
1067
|
+
|
|
1068
|
+
expect(validateForm({ birthdate: '1922-03-01' })).toEqual(undefined);
|
|
1069
|
+
|
|
1070
|
+
expect(validateForm({ birthdate: '2021-03-01' })).toEqual(undefined);
|
|
1064
1071
|
});
|
|
1065
1072
|
|
|
1066
1073
|
it('support "date" field type with a maxDate', () => {
|
|
1067
|
-
const
|
|
1074
|
+
const { fields, handleValidation } = createHeadlessForm(schemaInputTypeDate);
|
|
1068
1075
|
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
},
|
|
1081
|
-
],
|
|
1076
|
+
const validateForm = (vals) => friendlyError(handleValidation(vals));
|
|
1077
|
+
|
|
1078
|
+
expect(fields[0]).toMatchObject({
|
|
1079
|
+
label: 'Birthdate',
|
|
1080
|
+
name: 'birthdate',
|
|
1081
|
+
required: true,
|
|
1082
|
+
schema: expect.any(Object),
|
|
1083
|
+
type: 'date',
|
|
1084
|
+
maxLength: 10,
|
|
1085
|
+
minDate: '1922-03-01',
|
|
1086
|
+
maxDate: '2022-03-01',
|
|
1082
1087
|
});
|
|
1083
1088
|
|
|
1084
|
-
const fieldValidator = result.fields[0].schema;
|
|
1085
1089
|
const todayDateHint = new Date().toISOString().substring(0, 10);
|
|
1086
|
-
|
|
1087
|
-
expect(
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
);
|
|
1090
|
+
|
|
1091
|
+
expect(validateForm({ birthdate: '' })).toEqual({
|
|
1092
|
+
birthdate: `Must be a valid date in yyyy-mm-dd format. e.g. ${todayDateHint}`,
|
|
1093
|
+
});
|
|
1094
|
+
|
|
1095
|
+
expect(validateForm({ birthdate: '2022-02-01' })).toEqual(undefined);
|
|
1096
|
+
expect(validateForm({ birthdate: '2022-03-01' })).toEqual(undefined);
|
|
1097
|
+
expect(validateForm({ birthdate: '2022-04-01' })).toEqual({
|
|
1098
|
+
birthdate: 'The date must be 2022-03-01 or before.',
|
|
1099
|
+
});
|
|
1100
|
+
});
|
|
1101
|
+
|
|
1102
|
+
it('support format date with minDate and maxDate', () => {
|
|
1103
|
+
const schemaFormatDate = {
|
|
1104
|
+
properties: {
|
|
1105
|
+
birthdate: {
|
|
1106
|
+
title: 'Birthdate',
|
|
1107
|
+
type: 'string',
|
|
1108
|
+
format: 'date',
|
|
1109
|
+
'x-jsf-presentation': {
|
|
1110
|
+
inputType: 'myDateType',
|
|
1111
|
+
maxDate: '2022-03-01',
|
|
1112
|
+
minDate: '1922-03-01',
|
|
1113
|
+
},
|
|
1114
|
+
},
|
|
1115
|
+
},
|
|
1116
|
+
};
|
|
1117
|
+
|
|
1118
|
+
const { handleValidation } = createHeadlessForm(schemaFormatDate);
|
|
1119
|
+
const validateForm = (vals) => friendlyError(handleValidation(vals));
|
|
1120
|
+
|
|
1121
|
+
expect(validateForm({ birthdate: '1922-02-01' })).toEqual({
|
|
1122
|
+
birthdate: 'The date must be 1922-03-01 or after.',
|
|
1123
|
+
});
|
|
1092
1124
|
});
|
|
1093
1125
|
|
|
1094
1126
|
it('supports "file" field type', () => {
|