@react-typed-forms/schemas 11.11.0 → 11.11.1

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/lib/index.js CHANGED
@@ -29,6 +29,8 @@ exports.ValidationMessageType = void 0;
29
29
  ValidationMessageType["NotEmpty"] = "NotEmpty";
30
30
  ValidationMessageType["MinLength"] = "MinLength";
31
31
  ValidationMessageType["MaxLength"] = "MaxLength";
32
+ ValidationMessageType["NotAfterDate"] = "NotAfterDate";
33
+ ValidationMessageType["NotBeforeDate"] = "NotBeforeDate";
32
34
  })(exports.ValidationMessageType || (exports.ValidationMessageType = {}));
33
35
  exports.ControlDefinitionType = void 0;
34
36
  (function (ControlDefinitionType) {
@@ -1282,7 +1284,7 @@ function useDateValidator(dv, ctx) {
1282
1284
  schemaInterface = ctx.dataContext.schemaInterface;
1283
1285
  var comparisonDate;
1284
1286
  if (dv.fixedDate) {
1285
- comparisonDate = Date.parse(dv.fixedDate);
1287
+ comparisonDate = schemaInterface.parseToMillis(field, dv.fixedDate);
1286
1288
  } else {
1287
1289
  var nowDate = new Date();
1288
1290
  comparisonDate = Date.UTC(nowDate.getFullYear(), nowDate.getMonth(), nowDate.getDate());
@@ -1295,7 +1297,7 @@ function useDateValidator(dv, ctx) {
1295
1297
  var selDate = schemaInterface.parseToMillis(field, v);
1296
1298
  var notAfter = dv.comparison === exports.DateComparison.NotAfter;
1297
1299
  if (notAfter ? selDate > comparisonDate : selDate < comparisonDate) {
1298
- return "Date must not be " + (notAfter ? "after" : "before") + " " + new Date(comparisonDate).toDateString();
1300
+ return schemaInterface.validationMessageText(field, notAfter ? exports.ValidationMessageType.NotAfterDate : exports.ValidationMessageType.NotBeforeDate, selDate, comparisonDate);
1299
1301
  }
1300
1302
  }
1301
1303
  return null;
@@ -1326,6 +1328,10 @@ var DefaultSchemaInterface = /*#__PURE__*/function () {
1326
1328
  return "Length must be at least " + expected;
1327
1329
  case exports.ValidationMessageType.MaxLength:
1328
1330
  return "Length must be less than " + expected;
1331
+ case exports.ValidationMessageType.NotBeforeDate:
1332
+ return "Date must not be before " + new Date(expected).toDateString();
1333
+ case exports.ValidationMessageType.NotAfterDate:
1334
+ return "Date must not be after " + new Date(expected).toDateString();
1329
1335
  default:
1330
1336
  return "Unknown error";
1331
1337
  }