@warlock.js/seal 5.6.0 → 5.7.0

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/CHANGELOG.md CHANGED
@@ -4,6 +4,12 @@ All notable changes to `@warlock.js/seal` are documented in this file.
4
4
 
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). `@warlock.js/*` packages are released in lockstep — every package shares the same version number, so a version below may list only the changes that affected this package.
6
6
 
7
+ ## 5.7.0 - 2026-09-11
8
+
9
+ ### Changed
10
+
11
+ - Internal type-safety hardening; no behaviour change.
12
+
7
13
  ## 5.6.0 - 2026-09-08
8
14
  ### Fixed
9
15
 
package/cjs/index.cjs CHANGED
@@ -329,13 +329,19 @@ const invalidRule = (rule, context) => {
329
329
  rule,
330
330
  context
331
331
  })]));
332
+ const input = resolveAttribute({
333
+ key: "input",
334
+ rawValue: translatableWithInput.input ?? "schema",
335
+ rule,
336
+ context
337
+ });
332
338
  const attributes = {
333
339
  path: context.path,
334
340
  key: context.key,
335
341
  value: context.value,
336
342
  ...rule.context.translationParams,
337
343
  ...resolvedParams,
338
- input: resolvedParams.input
344
+ input
339
345
  };
340
346
  return {
341
347
  isValid: false,
@@ -609,7 +615,7 @@ var BaseValidator = class {
609
615
  */
610
616
  attributes(attributes) {
611
617
  const instance = this.instance;
612
- for (const key in attributes) instance.attributesText[key] = attributes[key];
618
+ for (const [key, value] of Object.entries(attributes)) instance.attributesText[key] = value;
613
619
  return instance;
614
620
  }
615
621
  /**
@@ -617,7 +623,7 @@ var BaseValidator = class {
617
623
  */
618
624
  transAttributes(attributes) {
619
625
  const instance = this.instance;
620
- for (const key in attributes) instance.translatedAttributes[key] = attributes[key];
626
+ for (const [key, value] of Object.entries(attributes)) instance.translatedAttributes[key] = value;
621
627
  return instance;
622
628
  }
623
629
  /**
@@ -1640,7 +1646,7 @@ const isCreditCardRule = {
1640
1646
  let sum = 0;
1641
1647
  let isEven = false;
1642
1648
  for (let i = cardNumber.length - 1; i >= 0; i--) {
1643
- let digit = parseInt(cardNumber[i], 10);
1649
+ let digit = parseInt(cardNumber.charAt(i), 10);
1644
1650
  if (isEven) {
1645
1651
  digit *= 2;
1646
1652
  if (digit > 9) digit -= 9;
@@ -2924,8 +2930,10 @@ const betweenTimesRule = {
2924
2930
  const inputTimeInMinutes = inputHour * 60 + inputMinute;
2925
2931
  const { startTime, endTime } = this.context.options;
2926
2932
  const [startHour, startMinute] = startTime.split(":").map(Number);
2933
+ if (startHour === void 0 || startMinute === void 0) return invalidRule(this, context);
2927
2934
  const startTimeInMinutes = startHour * 60 + startMinute;
2928
2935
  const [endHour, endMinute] = endTime.split(":").map(Number);
2936
+ if (endHour === void 0 || endMinute === void 0) return invalidRule(this, context);
2929
2937
  const endTimeInMinutes = endHour * 60 + endMinute;
2930
2938
  if (inputTimeInMinutes >= startTimeInMinutes && inputTimeInMinutes <= endTimeInMinutes) return VALID_RULE;
2931
2939
  this.context.translationParams.startTime = startTime;
@@ -7326,9 +7334,9 @@ var ObjectValidator = class ObjectValidator extends BaseValidator {
7326
7334
  clone(keys) {
7327
7335
  const cloned = super.clone();
7328
7336
  const newSchema = {};
7329
- for (const key in this.schema) {
7337
+ for (const [key, validator] of Object.entries(this.schema)) {
7330
7338
  if (keys && !keys.includes(key)) continue;
7331
- newSchema[key] = this.schema[key].clone();
7339
+ newSchema[key] = validator.clone();
7332
7340
  }
7333
7341
  cloned.schema = newSchema;
7334
7342
  cloned.shouldAllowUnknown = this.shouldAllowUnknown;
@@ -7379,7 +7387,7 @@ var ObjectValidator = class ObjectValidator extends BaseValidator {
7379
7387
  extend(schemaOrValidator) {
7380
7388
  const extended = this.clone();
7381
7389
  const schemaToAdd = schemaOrValidator instanceof ObjectValidator ? schemaOrValidator.schema : schemaOrValidator;
7382
- for (const key in schemaToAdd) extended.schema[key] = schemaToAdd[key].clone();
7390
+ for (const [key, validator] of Object.entries(schemaToAdd)) extended.schema[key] = validator.clone();
7383
7391
  return extended;
7384
7392
  }
7385
7393
  /**
@@ -7413,7 +7421,7 @@ var ObjectValidator = class ObjectValidator extends BaseValidator {
7413
7421
  */
7414
7422
  merge(validator) {
7415
7423
  const merged = this.clone();
7416
- for (const key in validator.schema) merged.schema[key] = validator.schema[key].clone();
7424
+ for (const [key, schemaValidator] of Object.entries(validator.schema)) merged.schema[key] = schemaValidator.clone();
7417
7425
  merged.shouldAllowUnknown = validator.shouldAllowUnknown;
7418
7426
  merged.allowedKeys = [...merged.allowedKeys, ...validator.allowedKeys];
7419
7427
  merged.rules.push(...validator.rules);
@@ -7470,7 +7478,7 @@ var ObjectValidator = class ObjectValidator extends BaseValidator {
7470
7478
  partial(...keys) {
7471
7479
  const validationSchema = this.clone();
7472
7480
  if (keys.length === 0) keys = Object.keys(validationSchema.schema);
7473
- for (const key of keys) validationSchema.schema[key] = validationSchema.schema[key].optional();
7481
+ for (const [key, validator] of Object.entries(validationSchema.schema)) if (keys.length === 0 || keys.includes(key)) validationSchema.schema[key] = validator.optional();
7474
7482
  return validationSchema;
7475
7483
  }
7476
7484
  /**
@@ -7479,7 +7487,7 @@ var ObjectValidator = class ObjectValidator extends BaseValidator {
7479
7487
  requiredFields(...keys) {
7480
7488
  const validationSchema = this.clone();
7481
7489
  if (keys.length === 0) keys = Object.keys(validationSchema.schema);
7482
- for (const key of keys) validationSchema.schema[key] = validationSchema.schema[key].required();
7490
+ for (const [key, validator] of Object.entries(validationSchema.schema)) if (keys.length === 0 || keys.includes(key)) validationSchema.schema[key] = validator.required();
7483
7491
  return validationSchema;
7484
7492
  }
7485
7493
  /**
@@ -7543,8 +7551,7 @@ var ObjectValidator = class ObjectValidator extends BaseValidator {
7543
7551
  if (data === void 0) return result;
7544
7552
  const errors = [];
7545
7553
  const validatedData = {};
7546
- const validationPromises = Object.keys(this.schema).filter((key) => !this.isComputedValidator(this.schema[key])).map(async (key) => {
7547
- const validator = this.schema[key];
7554
+ const validationPromises = Object.entries(this.schema).filter(([, validator]) => !this.isComputedValidator(validator)).map(async ([key, validator]) => {
7548
7555
  const value = mutatedData?.[key] !== void 0 ? mutatedData[key] : validator.getDefaultValue();
7549
7556
  const childContext = {
7550
7557
  ...context,
@@ -7564,8 +7571,7 @@ var ObjectValidator = class ObjectValidator extends BaseValidator {
7564
7571
  data: void 0
7565
7572
  };
7566
7573
  const computedFields = this.getComputedFields();
7567
- const computedPromises = Object.keys(computedFields).map(async (key) => {
7568
- const validator = computedFields[key];
7574
+ const computedPromises = Object.entries(computedFields).map(async ([key, validator]) => {
7569
7575
  const childContext = {
7570
7576
  ...context,
7571
7577
  parent: validatedData,