@warlock.js/seal 4.16.0 → 5.0.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 +7 -0
- package/cjs/index.cjs +33 -5
- package/cjs/index.cjs.map +1 -1
- package/esm/index.d.mts +2 -2
- package/esm/index.mjs +2 -2
- package/esm/rules/index.mjs +1 -1
- package/esm/rules/string/index.mjs +1 -1
- package/esm/rules/string/ip.d.mts +8 -1
- package/esm/rules/string/ip.d.mts.map +1 -1
- package/esm/rules/string/ip.mjs +26 -2
- package/esm/rules/string/ip.mjs.map +1 -1
- package/esm/validators/base-validator.d.mts.map +1 -1
- package/esm/validators/base-validator.mjs +2 -1
- package/esm/validators/base-validator.mjs.map +1 -1
- package/package.json +4 -1
package/esm/index.d.mts
CHANGED
|
@@ -29,7 +29,7 @@ import { alphaNumericRule, alphaRule, isNumericRule } from "./rules/string/alpha
|
|
|
29
29
|
import { isCreditCardRule } from "./rules/string/credit-card.mjs";
|
|
30
30
|
import { emailRule } from "./rules/string/email.mjs";
|
|
31
31
|
import { UUIDVersion, cuidRule, nanoidRule, ulidRule, uuidRule } from "./rules/string/id-formats.mjs";
|
|
32
|
-
import { ip4Rule, ip6Rule, ipRule } from "./rules/string/ip.mjs";
|
|
32
|
+
import { ip4Rule, ip6Rule, ipRule, isIP, isIPv4, isIPv6 } from "./rules/string/ip.mjs";
|
|
33
33
|
import { matchesRule } from "./rules/string/matches.mjs";
|
|
34
34
|
import { patternRule } from "./rules/string/pattern.mjs";
|
|
35
35
|
import { containsRule, endsWithRule, notContainsRule, startsWithRule } from "./rules/string/string-comparison.mjs";
|
|
@@ -97,7 +97,7 @@ import { ValidateOptions, ValidatorV, v } from "./factory/validators.mjs";
|
|
|
97
97
|
import { validate } from "./factory/validate.mjs";
|
|
98
98
|
import { PluginContext, SealPlugin, getInstalledPlugins, hasPlugin, registerPlugin, unregisterPlugin } from "./plugins/plugin-system.mjs";
|
|
99
99
|
import { mapToStandardResult } from "./standard-schema/map-result.mjs";
|
|
100
|
-
export { AnyValidator, ArrayValidator, AttributeTranslation, BaseValidator, BooleanValidator, ComputedCallback, ComputedValidator, ContextualSchemaRule, ContextualizedMutator, ContextualizedTransformer, DateValidator, DiscriminatedUnionValidator, FileSizeOption, FloatValidator, Infer, InferInput, InferInputObjectShape, InferObjectShape, InferOutput, InferOutputObjectShape, InstanceOfValidator, IntValidator, IsInputOptionalKey, IsOptionalKey, IsOutputOptionalKey, JsonSchemaResult, JsonSchemaTarget, LazyValidator, LiteralValidator, ManagedCallback, ManagedValidator, Month, Mutator, MutatorContext, NumberValidator, NumericValidator, ObjectValidator, PluginContext, PrimitiveValidator, RecordValidator, RuleResult, RuleTranslation, ScalarValidator, Schema, SchemaContext, SchemaRule, SchemaRuleOptions, SealConfig, SealPlugin, SimpleTransformerCallback, StandardJSONSchemaV1, StandardSchemaV1, StringValidator, TransformerCallback, TranslateAttributeCallback, TranslateRuleCallback, TupleValidator, UUIDVersion, UnionValidator, VALID_RULE, ValidateOptions, ValidationAttributesList, ValidationResult, ValidatorV, WEEK_DAYS, WeekDay, WhenRuleOptions, absMutator, addDaysMutator, addHoursMutator, addMonthsMutator, addYearsMutator, afterFieldRule, afterTodayRule, ageRule, allowedValuesRule, alphaNumericRule, alphaOnlyMutator, alphaRule, alphanumericOnlyMutator, appendMutator, applyNullable, arrayRule, base64DecodeMutator, base64EncodeMutator, beforeFieldRule, beforeHourRule, beforeMinuteRule, beforeTodayRule, betweenAgeRule, betweenDatesRule, betweenDaysRule, betweenHoursRule, betweenLengthRule, betweenMinutesRule, betweenMonthsRule, betweenNumbersRule, betweenTimesRule, betweenYearsRule, birthdayRule, booleanMutator, booleanRule, businessDayRule, camelCaseMutator, capitalizeMutator, ceilMutator, colorRule, configureSeal, containsRule, cuidRule, darkColorRule, dateMutator, dateRule, emailRule, endsWithRule, enumRule, equalRule, equalityConditionalMethodsApplied, equalsFieldRule, evenRule, flipArrayMutator, floatRule, floorMutator, forbiddenIfEmptyRule, forbiddenIfInRule, forbiddenIfNotEmptyRule, forbiddenIfNotInRule, forbiddenIfNotRule, forbiddenIfRule, forbiddenMethodsApplied, forbiddenRule, fromHourRule, fromMinuteRule, fromTodayRule, futureRule, getFieldValue, getInstalledPlugins, getRuleOptions, getSealConfig, greaterThanRule, hasPlugin, hexColorRule, hslColorRule, htmlEscapeMutator, humanizeSize, inRule, instanceofRule, intRule, invalidRule, ip4Rule, ip6Rule, ipRule, isCreditCardRule, isDateValue, isNumericRule, jsonMutator, kebabCaseMutator, leapYearRule, lengthRule, lessThanRule, lightColorRule, literalRule, lowercaseMutator, ltrimMutator, mapToStandardResult, maskMutator, matchesRule, maxAgeRule, maxDateRule, maxDayRule, maxFileSizeRule, maxHeightRule, maxLengthRule, maxMonthRule, maxRule, maxWidthRule, maxWordsRule, maxYearRule, minAgeRule, minDateRule, minDayRule, minFileSizeRule, minHeightRule, minLengthRule, minMonthRule, minRule, minWidthRule, minWordsRule, minYearRule, moduloRule, monthRule, nanoidRule, negativeRule, notAllowedValuesRule, notContainsRule, notEqualsFieldRule, numberMutator, numberRule, numericMutator, objectRule, objectTrimMutator, oddRule, padEndMutator, padStartMutator, pascalCaseMutator, pastRule, patternRule, plainObjectRule, positiveRule, prependMutator, presentIfEmptyRule, presentIfInRule, presentIfNotEmptyRule, presentIfNotInRule, presentIfRule, presentMethodsApplied, presentRule, presentUnlessRule, presentWithAllRule, presentWithAnyRule, presentWithRule, presentWithoutAllRule, presentWithoutAnyRule, presentWithoutRule, quarterRule, registerPlugin, removeEmptyArrayElementsMutator, removeNumbersMutator, removeSpecialCharactersMutator, repeatMutator, replaceAllMutator, replaceMutator, requiredIfAllEmptyRule, requiredIfAllNotEmptyRule, requiredIfAnyEmptyRule, requiredIfAnyNotEmptyRule, requiredIfEmptyRule, requiredIfInRule, requiredIfNotEmptyRule, requiredIfNotInRule, requiredIfRule, requiredMethodsApplied, requiredRule, requiredUnlessRule, requiredWhenRule, requiredWithAllRule, requiredWithAnyRule, requiredWithRule, requiredWithoutAllRule, requiredWithoutAnyRule, requiredWithoutRule, resetSealConfig, resolveFileSize, resolveTranslation, reverseArrayMutator, reverseMutator, rgbColorRule, rgbaColorRule, roundMutator, roundNumberMutator, rtrimMutator, safeHtmlMutator, sameAsFieldDateRule, scalarRule, setKeyPath, slugMutator, snakeCaseMutator, sortArrayMutator, sortedArrayRule, startsWithRule, stringMutator, stringRule, stringifyMutator, stripTagsMutator, stripUnknownMutator, strongPasswordRule, titleCaseMutator, toDateOnlyMutator, toEndOfDayMutator, toEndOfMonthMutator, toEndOfYearMutator, toFixedMutator, toFormatMutator, toISOStringMutator, toStartOfDayMutator, toStartOfMonthMutator, toStartOfYearMutator, toTimeOnlyMutator, toTimestampMutator, toUTCMutator, todayRule, trimMultipleWhitespaceMutator, trimMutator, truncateMutator, ulidRule, unescapeHtmlMutator, unionRule, uniqueArrayMutator, uniqueArrayRule, unknownKeyRule, unregisterPlugin, uppercaseMutator, urlDecodeMutator, urlEncodeMutator, urlRule, uuidRule, v, validate, weekDayRule, weekdayRule, weekdaysRule, weekendRule, whenRule, withinDaysRule, withinFutureDaysRule, withinPastDaysRule, withoutWhitespaceRule, wordsRule, wrapNullableStrict, yearRule };
|
|
100
|
+
export { AnyValidator, ArrayValidator, AttributeTranslation, BaseValidator, BooleanValidator, ComputedCallback, ComputedValidator, ContextualSchemaRule, ContextualizedMutator, ContextualizedTransformer, DateValidator, DiscriminatedUnionValidator, FileSizeOption, FloatValidator, Infer, InferInput, InferInputObjectShape, InferObjectShape, InferOutput, InferOutputObjectShape, InstanceOfValidator, IntValidator, IsInputOptionalKey, IsOptionalKey, IsOutputOptionalKey, JsonSchemaResult, JsonSchemaTarget, LazyValidator, LiteralValidator, ManagedCallback, ManagedValidator, Month, Mutator, MutatorContext, NumberValidator, NumericValidator, ObjectValidator, PluginContext, PrimitiveValidator, RecordValidator, RuleResult, RuleTranslation, ScalarValidator, Schema, SchemaContext, SchemaRule, SchemaRuleOptions, SealConfig, SealPlugin, SimpleTransformerCallback, StandardJSONSchemaV1, StandardSchemaV1, StringValidator, TransformerCallback, TranslateAttributeCallback, TranslateRuleCallback, TupleValidator, UUIDVersion, UnionValidator, VALID_RULE, ValidateOptions, ValidationAttributesList, ValidationResult, ValidatorV, WEEK_DAYS, WeekDay, WhenRuleOptions, absMutator, addDaysMutator, addHoursMutator, addMonthsMutator, addYearsMutator, afterFieldRule, afterTodayRule, ageRule, allowedValuesRule, alphaNumericRule, alphaOnlyMutator, alphaRule, alphanumericOnlyMutator, appendMutator, applyNullable, arrayRule, base64DecodeMutator, base64EncodeMutator, beforeFieldRule, beforeHourRule, beforeMinuteRule, beforeTodayRule, betweenAgeRule, betweenDatesRule, betweenDaysRule, betweenHoursRule, betweenLengthRule, betweenMinutesRule, betweenMonthsRule, betweenNumbersRule, betweenTimesRule, betweenYearsRule, birthdayRule, booleanMutator, booleanRule, businessDayRule, camelCaseMutator, capitalizeMutator, ceilMutator, colorRule, configureSeal, containsRule, cuidRule, darkColorRule, dateMutator, dateRule, emailRule, endsWithRule, enumRule, equalRule, equalityConditionalMethodsApplied, equalsFieldRule, evenRule, flipArrayMutator, floatRule, floorMutator, forbiddenIfEmptyRule, forbiddenIfInRule, forbiddenIfNotEmptyRule, forbiddenIfNotInRule, forbiddenIfNotRule, forbiddenIfRule, forbiddenMethodsApplied, forbiddenRule, fromHourRule, fromMinuteRule, fromTodayRule, futureRule, getFieldValue, getInstalledPlugins, getRuleOptions, getSealConfig, greaterThanRule, hasPlugin, hexColorRule, hslColorRule, htmlEscapeMutator, humanizeSize, inRule, instanceofRule, intRule, invalidRule, ip4Rule, ip6Rule, ipRule, isCreditCardRule, isDateValue, isIP, isIPv4, isIPv6, isNumericRule, jsonMutator, kebabCaseMutator, leapYearRule, lengthRule, lessThanRule, lightColorRule, literalRule, lowercaseMutator, ltrimMutator, mapToStandardResult, maskMutator, matchesRule, maxAgeRule, maxDateRule, maxDayRule, maxFileSizeRule, maxHeightRule, maxLengthRule, maxMonthRule, maxRule, maxWidthRule, maxWordsRule, maxYearRule, minAgeRule, minDateRule, minDayRule, minFileSizeRule, minHeightRule, minLengthRule, minMonthRule, minRule, minWidthRule, minWordsRule, minYearRule, moduloRule, monthRule, nanoidRule, negativeRule, notAllowedValuesRule, notContainsRule, notEqualsFieldRule, numberMutator, numberRule, numericMutator, objectRule, objectTrimMutator, oddRule, padEndMutator, padStartMutator, pascalCaseMutator, pastRule, patternRule, plainObjectRule, positiveRule, prependMutator, presentIfEmptyRule, presentIfInRule, presentIfNotEmptyRule, presentIfNotInRule, presentIfRule, presentMethodsApplied, presentRule, presentUnlessRule, presentWithAllRule, presentWithAnyRule, presentWithRule, presentWithoutAllRule, presentWithoutAnyRule, presentWithoutRule, quarterRule, registerPlugin, removeEmptyArrayElementsMutator, removeNumbersMutator, removeSpecialCharactersMutator, repeatMutator, replaceAllMutator, replaceMutator, requiredIfAllEmptyRule, requiredIfAllNotEmptyRule, requiredIfAnyEmptyRule, requiredIfAnyNotEmptyRule, requiredIfEmptyRule, requiredIfInRule, requiredIfNotEmptyRule, requiredIfNotInRule, requiredIfRule, requiredMethodsApplied, requiredRule, requiredUnlessRule, requiredWhenRule, requiredWithAllRule, requiredWithAnyRule, requiredWithRule, requiredWithoutAllRule, requiredWithoutAnyRule, requiredWithoutRule, resetSealConfig, resolveFileSize, resolveTranslation, reverseArrayMutator, reverseMutator, rgbColorRule, rgbaColorRule, roundMutator, roundNumberMutator, rtrimMutator, safeHtmlMutator, sameAsFieldDateRule, scalarRule, setKeyPath, slugMutator, snakeCaseMutator, sortArrayMutator, sortedArrayRule, startsWithRule, stringMutator, stringRule, stringifyMutator, stripTagsMutator, stripUnknownMutator, strongPasswordRule, titleCaseMutator, toDateOnlyMutator, toEndOfDayMutator, toEndOfMonthMutator, toEndOfYearMutator, toFixedMutator, toFormatMutator, toISOStringMutator, toStartOfDayMutator, toStartOfMonthMutator, toStartOfYearMutator, toTimeOnlyMutator, toTimestampMutator, toUTCMutator, todayRule, trimMultipleWhitespaceMutator, trimMutator, truncateMutator, ulidRule, unescapeHtmlMutator, unionRule, uniqueArrayMutator, uniqueArrayRule, unknownKeyRule, unregisterPlugin, uppercaseMutator, urlDecodeMutator, urlEncodeMutator, urlRule, uuidRule, v, validate, weekDayRule, weekdayRule, weekdaysRule, weekendRule, whenRule, withinDaysRule, withinFutureDaysRule, withinPastDaysRule, withoutWhitespaceRule, wordsRule, wrapNullableStrict, yearRule };
|
|
101
101
|
import "./validators/methods/equality-conditional-methods.mjs";
|
|
102
102
|
import "./validators/methods/forbidden-methods.mjs";
|
|
103
103
|
import "./validators/methods/present-methods.mjs";
|
package/esm/index.mjs
CHANGED
|
@@ -26,7 +26,7 @@ import { alphaNumericRule, alphaRule, isNumericRule } from "./rules/string/alpha
|
|
|
26
26
|
import { isCreditCardRule } from "./rules/string/credit-card.mjs";
|
|
27
27
|
import { emailRule } from "./rules/string/email.mjs";
|
|
28
28
|
import { cuidRule, nanoidRule, ulidRule, uuidRule } from "./rules/string/id-formats.mjs";
|
|
29
|
-
import { ip4Rule, ip6Rule, ipRule } from "./rules/string/ip.mjs";
|
|
29
|
+
import { ip4Rule, ip6Rule, ipRule, isIP, isIPv4, isIPv6 } from "./rules/string/ip.mjs";
|
|
30
30
|
import { matchesRule } from "./rules/string/matches.mjs";
|
|
31
31
|
import { patternRule } from "./rules/string/pattern.mjs";
|
|
32
32
|
import { containsRule, endsWithRule, notContainsRule, startsWithRule } from "./rules/string/string-comparison.mjs";
|
|
@@ -93,4 +93,4 @@ import { v } from "./factory/validators.mjs";
|
|
|
93
93
|
import "./factory/index.mjs";
|
|
94
94
|
import { getInstalledPlugins, hasPlugin, registerPlugin, unregisterPlugin } from "./plugins/plugin-system.mjs";
|
|
95
95
|
|
|
96
|
-
export { AnyValidator, ArrayValidator, BaseValidator, BooleanValidator, ComputedValidator, DateValidator, DiscriminatedUnionValidator, FloatValidator, InstanceOfValidator, IntValidator, LazyValidator, LiteralValidator, ManagedValidator, NumberValidator, NumericValidator, ObjectValidator, PrimitiveValidator, RecordValidator, ScalarValidator, StringValidator, TupleValidator, UnionValidator, VALID_RULE, WEEK_DAYS, absMutator, addDaysMutator, addHoursMutator, addMonthsMutator, addYearsMutator, afterFieldRule, afterTodayRule, ageRule, allowedValuesRule, alphaNumericRule, alphaOnlyMutator, alphaRule, alphanumericOnlyMutator, appendMutator, applyNullable, arrayRule, base64DecodeMutator, base64EncodeMutator, beforeFieldRule, beforeHourRule, beforeMinuteRule, beforeTodayRule, betweenAgeRule, betweenDatesRule, betweenDaysRule, betweenHoursRule, betweenLengthRule, betweenMinutesRule, betweenMonthsRule, betweenNumbersRule, betweenTimesRule, betweenYearsRule, birthdayRule, booleanMutator, booleanRule, businessDayRule, camelCaseMutator, capitalizeMutator, ceilMutator, colorRule, configureSeal, containsRule, cuidRule, darkColorRule, dateMutator, dateRule, emailRule, endsWithRule, enumRule, equalRule, equalityConditionalMethodsApplied, equalsFieldRule, evenRule, flipArrayMutator, floatRule, floorMutator, forbiddenIfEmptyRule, forbiddenIfInRule, forbiddenIfNotEmptyRule, forbiddenIfNotInRule, forbiddenIfNotRule, forbiddenIfRule, forbiddenMethodsApplied, forbiddenRule, fromHourRule, fromMinuteRule, fromTodayRule, futureRule, getFieldValue, getInstalledPlugins, getRuleOptions, getSealConfig, greaterThanRule, hasPlugin, hexColorRule, hslColorRule, htmlEscapeMutator, humanizeSize, inRule, instanceofRule, intRule, invalidRule, ip4Rule, ip6Rule, ipRule, isCreditCardRule, isDateValue, isNumericRule, jsonMutator, kebabCaseMutator, leapYearRule, lengthRule, lessThanRule, lightColorRule, literalRule, lowercaseMutator, ltrimMutator, mapToStandardResult, maskMutator, matchesRule, maxAgeRule, maxDateRule, maxDayRule, maxFileSizeRule, maxHeightRule, maxLengthRule, maxMonthRule, maxRule, maxWidthRule, maxWordsRule, maxYearRule, minAgeRule, minDateRule, minDayRule, minFileSizeRule, minHeightRule, minLengthRule, minMonthRule, minRule, minWidthRule, minWordsRule, minYearRule, moduloRule, monthRule, nanoidRule, negativeRule, notAllowedValuesRule, notContainsRule, notEqualsFieldRule, numberMutator, numberRule, numericMutator, objectRule, objectTrimMutator, oddRule, padEndMutator, padStartMutator, pascalCaseMutator, pastRule, patternRule, plainObjectRule, positiveRule, prependMutator, presentIfEmptyRule, presentIfInRule, presentIfNotEmptyRule, presentIfNotInRule, presentIfRule, presentMethodsApplied, presentRule, presentUnlessRule, presentWithAllRule, presentWithAnyRule, presentWithRule, presentWithoutAllRule, presentWithoutAnyRule, presentWithoutRule, quarterRule, registerPlugin, removeEmptyArrayElementsMutator, removeNumbersMutator, removeSpecialCharactersMutator, repeatMutator, replaceAllMutator, replaceMutator, requiredIfAllEmptyRule, requiredIfAllNotEmptyRule, requiredIfAnyEmptyRule, requiredIfAnyNotEmptyRule, requiredIfEmptyRule, requiredIfInRule, requiredIfNotEmptyRule, requiredIfNotInRule, requiredIfRule, requiredMethodsApplied, requiredRule, requiredUnlessRule, requiredWhenRule, requiredWithAllRule, requiredWithAnyRule, requiredWithRule, requiredWithoutAllRule, requiredWithoutAnyRule, requiredWithoutRule, resetSealConfig, resolveFileSize, resolveTranslation, reverseArrayMutator, reverseMutator, rgbColorRule, rgbaColorRule, roundMutator, roundNumberMutator, rtrimMutator, safeHtmlMutator, sameAsFieldDateRule, scalarRule, setKeyPath, slugMutator, snakeCaseMutator, sortArrayMutator, sortedArrayRule, startsWithRule, stringMutator, stringRule, stringifyMutator, stripTagsMutator, stripUnknownMutator, strongPasswordRule, titleCaseMutator, toDateOnlyMutator, toEndOfDayMutator, toEndOfMonthMutator, toEndOfYearMutator, toFixedMutator, toFormatMutator, toISOStringMutator, toStartOfDayMutator, toStartOfMonthMutator, toStartOfYearMutator, toTimeOnlyMutator, toTimestampMutator, toUTCMutator, todayRule, trimMultipleWhitespaceMutator, trimMutator, truncateMutator, ulidRule, unescapeHtmlMutator, unionRule, uniqueArrayMutator, uniqueArrayRule, unknownKeyRule, unregisterPlugin, uppercaseMutator, urlDecodeMutator, urlEncodeMutator, urlRule, uuidRule, v, validate, weekDayRule, weekdayRule, weekdaysRule, weekendRule, whenRule, withinDaysRule, withinFutureDaysRule, withinPastDaysRule, withoutWhitespaceRule, wordsRule, wrapNullableStrict, yearRule };
|
|
96
|
+
export { AnyValidator, ArrayValidator, BaseValidator, BooleanValidator, ComputedValidator, DateValidator, DiscriminatedUnionValidator, FloatValidator, InstanceOfValidator, IntValidator, LazyValidator, LiteralValidator, ManagedValidator, NumberValidator, NumericValidator, ObjectValidator, PrimitiveValidator, RecordValidator, ScalarValidator, StringValidator, TupleValidator, UnionValidator, VALID_RULE, WEEK_DAYS, absMutator, addDaysMutator, addHoursMutator, addMonthsMutator, addYearsMutator, afterFieldRule, afterTodayRule, ageRule, allowedValuesRule, alphaNumericRule, alphaOnlyMutator, alphaRule, alphanumericOnlyMutator, appendMutator, applyNullable, arrayRule, base64DecodeMutator, base64EncodeMutator, beforeFieldRule, beforeHourRule, beforeMinuteRule, beforeTodayRule, betweenAgeRule, betweenDatesRule, betweenDaysRule, betweenHoursRule, betweenLengthRule, betweenMinutesRule, betweenMonthsRule, betweenNumbersRule, betweenTimesRule, betweenYearsRule, birthdayRule, booleanMutator, booleanRule, businessDayRule, camelCaseMutator, capitalizeMutator, ceilMutator, colorRule, configureSeal, containsRule, cuidRule, darkColorRule, dateMutator, dateRule, emailRule, endsWithRule, enumRule, equalRule, equalityConditionalMethodsApplied, equalsFieldRule, evenRule, flipArrayMutator, floatRule, floorMutator, forbiddenIfEmptyRule, forbiddenIfInRule, forbiddenIfNotEmptyRule, forbiddenIfNotInRule, forbiddenIfNotRule, forbiddenIfRule, forbiddenMethodsApplied, forbiddenRule, fromHourRule, fromMinuteRule, fromTodayRule, futureRule, getFieldValue, getInstalledPlugins, getRuleOptions, getSealConfig, greaterThanRule, hasPlugin, hexColorRule, hslColorRule, htmlEscapeMutator, humanizeSize, inRule, instanceofRule, intRule, invalidRule, ip4Rule, ip6Rule, ipRule, isCreditCardRule, isDateValue, isIP, isIPv4, isIPv6, isNumericRule, jsonMutator, kebabCaseMutator, leapYearRule, lengthRule, lessThanRule, lightColorRule, literalRule, lowercaseMutator, ltrimMutator, mapToStandardResult, maskMutator, matchesRule, maxAgeRule, maxDateRule, maxDayRule, maxFileSizeRule, maxHeightRule, maxLengthRule, maxMonthRule, maxRule, maxWidthRule, maxWordsRule, maxYearRule, minAgeRule, minDateRule, minDayRule, minFileSizeRule, minHeightRule, minLengthRule, minMonthRule, minRule, minWidthRule, minWordsRule, minYearRule, moduloRule, monthRule, nanoidRule, negativeRule, notAllowedValuesRule, notContainsRule, notEqualsFieldRule, numberMutator, numberRule, numericMutator, objectRule, objectTrimMutator, oddRule, padEndMutator, padStartMutator, pascalCaseMutator, pastRule, patternRule, plainObjectRule, positiveRule, prependMutator, presentIfEmptyRule, presentIfInRule, presentIfNotEmptyRule, presentIfNotInRule, presentIfRule, presentMethodsApplied, presentRule, presentUnlessRule, presentWithAllRule, presentWithAnyRule, presentWithRule, presentWithoutAllRule, presentWithoutAnyRule, presentWithoutRule, quarterRule, registerPlugin, removeEmptyArrayElementsMutator, removeNumbersMutator, removeSpecialCharactersMutator, repeatMutator, replaceAllMutator, replaceMutator, requiredIfAllEmptyRule, requiredIfAllNotEmptyRule, requiredIfAnyEmptyRule, requiredIfAnyNotEmptyRule, requiredIfEmptyRule, requiredIfInRule, requiredIfNotEmptyRule, requiredIfNotInRule, requiredIfRule, requiredMethodsApplied, requiredRule, requiredUnlessRule, requiredWhenRule, requiredWithAllRule, requiredWithAnyRule, requiredWithRule, requiredWithoutAllRule, requiredWithoutAnyRule, requiredWithoutRule, resetSealConfig, resolveFileSize, resolveTranslation, reverseArrayMutator, reverseMutator, rgbColorRule, rgbaColorRule, roundMutator, roundNumberMutator, rtrimMutator, safeHtmlMutator, sameAsFieldDateRule, scalarRule, setKeyPath, slugMutator, snakeCaseMutator, sortArrayMutator, sortedArrayRule, startsWithRule, stringMutator, stringRule, stringifyMutator, stripTagsMutator, stripUnknownMutator, strongPasswordRule, titleCaseMutator, toDateOnlyMutator, toEndOfDayMutator, toEndOfMonthMutator, toEndOfYearMutator, toFixedMutator, toFormatMutator, toISOStringMutator, toStartOfDayMutator, toStartOfMonthMutator, toStartOfYearMutator, toTimeOnlyMutator, toTimestampMutator, toUTCMutator, todayRule, trimMultipleWhitespaceMutator, trimMutator, truncateMutator, ulidRule, unescapeHtmlMutator, unionRule, uniqueArrayMutator, uniqueArrayRule, unknownKeyRule, unregisterPlugin, uppercaseMutator, urlDecodeMutator, urlEncodeMutator, urlRule, uuidRule, v, validate, weekDayRule, weekdayRule, weekdaysRule, weekendRule, whenRule, withinDaysRule, withinFutureDaysRule, withinPastDaysRule, withoutWhitespaceRule, wordsRule, wrapNullableStrict, yearRule };
|
package/esm/rules/index.mjs
CHANGED
|
@@ -8,7 +8,7 @@ import { alphaNumericRule, alphaRule, isNumericRule } from "./string/alpha.mjs";
|
|
|
8
8
|
import { isCreditCardRule } from "./string/credit-card.mjs";
|
|
9
9
|
import { emailRule } from "./string/email.mjs";
|
|
10
10
|
import { cuidRule, nanoidRule, ulidRule, uuidRule } from "./string/id-formats.mjs";
|
|
11
|
-
import { ip4Rule, ip6Rule, ipRule } from "./string/ip.mjs";
|
|
11
|
+
import { ip4Rule, ip6Rule, ipRule, isIP, isIPv4, isIPv6 } from "./string/ip.mjs";
|
|
12
12
|
import { matchesRule } from "./string/matches.mjs";
|
|
13
13
|
import { patternRule } from "./string/pattern.mjs";
|
|
14
14
|
import { containsRule, endsWithRule, notContainsRule, startsWithRule } from "./string/string-comparison.mjs";
|
|
@@ -2,7 +2,7 @@ import { alphaNumericRule, alphaRule, isNumericRule } from "./alpha.mjs";
|
|
|
2
2
|
import { isCreditCardRule } from "./credit-card.mjs";
|
|
3
3
|
import { emailRule } from "./email.mjs";
|
|
4
4
|
import { cuidRule, nanoidRule, ulidRule, uuidRule } from "./id-formats.mjs";
|
|
5
|
-
import { ip4Rule, ip6Rule, ipRule } from "./ip.mjs";
|
|
5
|
+
import { ip4Rule, ip6Rule, ipRule, isIP, isIPv4, isIPv6 } from "./ip.mjs";
|
|
6
6
|
import { matchesRule } from "./matches.mjs";
|
|
7
7
|
import { patternRule } from "./pattern.mjs";
|
|
8
8
|
import { containsRule, endsWithRule, notContainsRule, startsWithRule } from "./string-comparison.mjs";
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import { SchemaRule } from "../../types/rule-types.mjs";
|
|
2
2
|
|
|
3
3
|
//#region ../seal/src/rules/string/ip.d.ts
|
|
4
|
+
declare function isIPv4(value: string): boolean;
|
|
5
|
+
declare function isIPv6(value: string): boolean;
|
|
6
|
+
/**
|
|
7
|
+
* Returns 4 or 6 when `value` is a valid IPv4/IPv6 address, otherwise 0.
|
|
8
|
+
* Signature mirrors Node's `net.isIP` for drop-in behavior parity.
|
|
9
|
+
*/
|
|
10
|
+
declare function isIP(value: string): 0 | 4 | 6;
|
|
4
11
|
/**
|
|
5
12
|
* IP rule - validates IP address (v4 or v6)
|
|
6
13
|
*/
|
|
@@ -14,5 +21,5 @@ declare const ip4Rule: SchemaRule;
|
|
|
14
21
|
*/
|
|
15
22
|
declare const ip6Rule: SchemaRule;
|
|
16
23
|
//#endregion
|
|
17
|
-
export { ip4Rule, ip6Rule, ipRule };
|
|
24
|
+
export { ip4Rule, ip6Rule, ipRule, isIP, isIPv4, isIPv6 };
|
|
18
25
|
//# sourceMappingURL=ip.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ip.d.mts","names":[],"sources":["../../../../../../../../seal/src/rules/string/ip.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"ip.d.mts","names":[],"sources":["../../../../../../../../seal/src/rules/string/ip.ts"],"mappings":";;;iBA0BgB,MAAA,CAAO,KAAa;AAAA,iBAIpB,MAAA,CAAO,KAAa;AAJpC;;;;AAAA,iBAYgB,IAAA,CAAK,KAAa;AARlC;;;AAAA,cAiBa,MAAA,EAAQ,UASpB;AA1BmC;AAQpC;;AARoC,cA+BvB,OAAA,EAAS,UASrB;;AAhCiC;AASlC;cA4Ba,OAAA,EAAS,UASrB"}
|
package/esm/rules/string/ip.mjs
CHANGED
|
@@ -1,9 +1,33 @@
|
|
|
1
1
|
import { VALID_RULE, invalidRule } from "../../helpers/validation-helpers.mjs";
|
|
2
2
|
import "../../helpers/index.mjs";
|
|
3
|
-
import { isIP } from "net";
|
|
4
3
|
|
|
5
4
|
//#region ../seal/src/rules/string/ip.ts
|
|
6
5
|
/**
|
|
6
|
+
* Pure, dependency-free re-implementation of Node's `net.isIP`/`isIPv4`/`isIPv6`.
|
|
7
|
+
* Mirrors the exact regex Node uses internally (lib/internal/net.js) so that
|
|
8
|
+
* behavior stays identical while remaining runnable in the browser (no `net` import).
|
|
9
|
+
*/
|
|
10
|
+
const v4Seg = "(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])";
|
|
11
|
+
const v4Str = `(${v4Seg}[.]){3}${v4Seg}`;
|
|
12
|
+
const IPv4Reg = new RegExp(`^${v4Str}$`);
|
|
13
|
+
const v6Seg = "(?:[0-9a-fA-F]{1,4})";
|
|
14
|
+
const IPv6Reg = new RegExp(`^((?:${v6Seg}:){7}(?:${v6Seg}|:)|(?:${v6Seg}:){6}(?:${v4Str}|:${v6Seg}|:)|(?:${v6Seg}:){5}(?::${v4Str}|(:${v6Seg}){1,2}|:)|(?:${v6Seg}:){4}(?:(:${v6Seg}){0,1}:${v4Str}|(:${v6Seg}){1,3}|:)|(?:${v6Seg}:){3}(?:(:${v6Seg}){0,2}:${v4Str}|(:${v6Seg}){1,4}|:)|(?:${v6Seg}:){2}(?:(:${v6Seg}){0,3}:${v4Str}|(:${v6Seg}){1,5}|:)|(?:${v6Seg}:){1}(?:(:${v6Seg}){0,4}:${v4Str}|(:${v6Seg}){1,6}|:)|(?::((?::${v6Seg}){0,5}:${v4Str}|(?::${v6Seg}){1,7}|:)))(%[0-9a-zA-Z-.:]{1,})?\$`);
|
|
15
|
+
function isIPv4(value) {
|
|
16
|
+
return IPv4Reg.test(value);
|
|
17
|
+
}
|
|
18
|
+
function isIPv6(value) {
|
|
19
|
+
return IPv6Reg.test(value);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Returns 4 or 6 when `value` is a valid IPv4/IPv6 address, otherwise 0.
|
|
23
|
+
* Signature mirrors Node's `net.isIP` for drop-in behavior parity.
|
|
24
|
+
*/
|
|
25
|
+
function isIP(value) {
|
|
26
|
+
if (isIPv4(value)) return 4;
|
|
27
|
+
if (isIPv6(value)) return 6;
|
|
28
|
+
return 0;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
7
31
|
* IP rule - validates IP address (v4 or v6)
|
|
8
32
|
*/
|
|
9
33
|
const ipRule = {
|
|
@@ -38,5 +62,5 @@ const ip6Rule = {
|
|
|
38
62
|
};
|
|
39
63
|
|
|
40
64
|
//#endregion
|
|
41
|
-
export { ip4Rule, ip6Rule, ipRule };
|
|
65
|
+
export { ip4Rule, ip6Rule, ipRule, isIP, isIPv4, isIPv6 };
|
|
42
66
|
//# sourceMappingURL=ip.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ip.mjs","names":[],"sources":["../../../../../../../../seal/src/rules/string/ip.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"ip.mjs","names":[],"sources":["../../../../../../../../seal/src/rules/string/ip.ts"],"sourcesContent":["import { invalidRule, VALID_RULE } from \"../../helpers\";\nimport type { SchemaRule } from \"../../types\";\n\n/**\n * Pure, dependency-free re-implementation of Node's `net.isIP`/`isIPv4`/`isIPv6`.\n * Mirrors the exact regex Node uses internally (lib/internal/net.js) so that\n * behavior stays identical while remaining runnable in the browser (no `net` import).\n */\nconst v4Seg = \"(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\";\nconst v4Str = `(${v4Seg}[.]){3}${v4Seg}`;\nconst IPv4Reg = new RegExp(`^${v4Str}$`);\n\nconst v6Seg = \"(?:[0-9a-fA-F]{1,4})\";\nconst IPv6Reg = new RegExp(\n \"^(\" +\n `(?:${v6Seg}:){7}(?:${v6Seg}|:)|` +\n `(?:${v6Seg}:){6}(?:${v4Str}|:${v6Seg}|:)|` +\n `(?:${v6Seg}:){5}(?::${v4Str}|(:${v6Seg}){1,2}|:)|` +\n `(?:${v6Seg}:){4}(?:(:${v6Seg}){0,1}:${v4Str}|(:${v6Seg}){1,3}|:)|` +\n `(?:${v6Seg}:){3}(?:(:${v6Seg}){0,2}:${v4Str}|(:${v6Seg}){1,4}|:)|` +\n `(?:${v6Seg}:){2}(?:(:${v6Seg}){0,3}:${v4Str}|(:${v6Seg}){1,5}|:)|` +\n `(?:${v6Seg}:){1}(?:(:${v6Seg}){0,4}:${v4Str}|(:${v6Seg}){1,6}|:)|` +\n `(?::((?::${v6Seg}){0,5}:${v4Str}|(?::${v6Seg}){1,7}|:))` +\n \")(%[0-9a-zA-Z-.:]{1,})?$\",\n);\n\nexport function isIPv4(value: string): boolean {\n return IPv4Reg.test(value);\n}\n\nexport function isIPv6(value: string): boolean {\n return IPv6Reg.test(value);\n}\n\n/**\n * Returns 4 or 6 when `value` is a valid IPv4/IPv6 address, otherwise 0.\n * Signature mirrors Node's `net.isIP` for drop-in behavior parity.\n */\nexport function isIP(value: string): 0 | 4 | 6 {\n if (isIPv4(value)) return 4;\n if (isIPv6(value)) return 6;\n return 0;\n}\n\n/**\n * IP rule - validates IP address (v4 or v6)\n */\nexport const ipRule: SchemaRule = {\n name: \"ip\",\n defaultErrorMessage: \"The :input must be a valid IP address\",\n async validate(value: any, context) {\n if (isIP(value)) {\n return VALID_RULE;\n }\n return invalidRule(this, context);\n },\n};\n\n/**\n * IPv4 rule - validates IPv4 address\n */\nexport const ip4Rule: SchemaRule = {\n name: \"ip4\",\n defaultErrorMessage: \"The :input must be a valid IPv4 address\",\n async validate(value: any, context) {\n if (isIP(value) === 4) {\n return VALID_RULE;\n }\n return invalidRule(this, context);\n },\n};\n\n/**\n * IPv6 rule - validates IPv6 address\n */\nexport const ip6Rule: SchemaRule = {\n name: \"ip6\",\n defaultErrorMessage: \"The :input must be a valid IPv6 address\",\n async validate(value: any, context) {\n if (isIP(value) === 6) {\n return VALID_RULE;\n }\n return invalidRule(this, context);\n },\n};\n"],"mappings":";;;;;;;;;AAQA,MAAM,QAAQ;AACd,MAAM,QAAQ,IAAI,MAAM,SAAS;AACjC,MAAM,UAAU,IAAI,OAAO,IAAI,MAAM,EAAE;AAEvC,MAAM,QAAQ;AACd,MAAM,UAAU,IAAI,OAClB,QACQ,MAAM,UAAU,MAAM,SACtB,MAAM,UAAU,MAAM,IAAI,MAAM,SAChC,MAAM,WAAW,MAAM,KAAK,MAAM,eAClC,MAAM,YAAY,MAAM,SAAS,MAAM,KAAK,MAAM,eAClD,MAAM,YAAY,MAAM,SAAS,MAAM,KAAK,MAAM,eAClD,MAAM,YAAY,MAAM,SAAS,MAAM,KAAK,MAAM,eAClD,MAAM,YAAY,MAAM,SAAS,MAAM,KAAK,MAAM,qBAC5C,MAAM,SAAS,MAAM,OAAO,MAAM,oCAElD;AAEA,SAAgB,OAAO,OAAwB;CAC7C,OAAO,QAAQ,KAAK,KAAK;AAC3B;AAEA,SAAgB,OAAO,OAAwB;CAC7C,OAAO,QAAQ,KAAK,KAAK;AAC3B;;;;;AAMA,SAAgB,KAAK,OAA0B;CAC7C,IAAI,OAAO,KAAK,GAAG,OAAO;CAC1B,IAAI,OAAO,KAAK,GAAG,OAAO;CAC1B,OAAO;AACT;;;;AAKA,MAAa,SAAqB;CAChC,MAAM;CACN,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAClC,IAAI,KAAK,KAAK,GACZ,OAAO;EAET,OAAO,YAAY,MAAM,OAAO;CAClC;AACF;;;;AAKA,MAAa,UAAsB;CACjC,MAAM;CACN,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAClC,IAAI,KAAK,KAAK,MAAM,GAClB,OAAO;EAET,OAAO,YAAY,MAAM,OAAO;CAClC;AACF;;;;AAKA,MAAa,UAAsB;CACjC,MAAM;CACN,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAClC,IAAI,KAAK,KAAK,MAAM,GAClB,OAAO;EAET,OAAO,YAAY,MAAM,OAAO;CAClC;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-validator.d.mts","names":[],"sources":["../../../../../../../seal/src/validators/base-validator.ts"],"mappings":";;;;;;;;;;;;cAyBa,aAAA,6BAA0C,MAAA;EAC9C,KAAA,EAAO,oBAAA;EACP,QAAA,EAAU,qBAAA;EAAA,UACP,YAAA;EAAA,UACA,WAAA;EAAA,UACA,UAAA;EAAA,UACA,UAAA;EAAA,UACA,SAAA;EALO;;;;;;;EAAA,UAcP,UAAA,UAEJ,MAAA,EAAQ,gBAAA,YAA4B,aAAA,gBAA6B,OAAA;EAAA,UAC7D,QAAA;EAiKgB;;;;;;;EAxJnB,UAAA;EAoXY;;;;;;;EA3WZ,YAAA,EAAc,oBAAA;EAoZW;;;EAAA,UA/YtB,gBAAA,EAAkB,yBAAA;EAkZjB;;;;;EAAA,UA3YD,cAAA,EAAgB,wBAAA;EAwZlB;;;EAAA,UAnZE,oBAAA,EAAsB,MAAA;EAocP;;;EAAA,IA/bd,OAAA;EAicC;;;EAAA,IAzbD,SAAA;EAieuB;;;;;EAAA,cAvdpB,QAAA;EAmjBoD;;;;EA3iB3D,eAAA;
|
|
1
|
+
{"version":3,"file":"base-validator.d.mts","names":[],"sources":["../../../../../../../seal/src/validators/base-validator.ts"],"mappings":";;;;;;;;;;;;cAyBa,aAAA,6BAA0C,MAAA;EAC9C,KAAA,EAAO,oBAAA;EACP,QAAA,EAAU,qBAAA;EAAA,UACP,YAAA;EAAA,UACA,WAAA;EAAA,UACA,UAAA;EAAA,UACA,UAAA;EAAA,UACA,SAAA;EALO;;;;;;;EAAA,UAcP,UAAA,UAEJ,MAAA,EAAQ,g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AsB,IAAA,EAAM,oBAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBAmDjB,oBAAA,CAAqB,KAAA,CAAM,MAAA,EAAQ,OAAA;;;;;;;;;;;;;;;;;;;;;;;;;;EAyCjD,YAAA,CAAa,OAAA,GAAS,gBAAA,GAAqC,gBAAA;AAAA"}
|
|
@@ -530,9 +530,10 @@ var BaseValidator = class {
|
|
|
530
530
|
let isValid = true;
|
|
531
531
|
const isFirstErrorOnly = context.configurations?.firstErrorOnly ?? true;
|
|
532
532
|
const isEmpty = isEmptyValue(valueForRules);
|
|
533
|
+
const skipEmptyRules = this.isOptional ? valueForRules === void 0 : isEmpty;
|
|
533
534
|
const rulesToRun = this.requiredRule ? [this.requiredRule, ...this.rules] : this.rules;
|
|
534
535
|
for (const rule of rulesToRun) {
|
|
535
|
-
if ((rule.requiresValue ?? true) &&
|
|
536
|
+
if ((rule.requiresValue ?? true) && skipEmptyRules) continue;
|
|
536
537
|
this.setRuleAttributesList(rule);
|
|
537
538
|
const result = await rule.validate(mutatedData, context);
|
|
538
539
|
if (result.isValid === false) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-validator.mjs","names":["defaultRequiredRule"],"sources":["../../../../../../../seal/src/validators/base-validator.ts"],"sourcesContent":["import { clone } from \"@mongez/reinforcements\";\nimport { validate } from \"../factory/validate\";\nimport { VALID_RULE, invalidRule } from \"../helpers\";\nimport { isEmptyValue } from \"../helpers/is-empty-value\";\nimport { requiredRule as defaultRequiredRule } from \"../rules/core/required\";\nimport type { JsonSchemaResult, JsonSchemaTarget } from \"../standard-schema/json-schema\";\nimport { mapToStandardResult } from \"../standard-schema/map-result\";\nimport type { StandardJSONSchemaV1, StandardSchemaV1 } from \"../standard-schema/types\";\nimport type {\n ContextualSchemaRule,\n ContextualizedMutator,\n ContextualizedTransformer,\n Mutator,\n SchemaContext,\n SchemaRule,\n SchemaRuleOptions,\n SimpleTransformerCallback,\n TransformerCallback,\n ValidationAttributesList,\n ValidationResult,\n} from \"../types\";\n\n/**\n * Base validator class - foundation for all validators\n */\nexport class BaseValidator<TInput = unknown, TOutput = TInput> {\n public rules: ContextualSchemaRule[] = [];\n public mutators: ContextualizedMutator[] = [];\n protected defaultValue: any | (() => any);\n protected description?: string;\n protected shouldOmit = false;\n protected isNullable = false;\n protected isMutable = false;\n\n /**\n * Catch state — when `hasCatch` is true and validation fails, `catchValue`\n * (or its callback result) substitutes for the failed value, and the public\n * result reports `isValid: true` with no errors.\n *\n * See `.catch()` for semantics and the v1 scope (leaf-only).\n */\n protected catchValue:\n | any\n | ((errors: ValidationResult[\"errors\"], originalInput: any) => any | Promise<any>);\n protected hasCatch = false;\n\n /**\n * Whether the field is optional.\n * - false (default): field is required unless a requiredRule governs the condition.\n * - true: field can be absent or empty — set by calling .optional().\n *\n * Also used as a TypeScript literal brand via the optional() return type.\n */\n public isOptional = false;\n\n /**\n * The single required-condition rule for this field.\n * - null: field uses strict default (always required when not optional).\n * - set: the rule governs when the field is required (e.g., requiredIf).\n *\n * Stored separately from rules[] and prepended at validate() time.\n */\n public requiredRule: ContextualSchemaRule | null = this.createRule(defaultRequiredRule);\n\n /**\n * Pipeline to transform the mutated/original data before returning it\n */\n protected dataTransformers: ContextualizedTransformer[] = [];\n\n /**\n * Attributes text to be replaced on translations\n * If the value is an object, it will be used as the attributes list for the rule\n * If the value is a string, it will be used as the attributes list for the rule\n */\n protected attributesText: ValidationAttributesList = {};\n\n /**\n * Attributed that will be always using the attribute translator\n */\n protected translatedAttributes: Record<string, string> = {};\n\n /**\n * Mark the validator as mutable\n */\n public get mutable() {\n this.isMutable = true;\n return this;\n }\n\n /**\n * Mark the validator as immutable\n */\n public get immutable() {\n this.isMutable = false;\n return this;\n }\n\n /**\n * Get the instance to apply changes to.\n * By default (immutable), returns a clone so the original is unchanged.\n * When `.mutable` is set, returns `this` to mutate in place.\n */\n protected get instance(): this {\n return this.isMutable ? this : this.clone();\n }\n\n /**\n * Get the default value\n * Supports lazy evaluation via callbacks\n */\n public getDefaultValue(): any {\n return typeof this.defaultValue === \"function\" ? this.defaultValue() : this.defaultValue;\n }\n\n /**\n * Allow null as a valid value.\n *\n * Brands the return type with `{ isNullable: true }` so `Infer<>` widens\n * the inferred output to include `| null`.\n */\n public nullable(): this & { isNullable: true } {\n const instance = this.instance;\n instance.isNullable = true;\n return instance as this & { isNullable: true };\n }\n\n /**\n * Explicitly disallow null values after calling nullable.\n *\n * Brands the return type with `{ isNullable: false }` to cancel any prior\n * `.nullable()` at the type level.\n */\n public notNullable(): this & { isNullable: false } {\n const instance = this.instance;\n instance.isNullable = false;\n return instance as this & { isNullable: false };\n }\n\n /**\n * Add transformer with optional options\n *\n * @param transform - The transformer callback function\n * @param options - Optional options to pass to the transformer\n *\n * @example\n * ```ts\n * // Without options\n * v.date().addTransformer(data => data.toISOString())\n *\n * // With options\n * v.date().addTransformer(\n * (data, { options }) => dayjs(data).format(options.format),\n * { format: 'YYYY-MM-DD' }\n * )\n * ```\n */\n public addTransformer(transform: TransformerCallback, options: any = {}) {\n const instance = this.instance;\n instance.addMutableTransformer(transform, options);\n\n return instance;\n }\n\n /**\n * Add transformer with optional options\n *\n * @param transform - The transformer callback function\n * @param options - Optional options to pass to the transformer\n *\n * @example\n * ```ts\n * // Without options\n * v.date().addTransformer(data => data.toISOString())\n *\n * // With options\n * v.date().addTransformer(\n * (data, { options }) => dayjs(data).format(options.format),\n * { format: 'YYYY-MM-DD' }\n * )\n * ```\n */\n public addMutableTransformer(transform: TransformerCallback, options: any = {}) {\n this.dataTransformers.push({\n transform,\n options,\n });\n }\n\n /**\n * Transform the output value - simple one-time transformation\n *\n * @param callback - Simple callback receiving data and context\n *\n * @example\n * ```ts\n * // Simple transformation\n * v.string().outputAs(data => data.toUpperCase())\n *\n * // With context\n * v.string().outputAs((data, context) => {\n * console.log(`Transforming ${context.path}`);\n * return data.toLowerCase();\n * })\n * ```\n */\n public outputAs(callback: SimpleTransformerCallback) {\n return this.addTransformer((data, { context }) => callback(data, context));\n }\n\n /**\n * Transform output to JSON string\n *\n * Works with any validator type (string, number, date, object, array, etc.)\n *\n * @param indent - Optional indentation for pretty printing (default: 0 for compact)\n *\n * @example\n * ```ts\n * // Compact JSON\n * v.object({ name: v.string() }).toJSON()\n * // Output: '{\"name\":\"John\"}'\n *\n * // Pretty-printed JSON\n * v.array(v.object({...})).toJSON(2)\n * // Output:\n * // [\n * // {\n * // \"name\": \"John\"\n * // }\n * // ]\n *\n * // Works with any type\n * v.string().toJSON() // '\"hello\"'\n * v.number().toJSON() // '42'\n * v.date().toJSON() // '\"2024-10-26T00:00:00.000Z\"'\n * ```\n *\n * @category Transformer\n */\n public toJSON(indent?: number) {\n return this.addTransformer((data, { options }) => JSON.stringify(data, null, options.indent), {\n indent: indent ?? 0,\n });\n }\n\n /**\n * Start data transformation pipeline\n * Context is passed at runtime, not stored\n */\n public async startTransformationPipeline(data: any, context: SchemaContext) {\n for (const transformer of this.dataTransformers) {\n data = await transformer.transform(data, {\n options: transformer.options,\n context,\n });\n }\n\n return data;\n }\n\n /**\n * Set attributes text to be replaced on translations\n * If the value is an object, it will be used as the attributes list for the rule\n * If the value is a string, it will be used as the attributes list for the rule\n *\n * @example\n * v.string().attributes({\n * name: \"Name\",\n * email: \"Email\",\n * });\n * // Example 2: Add custom attributes for matches\n * v.string().matches(\"confirmPassword\").attributes({\n * matches: {\n * confirmPassword: \"Confirm Password\",\n * },\n * });\n */\n public attributes(attributes: Record<string, string | Record<string, string>>) {\n const instance = this.instance;\n for (const key in attributes) {\n instance.attributesText[key] = attributes[key];\n }\n\n return instance;\n }\n\n /**\n * Define a lazy getter property for each attribute in the given object and use the config attribute translator\n */\n public transAttributes(attributes: Record<string, string>) {\n const instance = this.instance;\n for (const key in attributes) {\n instance.translatedAttributes[key] = attributes[key];\n }\n\n return instance;\n }\n\n /**\n * Add description to the validator\n */\n public describe(description: string) {\n const instance = this.instance;\n instance.description = description;\n return instance;\n }\n\n /**\n * Check if this validator can handle the given value's type\n * Override this in specific validators to enable type-based routing in union validators\n *\n * Default: returns true (validator will attempt to validate any type)\n *\n * @param value - The value to check\n * @returns True if this validator can handle this type\n *\n * @example\n * ```ts\n * // StringValidator\n * public matchesType(value: any): boolean {\n * return typeof value === 'string';\n * }\n *\n * // Custom FileValidator\n * public matchesType(value: any): boolean {\n * return value instanceof UploadedFile;\n * }\n * ```\n */\n public matchesType(_value: any): boolean {\n return true; // Default: permissive, attempt to validate any type\n }\n\n /**\n * Create a copy of this validator with the same configuration\n * Copies all rules, mutators, transformers, default values, and settings\n *\n * @returns A new validator instance with copied configuration\n *\n * @example\n * ```ts\n * // Create reusable validator templates\n * const baseString = v.string().required().trim().min(3);\n * const emailField = baseString.clone().email();\n * const usernameField = baseString.clone().alphanumeric().max(20);\n *\n * // Works with all validators\n * const positiveInt = v.int().positive().required();\n * const ageField = positiveInt.clone().min(18).max(120);\n * ```\n */\n public clone(): this {\n // Create a new instance using Object.create to preserve the prototype chain\n const Constructor = this.constructor as new (...args: any[]) => this;\n const cloned = Object.create(Constructor.prototype);\n\n // Copy all BaseValidator properties\n cloned.rules = [...this.rules];\n cloned.mutators = [...this.mutators];\n cloned.dataTransformers = [...this.dataTransformers];\n cloned.defaultValue = this.defaultValue;\n cloned.shouldOmit = this.shouldOmit;\n cloned.description = this.description;\n cloned.attributesText = { ...this.attributesText };\n cloned.isNullable = this.isNullable;\n cloned.isOptional = this.isOptional;\n cloned.requiredRule = this.requiredRule; // same reference is fine — rule is treated as immutable\n cloned.catchValue = this.catchValue;\n cloned.hasCatch = this.hasCatch;\n\n return cloned;\n }\n\n /**\n * @deprecated This method is no longer needed and does nothing.\n * Empty values are now automatically skipped for validation rules by default.\n * Only presence validators (required, present, etc.) will check empty values.\n * You can safely remove this call from your code.\n */\n public ignoreEmptyValue(_ignoreEmptyValue = true) {\n // No-op for backward compatibility\n return this;\n }\n\n /**\n * Omit this field from the validated data output\n *\n * Field will still be validated but not included in the final result.\n * Useful for confirmation fields, captcha, terms acceptance, etc.\n *\n * @example\n * ```ts\n * v.object({\n * password: v.string().required(),\n * confirmPassword: v.string().required().sameAs(\"password\").omit(),\n * acceptTerms: v.boolean().required().omit(),\n * });\n * // Output: { password: \"...\" }\n * // confirmPassword and acceptTerms validated but omitted\n * ```\n */\n public omit() {\n const instance = this.instance;\n instance.shouldOmit = true;\n return instance;\n }\n\n /**\n * @alias omit\n */\n public exclude() {\n return this.omit();\n }\n\n /**\n * Check if this field should be omitted from the output\n */\n public isOmitted(): boolean {\n return this.shouldOmit;\n }\n\n /**\n * Add rule to the validator\n */\n public addRule<T extends SchemaRuleOptions = SchemaRuleOptions>(\n rule: SchemaRule<T>,\n errorMessage?: string,\n options: T = {} as T,\n ): this {\n const instance = this.instance;\n instance.addMutableRule(rule, errorMessage, options);\n return instance;\n }\n\n /**\n * Set the required-condition rule for this field.\n *\n * Unlike addRule(), this does NOT push to rules[]. The rule is stored in the\n * dedicated `requiredRule` slot and is prepended to the validation pipeline\n * at runtime. Only one required rule can be active per field — this replaces\n * any previously set required rule.\n *\n * Also marks the field as not optional (isOptional = false).\n *\n * @example\n * ```ts\n * // Used internally by required(), requiredIf(), requiredWith(), etc.\n * BaseValidator.prototype.required = function(msg) {\n * return this.setRequiredRule(requiredRule, msg);\n * };\n * ```\n */\n public setRequiredRule<T extends SchemaRuleOptions = SchemaRuleOptions>(\n rule: SchemaRule<T>,\n errorMessage?: string,\n options: T = {} as T,\n ): this {\n const instance = this.instance;\n instance.isOptional = false;\n instance.requiredRule = instance.createRule(rule, errorMessage, options);\n return instance;\n }\n\n /**\n * Add mutable rule\n */\n public addMutableRule<T extends SchemaRuleOptions = SchemaRuleOptions>(\n rule: SchemaRule<T>,\n errorMessage?: string,\n options: T = {} as T,\n ): ContextualSchemaRule<T> {\n const newRule: ContextualSchemaRule<T> = this.createRule(rule, errorMessage, options);\n\n this.rules.push(newRule);\n\n return newRule;\n }\n\n /**\n * Create new rule\n */\n protected createRule<T extends SchemaRuleOptions = SchemaRuleOptions>(\n rule: SchemaRule<T>,\n errorMessage?: string,\n options: T = {} as T,\n ): ContextualSchemaRule<T> {\n const newRule: ContextualSchemaRule<T> = {\n ...(clone(rule) as ContextualSchemaRule<T>),\n context: {\n errorMessage,\n options,\n attributesList: this.attributesText,\n translatedAttributes: this.translatedAttributes,\n translationParams: {},\n translatableParams: {},\n },\n };\n\n if (errorMessage) {\n newRule.errorMessage = errorMessage;\n }\n\n if (rule.sortOrder === undefined) {\n newRule.sortOrder = this.rules.length + 1;\n }\n\n return newRule;\n }\n\n /**\n * Use a custom or pre-built validation rule\n *\n * @param rule - The validation rule to apply\n * @param options - Rule options including errorMessage and any rule-specific options\n *\n * @example\n * ```ts\n * import { hexColorRule } from \"@warlock.js/seal\";\n *\n * v.string().useRule(hexColorRule, { errorMessage: \"Invalid color\" });\n * ```\n *\n * @example\n * ```ts\n * // With rule options\n * v.string().useRule(myCustomRule, {\n * customOption: true,\n * errorMessage: \"Custom validation failed\"\n * });\n * ```\n */\n public useRule<T extends SchemaRuleOptions = SchemaRuleOptions>(\n rule: SchemaRule<T>,\n options?: T & { errorMessage?: string },\n ) {\n const { errorMessage, ...ruleOptions } = options || ({} as any);\n return this.addRule(rule, errorMessage, ruleOptions);\n }\n\n /**\n * Define custom rule\n */\n public refine(\n callback: (\n value: any,\n context: SchemaContext,\n ) => Promise<string | undefined> | string | undefined,\n ) {\n return this.addRule({\n name: \"custom\",\n async validate(value, context) {\n const result = await callback(value, context);\n if (result) {\n this.context.errorMessage = result;\n return invalidRule(this, context);\n }\n return VALID_RULE;\n },\n });\n }\n\n /**\n * Add mutator to the validator\n */\n public addMutator(mutator: Mutator, options: any = {}) {\n const instance = this.instance;\n instance.addMutableMutator(mutator, options);\n return instance;\n }\n\n /**\n * Add mutable mutator\n */\n public addMutableMutator(mutator: Mutator, options: any = {}) {\n this.mutators.push({\n mutate: mutator,\n context: {\n options,\n ctx: {} as any,\n },\n });\n }\n\n /**\n * Set default value for the field. The default is used when the input is\n * absent (`undefined`); it then flows through the rule pipeline.\n *\n * Brands the return type with `{ hasDefault: true }` so `Infer<>` treats\n * the field as guaranteed-present even when chained with `.optional()`.\n */\n public default(value: any): this & { hasDefault: true } {\n const instance = this.instance;\n instance.defaultValue = value;\n return instance as this & { hasDefault: true };\n }\n\n /**\n * Fallback to a value when validation fails.\n *\n * Complementary to `.default()`: `.default(x)` fires when input is **absent**,\n * `.catch(y)` fires when input is **present but invalid**. Combine them when\n * you want both behaviours: `.optional().default(x).catch(y)`.\n *\n * The fallback can be a value or a callback `(errors, originalInput) => fallback`.\n * The callback variant is the only side-channel for the swallowed errors —\n * use it to log/alert before the fallback substitutes.\n *\n * Brands the return type with `{ hasCatch: true }` so `Infer<>` treats the\n * field as guaranteed-present (the catch ensures a value will always exist).\n *\n * **Scope (v1).** Catch is honoured for **leaf validators** (string, number,\n * boolean, date, …) and for fields inside containers. It is a **no-op on\n * container validators themselves** (`v.object`, `v.array`, `v.record`,\n * `v.tuple`, `v.discriminatedUnion`) — those use their own iteration logic\n * that bypasses the catch hook in `BaseValidator.validate()`.\n *\n * @example\n * ```ts\n * v.int().min(0).catch(3) // bad number → 3\n * v.string().in([\"us\", \"eu\"]).catch(\"us\") // unknown enum → \"us\"\n * v.string().catch((errors, input) => {\n * console.warn(`bad user value: ${JSON.stringify(input)}`, errors);\n * return \"anonymous\";\n * })\n * ```\n */\n public catch(\n fallback:\n | any\n | ((errors: ValidationResult[\"errors\"], originalInput: any) => any | Promise<any>),\n ): this & { hasCatch: true } {\n const instance = this.instance;\n\n instance.catchValue = fallback;\n instance.hasCatch = true;\n\n return instance as this & { hasCatch: true };\n }\n\n /**\n * Mutate the data\n */\n public async mutate(data: any, context: SchemaContext) {\n let mutatedData = data;\n\n for (const mutator of this.mutators) {\n mutator.context.ctx = context;\n mutatedData = await mutator.mutate(mutatedData, mutator.context);\n }\n\n return mutatedData;\n }\n\n /**\n * Set the label for the validator that will be matching the :input attribute\n */\n public label(label: string) {\n const instance = this.instance;\n instance.attributesText.input = label;\n return instance;\n }\n\n /**\n * Validate the data\n */\n public async validate(data: any, context: SchemaContext): Promise<ValidationResult> {\n if (data === null && this.isNullable) {\n return { isValid: true, errors: [], data: null };\n }\n\n const valueForRules = data ?? this.getDefaultValue();\n const mutatedData = await this.mutate(valueForRules, context);\n\n const errors: ValidationResult[\"errors\"] = [];\n let isValid = true;\n const isFirstErrorOnly = context.configurations?.firstErrorOnly ?? true;\n\n const isEmpty = isEmptyValue(valueForRules);\n\n // Prepend the required-condition rule if set, so it always runs first.\n // requiredRule has requiresValue = false so it runs even on empty values.\n const rulesToRun = this.requiredRule ? [this.requiredRule, ...this.rules] : this.rules;\n\n for (const rule of rulesToRun) {\n if ((rule.requiresValue ?? true) && isEmpty) continue;\n\n this.setRuleAttributesList(rule);\n\n const result = await rule.validate(mutatedData, context);\n\n if (result.isValid === false) {\n isValid = false;\n errors.push({\n type: rule.name,\n error: result.error,\n input: result.path ?? context.path,\n });\n\n if (isFirstErrorOnly) {\n break;\n }\n }\n }\n\n const result: ValidationResult = {\n isValid,\n errors,\n data:\n mutatedData !== undefined\n ? await this.startTransformationPipeline(mutatedData, context)\n : undefined,\n };\n\n // Catch fallback — only on the leaf path. Container validators override\n // validate() and don't run this hook on their own outcome, so catching\n // a whole object/array/record is a no-op in v1.\n if (result.isValid === false && this.hasCatch) {\n const fallback =\n typeof this.catchValue === \"function\"\n ? await this.catchValue(result.errors, data)\n : this.catchValue;\n\n return { isValid: true, errors: [], data: fallback };\n }\n\n return result;\n }\n\n /**\n * Set rule attributes list\n */\n protected setRuleAttributesList(rule: ContextualSchemaRule) {\n rule.context.attributesList =\n typeof this.attributesText[rule.name] === \"object\"\n ? (this.attributesText[rule.name] as ValidationAttributesList)\n : this.attributesText;\n }\n\n /**\n * Standard Schema V1 compliance.\n *\n * Allows this validator to be used with any Standard Schema-aware library\n * (OpenAI structured outputs, LangGraph, TanStack Form, Conform, Valibot adapters, etc.)\n * without extra adapters.\n *\n * Delegates to the `validate()` factory so all `configureSeal()` options\n * (translations, firstErrorOnly) are picked up automatically at call time.\n *\n * Includes Standard JSON Schema support via `jsonSchema.input()` / `jsonSchema.output()`.\n *\n * ## How Standard Schema libraries consume this\n *\n * You pass the **schema object itself** to the library — they internally read\n * `schema[\"~standard\"]`. Do NOT pass `schema[\"~standard\"]` directly.\n *\n * @example\n * ```ts\n * const schema = v.object({ name: v.string().required() });\n *\n * // TanStack Form — pass schema, library reads [\"~standard\"] internally\n * const form = useForm({ validators: { onChange: schema } });\n *\n * // Conform (Remix) — same pattern\n * const [form] = useForm({ onValidate({ formData }) {\n * return parseWithStandardSchema(formData, { schema });\n * }});\n *\n * // Direct validation (lower level — most apps don't need this)\n * const result = await schema[\"~standard\"].validate({ name: \"Hasan\" });\n * // → { value: { name: \"Hasan\" } } on success\n * // → { issues: [{ message: \"...\", path: [{ key: \"name\" }] }] } on failure\n *\n * // JSON Schema for OpenAI / LangChain tool calling\n * const parameters = schema[\"~standard\"].jsonSchema.input({ target: \"openai-strict\" });\n * // → { type: \"object\", properties: {...}, required: [...], additionalProperties: false }\n * ```\n *\n * @note Cross-field rules (sameAs, requiredIf, requiredWith) rely on sibling values\n * available in the full validation context. When called on a standalone scalar validator,\n * sibling data is absent and those rules will not evaluate correctly.\n * Always call on the parent ObjectValidator for full-payload validation.\n */\n get [\"~standard\"](): StandardJSONSchemaV1.Props<TInput, TOutput> {\n return {\n version: 1,\n vendor: \"seal\",\n types: undefined as unknown as StandardSchemaV1.Types<TInput, TOutput>,\n validate: async (value: unknown) => {\n const result = await validate(this, value);\n return mapToStandardResult(result) as StandardSchemaV1.Result<TOutput>;\n },\n jsonSchema: {\n input: (options) => this.toJsonSchema(options.target),\n output: (options) => this.toJsonSchema(options.target),\n },\n };\n }\n\n /**\n * Generate a JSON Schema representation of this validator.\n *\n * Supports targets: `\"draft-2020-12\"` (default), `\"draft-07\"`, `\"openapi-3.0\"`.\n *\n * Subclasses override this to describe their specific constraints.\n * The base implementation returns `{}` (permissive — accepts anything),\n * which is correct for validators with no representable JSON Schema constraints.\n *\n * @note Rules that cannot be expressed in JSON Schema are silently omitted:\n * - Cross-field rules: sameAs, requiredIf, requiredWith, requiredWithout\n * - Custom callbacks: refine()\n * - Framework-specific runtime rules (core/cascade plugins)\n * These rules still run normally at validation time — only absent from JSON Schema.\n *\n * @example\n * ```ts\n * v.string().min(3).max(50).toJsonSchema(\"draft-2020-12\")\n * // → { type: \"string\", minLength: 3, maxLength: 50 }\n *\n * v.object({ name: v.string().required(), age: v.int().optional() })\n * .toJsonSchema(\"draft-07\")\n * // → { type: \"object\", properties: { name: { type: \"string\" }, age: { type: \"integer\" } }, required: [\"name\"] }\n * ```\n */\n public toJsonSchema(_target: JsonSchemaTarget = \"draft-2020-12\"): JsonSchemaResult {\n return {};\n }\n}\n"],"mappings":";;;;;;;;;;;;AAyBA,IAAa,gBAAb,MAA+D;;eACtB,CAAC;kBACG,CAAC;oBAGrB;oBACA;mBACD;kBAYD;oBASD;sBAS+B,KAAK,WAAWA,YAAmB;0BAK5B,CAAC;wBAON,CAAC;8BAKG,CAAC;;;;;CAK1D,IAAW,UAAU;EACnB,KAAK,YAAY;EACjB,OAAO;CACT;;;;CAKA,IAAW,YAAY;EACrB,KAAK,YAAY;EACjB,OAAO;CACT;;;;;;CAOA,IAAc,WAAiB;EAC7B,OAAO,KAAK,YAAY,OAAO,KAAK,MAAM;CAC5C;;;;;CAMA,AAAO,kBAAuB;EAC5B,OAAO,OAAO,KAAK,iBAAiB,aAAa,KAAK,aAAa,IAAI,KAAK;CAC9E;;;;;;;CAQA,AAAO,WAAwC;EAC7C,MAAM,WAAW,KAAK;EACtB,SAAS,aAAa;EACtB,OAAO;CACT;;;;;;;CAQA,AAAO,cAA4C;EACjD,MAAM,WAAW,KAAK;EACtB,SAAS,aAAa;EACtB,OAAO;CACT;;;;;;;;;;;;;;;;;;;CAoBA,AAAO,eAAe,WAAgC,UAAe,CAAC,GAAG;EACvE,MAAM,WAAW,KAAK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ACb;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8CA,KAAK,eAA4D;EAC/D,OAAO;GACL,SAAS;GACT,QAAQ;GACR,OAAO;GACP,UAAU,OAAO,UAAmB;IAElC,OAAO,oBAAoB,MADN,SAAS,MAAM,KAAK,CACR;GACnC;GACA,YAAY;IACV,QAAQ,YAAY,KAAK,aAAa,QAAQ,MAAM;IACpD,SAAS,YAAY,KAAK,aAAa,QAAQ,MAAM;GACvD;EACF;CACF;;;;;;;;;;;;;;;;;;;;;;;;;;CA2BA,AAAO,aAAa,UAA4B,iBAAmC;EACjF,OAAO,CAAC;CACV;AACF"}
|
|
1
|
+
{"version":3,"file":"base-validator.mjs","names":["defaultRequiredRule"],"sources":["../../../../../../../seal/src/validators/base-validator.ts"],"sourcesContent":["import { clone } from \"@mongez/reinforcements\";\nimport { validate } from \"../factory/validate\";\nimport { VALID_RULE, invalidRule } from \"../helpers\";\nimport { isEmptyValue } from \"../helpers/is-empty-value\";\nimport { requiredRule as defaultRequiredRule } from \"../rules/core/required\";\nimport type { JsonSchemaResult, JsonSchemaTarget } from \"../standard-schema/json-schema\";\nimport { mapToStandardResult } from \"../standard-schema/map-result\";\nimport type { StandardJSONSchemaV1, StandardSchemaV1 } from \"../standard-schema/types\";\nimport type {\n ContextualSchemaRule,\n ContextualizedMutator,\n ContextualizedTransformer,\n Mutator,\n SchemaContext,\n SchemaRule,\n SchemaRuleOptions,\n SimpleTransformerCallback,\n TransformerCallback,\n ValidationAttributesList,\n ValidationResult,\n} from \"../types\";\n\n/**\n * Base validator class - foundation for all validators\n */\nexport class BaseValidator<TInput = unknown, TOutput = TInput> {\n public rules: ContextualSchemaRule[] = [];\n public mutators: ContextualizedMutator[] = [];\n protected defaultValue: any | (() => any);\n protected description?: string;\n protected shouldOmit = false;\n protected isNullable = false;\n protected isMutable = false;\n\n /**\n * Catch state — when `hasCatch` is true and validation fails, `catchValue`\n * (or its callback result) substitutes for the failed value, and the public\n * result reports `isValid: true` with no errors.\n *\n * See `.catch()` for semantics and the v1 scope (leaf-only).\n */\n protected catchValue:\n | any\n | ((errors: ValidationResult[\"errors\"], originalInput: any) => any | Promise<any>);\n protected hasCatch = false;\n\n /**\n * Whether the field is optional.\n * - false (default): field is required unless a requiredRule governs the condition.\n * - true: field can be absent or empty — set by calling .optional().\n *\n * Also used as a TypeScript literal brand via the optional() return type.\n */\n public isOptional = false;\n\n /**\n * The single required-condition rule for this field.\n * - null: field uses strict default (always required when not optional).\n * - set: the rule governs when the field is required (e.g., requiredIf).\n *\n * Stored separately from rules[] and prepended at validate() time.\n */\n public requiredRule: ContextualSchemaRule | null = this.createRule(defaultRequiredRule);\n\n /**\n * Pipeline to transform the mutated/original data before returning it\n */\n protected dataTransformers: ContextualizedTransformer[] = [];\n\n /**\n * Attributes text to be replaced on translations\n * If the value is an object, it will be used as the attributes list for the rule\n * If the value is a string, it will be used as the attributes list for the rule\n */\n protected attributesText: ValidationAttributesList = {};\n\n /**\n * Attributed that will be always using the attribute translator\n */\n protected translatedAttributes: Record<string, string> = {};\n\n /**\n * Mark the validator as mutable\n */\n public get mutable() {\n this.isMutable = true;\n return this;\n }\n\n /**\n * Mark the validator as immutable\n */\n public get immutable() {\n this.isMutable = false;\n return this;\n }\n\n /**\n * Get the instance to apply changes to.\n * By default (immutable), returns a clone so the original is unchanged.\n * When `.mutable` is set, returns `this` to mutate in place.\n */\n protected get instance(): this {\n return this.isMutable ? this : this.clone();\n }\n\n /**\n * Get the default value\n * Supports lazy evaluation via callbacks\n */\n public getDefaultValue(): any {\n return typeof this.defaultValue === \"function\" ? this.defaultValue() : this.defaultValue;\n }\n\n /**\n * Allow null as a valid value.\n *\n * Brands the return type with `{ isNullable: true }` so `Infer<>` widens\n * the inferred output to include `| null`.\n */\n public nullable(): this & { isNullable: true } {\n const instance = this.instance;\n instance.isNullable = true;\n return instance as this & { isNullable: true };\n }\n\n /**\n * Explicitly disallow null values after calling nullable.\n *\n * Brands the return type with `{ isNullable: false }` to cancel any prior\n * `.nullable()` at the type level.\n */\n public notNullable(): this & { isNullable: false } {\n const instance = this.instance;\n instance.isNullable = false;\n return instance as this & { isNullable: false };\n }\n\n /**\n * Add transformer with optional options\n *\n * @param transform - The transformer callback function\n * @param options - Optional options to pass to the transformer\n *\n * @example\n * ```ts\n * // Without options\n * v.date().addTransformer(data => data.toISOString())\n *\n * // With options\n * v.date().addTransformer(\n * (data, { options }) => dayjs(data).format(options.format),\n * { format: 'YYYY-MM-DD' }\n * )\n * ```\n */\n public addTransformer(transform: TransformerCallback, options: any = {}) {\n const instance = this.instance;\n instance.addMutableTransformer(transform, options);\n\n return instance;\n }\n\n /**\n * Add transformer with optional options\n *\n * @param transform - The transformer callback function\n * @param options - Optional options to pass to the transformer\n *\n * @example\n * ```ts\n * // Without options\n * v.date().addTransformer(data => data.toISOString())\n *\n * // With options\n * v.date().addTransformer(\n * (data, { options }) => dayjs(data).format(options.format),\n * { format: 'YYYY-MM-DD' }\n * )\n * ```\n */\n public addMutableTransformer(transform: TransformerCallback, options: any = {}) {\n this.dataTransformers.push({\n transform,\n options,\n });\n }\n\n /**\n * Transform the output value - simple one-time transformation\n *\n * @param callback - Simple callback receiving data and context\n *\n * @example\n * ```ts\n * // Simple transformation\n * v.string().outputAs(data => data.toUpperCase())\n *\n * // With context\n * v.string().outputAs((data, context) => {\n * console.log(`Transforming ${context.path}`);\n * return data.toLowerCase();\n * })\n * ```\n */\n public outputAs(callback: SimpleTransformerCallback) {\n return this.addTransformer((data, { context }) => callback(data, context));\n }\n\n /**\n * Transform output to JSON string\n *\n * Works with any validator type (string, number, date, object, array, etc.)\n *\n * @param indent - Optional indentation for pretty printing (default: 0 for compact)\n *\n * @example\n * ```ts\n * // Compact JSON\n * v.object({ name: v.string() }).toJSON()\n * // Output: '{\"name\":\"John\"}'\n *\n * // Pretty-printed JSON\n * v.array(v.object({...})).toJSON(2)\n * // Output:\n * // [\n * // {\n * // \"name\": \"John\"\n * // }\n * // ]\n *\n * // Works with any type\n * v.string().toJSON() // '\"hello\"'\n * v.number().toJSON() // '42'\n * v.date().toJSON() // '\"2024-10-26T00:00:00.000Z\"'\n * ```\n *\n * @category Transformer\n */\n public toJSON(indent?: number) {\n return this.addTransformer((data, { options }) => JSON.stringify(data, null, options.indent), {\n indent: indent ?? 0,\n });\n }\n\n /**\n * Start data transformation pipeline\n * Context is passed at runtime, not stored\n */\n public async startTransformationPipeline(data: any, context: SchemaContext) {\n for (const transformer of this.dataTransformers) {\n data = await transformer.transform(data, {\n options: transformer.options,\n context,\n });\n }\n\n return data;\n }\n\n /**\n * Set attributes text to be replaced on translations\n * If the value is an object, it will be used as the attributes list for the rule\n * If the value is a string, it will be used as the attributes list for the rule\n *\n * @example\n * v.string().attributes({\n * name: \"Name\",\n * email: \"Email\",\n * });\n * // Example 2: Add custom attributes for matches\n * v.string().matches(\"confirmPassword\").attributes({\n * matches: {\n * confirmPassword: \"Confirm Password\",\n * },\n * });\n */\n public attributes(attributes: Record<string, string | Record<string, string>>) {\n const instance = this.instance;\n for (const key in attributes) {\n instance.attributesText[key] = attributes[key];\n }\n\n return instance;\n }\n\n /**\n * Define a lazy getter property for each attribute in the given object and use the config attribute translator\n */\n public transAttributes(attributes: Record<string, string>) {\n const instance = this.instance;\n for (const key in attributes) {\n instance.translatedAttributes[key] = attributes[key];\n }\n\n return instance;\n }\n\n /**\n * Add description to the validator\n */\n public describe(description: string) {\n const instance = this.instance;\n instance.description = description;\n return instance;\n }\n\n /**\n * Check if this validator can handle the given value's type\n * Override this in specific validators to enable type-based routing in union validators\n *\n * Default: returns true (validator will attempt to validate any type)\n *\n * @param value - The value to check\n * @returns True if this validator can handle this type\n *\n * @example\n * ```ts\n * // StringValidator\n * public matchesType(value: any): boolean {\n * return typeof value === 'string';\n * }\n *\n * // Custom FileValidator\n * public matchesType(value: any): boolean {\n * return value instanceof UploadedFile;\n * }\n * ```\n */\n public matchesType(_value: any): boolean {\n return true; // Default: permissive, attempt to validate any type\n }\n\n /**\n * Create a copy of this validator with the same configuration\n * Copies all rules, mutators, transformers, default values, and settings\n *\n * @returns A new validator instance with copied configuration\n *\n * @example\n * ```ts\n * // Create reusable validator templates\n * const baseString = v.string().required().trim().min(3);\n * const emailField = baseString.clone().email();\n * const usernameField = baseString.clone().alphanumeric().max(20);\n *\n * // Works with all validators\n * const positiveInt = v.int().positive().required();\n * const ageField = positiveInt.clone().min(18).max(120);\n * ```\n */\n public clone(): this {\n // Create a new instance using Object.create to preserve the prototype chain\n const Constructor = this.constructor as new (...args: any[]) => this;\n const cloned = Object.create(Constructor.prototype);\n\n // Copy all BaseValidator properties\n cloned.rules = [...this.rules];\n cloned.mutators = [...this.mutators];\n cloned.dataTransformers = [...this.dataTransformers];\n cloned.defaultValue = this.defaultValue;\n cloned.shouldOmit = this.shouldOmit;\n cloned.description = this.description;\n cloned.attributesText = { ...this.attributesText };\n cloned.isNullable = this.isNullable;\n cloned.isOptional = this.isOptional;\n cloned.requiredRule = this.requiredRule; // same reference is fine — rule is treated as immutable\n cloned.catchValue = this.catchValue;\n cloned.hasCatch = this.hasCatch;\n\n return cloned;\n }\n\n /**\n * @deprecated This method is no longer needed and does nothing.\n * Empty values are now automatically skipped for validation rules by default.\n * Only presence validators (required, present, etc.) will check empty values.\n * You can safely remove this call from your code.\n */\n public ignoreEmptyValue(_ignoreEmptyValue = true) {\n // No-op for backward compatibility\n return this;\n }\n\n /**\n * Omit this field from the validated data output\n *\n * Field will still be validated but not included in the final result.\n * Useful for confirmation fields, captcha, terms acceptance, etc.\n *\n * @example\n * ```ts\n * v.object({\n * password: v.string().required(),\n * confirmPassword: v.string().required().sameAs(\"password\").omit(),\n * acceptTerms: v.boolean().required().omit(),\n * });\n * // Output: { password: \"...\" }\n * // confirmPassword and acceptTerms validated but omitted\n * ```\n */\n public omit() {\n const instance = this.instance;\n instance.shouldOmit = true;\n return instance;\n }\n\n /**\n * @alias omit\n */\n public exclude() {\n return this.omit();\n }\n\n /**\n * Check if this field should be omitted from the output\n */\n public isOmitted(): boolean {\n return this.shouldOmit;\n }\n\n /**\n * Add rule to the validator\n */\n public addRule<T extends SchemaRuleOptions = SchemaRuleOptions>(\n rule: SchemaRule<T>,\n errorMessage?: string,\n options: T = {} as T,\n ): this {\n const instance = this.instance;\n instance.addMutableRule(rule, errorMessage, options);\n return instance;\n }\n\n /**\n * Set the required-condition rule for this field.\n *\n * Unlike addRule(), this does NOT push to rules[]. The rule is stored in the\n * dedicated `requiredRule` slot and is prepended to the validation pipeline\n * at runtime. Only one required rule can be active per field — this replaces\n * any previously set required rule.\n *\n * Also marks the field as not optional (isOptional = false).\n *\n * @example\n * ```ts\n * // Used internally by required(), requiredIf(), requiredWith(), etc.\n * BaseValidator.prototype.required = function(msg) {\n * return this.setRequiredRule(requiredRule, msg);\n * };\n * ```\n */\n public setRequiredRule<T extends SchemaRuleOptions = SchemaRuleOptions>(\n rule: SchemaRule<T>,\n errorMessage?: string,\n options: T = {} as T,\n ): this {\n const instance = this.instance;\n instance.isOptional = false;\n instance.requiredRule = instance.createRule(rule, errorMessage, options);\n return instance;\n }\n\n /**\n * Add mutable rule\n */\n public addMutableRule<T extends SchemaRuleOptions = SchemaRuleOptions>(\n rule: SchemaRule<T>,\n errorMessage?: string,\n options: T = {} as T,\n ): ContextualSchemaRule<T> {\n const newRule: ContextualSchemaRule<T> = this.createRule(rule, errorMessage, options);\n\n this.rules.push(newRule);\n\n return newRule;\n }\n\n /**\n * Create new rule\n */\n protected createRule<T extends SchemaRuleOptions = SchemaRuleOptions>(\n rule: SchemaRule<T>,\n errorMessage?: string,\n options: T = {} as T,\n ): ContextualSchemaRule<T> {\n const newRule: ContextualSchemaRule<T> = {\n ...(clone(rule) as ContextualSchemaRule<T>),\n context: {\n errorMessage,\n options,\n attributesList: this.attributesText,\n translatedAttributes: this.translatedAttributes,\n translationParams: {},\n translatableParams: {},\n },\n };\n\n if (errorMessage) {\n newRule.errorMessage = errorMessage;\n }\n\n if (rule.sortOrder === undefined) {\n newRule.sortOrder = this.rules.length + 1;\n }\n\n return newRule;\n }\n\n /**\n * Use a custom or pre-built validation rule\n *\n * @param rule - The validation rule to apply\n * @param options - Rule options including errorMessage and any rule-specific options\n *\n * @example\n * ```ts\n * import { hexColorRule } from \"@warlock.js/seal\";\n *\n * v.string().useRule(hexColorRule, { errorMessage: \"Invalid color\" });\n * ```\n *\n * @example\n * ```ts\n * // With rule options\n * v.string().useRule(myCustomRule, {\n * customOption: true,\n * errorMessage: \"Custom validation failed\"\n * });\n * ```\n */\n public useRule<T extends SchemaRuleOptions = SchemaRuleOptions>(\n rule: SchemaRule<T>,\n options?: T & { errorMessage?: string },\n ) {\n const { errorMessage, ...ruleOptions } = options || ({} as any);\n return this.addRule(rule, errorMessage, ruleOptions);\n }\n\n /**\n * Define custom rule\n */\n public refine(\n callback: (\n value: any,\n context: SchemaContext,\n ) => Promise<string | undefined> | string | undefined,\n ) {\n return this.addRule({\n name: \"custom\",\n async validate(value, context) {\n const result = await callback(value, context);\n if (result) {\n this.context.errorMessage = result;\n return invalidRule(this, context);\n }\n return VALID_RULE;\n },\n });\n }\n\n /**\n * Add mutator to the validator\n */\n public addMutator(mutator: Mutator, options: any = {}) {\n const instance = this.instance;\n instance.addMutableMutator(mutator, options);\n return instance;\n }\n\n /**\n * Add mutable mutator\n */\n public addMutableMutator(mutator: Mutator, options: any = {}) {\n this.mutators.push({\n mutate: mutator,\n context: {\n options,\n ctx: {} as any,\n },\n });\n }\n\n /**\n * Set default value for the field. The default is used when the input is\n * absent (`undefined`); it then flows through the rule pipeline.\n *\n * Brands the return type with `{ hasDefault: true }` so `Infer<>` treats\n * the field as guaranteed-present even when chained with `.optional()`.\n */\n public default(value: any): this & { hasDefault: true } {\n const instance = this.instance;\n instance.defaultValue = value;\n return instance as this & { hasDefault: true };\n }\n\n /**\n * Fallback to a value when validation fails.\n *\n * Complementary to `.default()`: `.default(x)` fires when input is **absent**,\n * `.catch(y)` fires when input is **present but invalid**. Combine them when\n * you want both behaviours: `.optional().default(x).catch(y)`.\n *\n * The fallback can be a value or a callback `(errors, originalInput) => fallback`.\n * The callback variant is the only side-channel for the swallowed errors —\n * use it to log/alert before the fallback substitutes.\n *\n * Brands the return type with `{ hasCatch: true }` so `Infer<>` treats the\n * field as guaranteed-present (the catch ensures a value will always exist).\n *\n * **Scope (v1).** Catch is honoured for **leaf validators** (string, number,\n * boolean, date, …) and for fields inside containers. It is a **no-op on\n * container validators themselves** (`v.object`, `v.array`, `v.record`,\n * `v.tuple`, `v.discriminatedUnion`) — those use their own iteration logic\n * that bypasses the catch hook in `BaseValidator.validate()`.\n *\n * @example\n * ```ts\n * v.int().min(0).catch(3) // bad number → 3\n * v.string().in([\"us\", \"eu\"]).catch(\"us\") // unknown enum → \"us\"\n * v.string().catch((errors, input) => {\n * console.warn(`bad user value: ${JSON.stringify(input)}`, errors);\n * return \"anonymous\";\n * })\n * ```\n */\n public catch(\n fallback:\n | any\n | ((errors: ValidationResult[\"errors\"], originalInput: any) => any | Promise<any>),\n ): this & { hasCatch: true } {\n const instance = this.instance;\n\n instance.catchValue = fallback;\n instance.hasCatch = true;\n\n return instance as this & { hasCatch: true };\n }\n\n /**\n * Mutate the data\n */\n public async mutate(data: any, context: SchemaContext) {\n let mutatedData = data;\n\n for (const mutator of this.mutators) {\n mutator.context.ctx = context;\n mutatedData = await mutator.mutate(mutatedData, mutator.context);\n }\n\n return mutatedData;\n }\n\n /**\n * Set the label for the validator that will be matching the :input attribute\n */\n public label(label: string) {\n const instance = this.instance;\n instance.attributesText.input = label;\n return instance;\n }\n\n /**\n * Validate the data\n */\n public async validate(data: any, context: SchemaContext): Promise<ValidationResult> {\n if (data === null && this.isNullable) {\n return { isValid: true, errors: [], data: null };\n }\n\n const valueForRules = data ?? this.getDefaultValue();\n const mutatedData = await this.mutate(valueForRules, context);\n\n const errors: ValidationResult[\"errors\"] = [];\n let isValid = true;\n const isFirstErrorOnly = context.configurations?.firstErrorOnly ?? true;\n\n const isEmpty = isEmptyValue(valueForRules);\n\n // D8 fix (design/core-defects-found.md): for an optional field, only a\n // truly ABSENT value (`valueForRules === undefined` — the key was\n // missing, or was `null`/`undefined` and got coalesced above) may skip\n // the value rules. A PRESENT-but-empty value (e.g. `\"\"` from `?page=`)\n // must still run them, so `v.int().optional()` given `\"\"` fails instead\n // of silently handing back a string that `Infer.Output`'s\n // `number | undefined` forbids. Non-optional fields are unaffected —\n // their `requiredRule` (not nulled out by `.optional()`) already rejects\n // `\"\"` before these rules matter.\n const skipEmptyRules = this.isOptional ? valueForRules === undefined : isEmpty;\n\n // Prepend the required-condition rule if set, so it always runs first.\n // requiredRule has requiresValue = false so it runs even on empty values.\n const rulesToRun = this.requiredRule ? [this.requiredRule, ...this.rules] : this.rules;\n\n for (const rule of rulesToRun) {\n if ((rule.requiresValue ?? true) && skipEmptyRules) continue;\n\n this.setRuleAttributesList(rule);\n\n const result = await rule.validate(mutatedData, context);\n\n if (result.isValid === false) {\n isValid = false;\n errors.push({\n type: rule.name,\n error: result.error,\n input: result.path ?? context.path,\n });\n\n if (isFirstErrorOnly) {\n break;\n }\n }\n }\n\n const result: ValidationResult = {\n isValid,\n errors,\n data:\n mutatedData !== undefined\n ? await this.startTransformationPipeline(mutatedData, context)\n : undefined,\n };\n\n // Catch fallback — only on the leaf path. Container validators override\n // validate() and don't run this hook on their own outcome, so catching\n // a whole object/array/record is a no-op in v1.\n if (result.isValid === false && this.hasCatch) {\n const fallback =\n typeof this.catchValue === \"function\"\n ? await this.catchValue(result.errors, data)\n : this.catchValue;\n\n return { isValid: true, errors: [], data: fallback };\n }\n\n return result;\n }\n\n /**\n * Set rule attributes list\n */\n protected setRuleAttributesList(rule: ContextualSchemaRule) {\n rule.context.attributesList =\n typeof this.attributesText[rule.name] === \"object\"\n ? (this.attributesText[rule.name] as ValidationAttributesList)\n : this.attributesText;\n }\n\n /**\n * Standard Schema V1 compliance.\n *\n * Allows this validator to be used with any Standard Schema-aware library\n * (OpenAI structured outputs, LangGraph, TanStack Form, Conform, Valibot adapters, etc.)\n * without extra adapters.\n *\n * Delegates to the `validate()` factory so all `configureSeal()` options\n * (translations, firstErrorOnly) are picked up automatically at call time.\n *\n * Includes Standard JSON Schema support via `jsonSchema.input()` / `jsonSchema.output()`.\n *\n * ## How Standard Schema libraries consume this\n *\n * You pass the **schema object itself** to the library — they internally read\n * `schema[\"~standard\"]`. Do NOT pass `schema[\"~standard\"]` directly.\n *\n * @example\n * ```ts\n * const schema = v.object({ name: v.string().required() });\n *\n * // TanStack Form — pass schema, library reads [\"~standard\"] internally\n * const form = useForm({ validators: { onChange: schema } });\n *\n * // Conform (Remix) — same pattern\n * const [form] = useForm({ onValidate({ formData }) {\n * return parseWithStandardSchema(formData, { schema });\n * }});\n *\n * // Direct validation (lower level — most apps don't need this)\n * const result = await schema[\"~standard\"].validate({ name: \"Hasan\" });\n * // → { value: { name: \"Hasan\" } } on success\n * // → { issues: [{ message: \"...\", path: [{ key: \"name\" }] }] } on failure\n *\n * // JSON Schema for OpenAI / LangChain tool calling\n * const parameters = schema[\"~standard\"].jsonSchema.input({ target: \"openai-strict\" });\n * // → { type: \"object\", properties: {...}, required: [...], additionalProperties: false }\n * ```\n *\n * @note Cross-field rules (sameAs, requiredIf, requiredWith) rely on sibling values\n * available in the full validation context. When called on a standalone scalar validator,\n * sibling data is absent and those rules will not evaluate correctly.\n * Always call on the parent ObjectValidator for full-payload validation.\n */\n get [\"~standard\"](): StandardJSONSchemaV1.Props<TInput, TOutput> {\n return {\n version: 1,\n vendor: \"seal\",\n types: undefined as unknown as StandardSchemaV1.Types<TInput, TOutput>,\n validate: async (value: unknown) => {\n const result = await validate(this, value);\n return mapToStandardResult(result) as StandardSchemaV1.Result<TOutput>;\n },\n jsonSchema: {\n input: (options) => this.toJsonSchema(options.target),\n output: (options) => this.toJsonSchema(options.target),\n },\n };\n }\n\n /**\n * Generate a JSON Schema representation of this validator.\n *\n * Supports targets: `\"draft-2020-12\"` (default), `\"draft-07\"`, `\"openapi-3.0\"`.\n *\n * Subclasses override this to describe their specific constraints.\n * The base implementation returns `{}` (permissive — accepts anything),\n * which is correct for validators with no representable JSON Schema constraints.\n *\n * @note Rules that cannot be expressed in JSON Schema are silently omitted:\n * - Cross-field rules: sameAs, requiredIf, requiredWith, requiredWithout\n * - Custom callbacks: refine()\n * - Framework-specific runtime rules (core/cascade plugins)\n * These rules still run normally at validation time — only absent from JSON Schema.\n *\n * @example\n * ```ts\n * v.string().min(3).max(50).toJsonSchema(\"draft-2020-12\")\n * // → { type: \"string\", minLength: 3, maxLength: 50 }\n *\n * v.object({ name: v.string().required(), age: v.int().optional() })\n * .toJsonSchema(\"draft-07\")\n * // → { type: \"object\", properties: { name: { type: \"string\" }, age: { type: \"integer\" } }, required: [\"name\"] }\n * ```\n */\n public toJsonSchema(_target: JsonSchemaTarget = \"draft-2020-12\"): JsonSchemaResult {\n return {};\n }\n}\n"],"mappings":";;;;;;;;;;;;AAyBA,IAAa,gBAAb,MAA+D;;eACtB,CAAC;kBACG,CAAC;oBAGrB;oBACA;mBACD;kBAYD;oBASD;sBAS+B,KAAK,WAAWA,YAAmB;0BAK5B,CAAC;wBAON,CAAC;8BAKG,CAAC;;;;;CAK1D,IAAW,UAAU;EACnB,KAAK,YAAY;EACjB,OAAO;CACT;;;;CAKA,IAAW,YAAY;EACrB,KAAK,YAAY;EACjB,OAAO;CACT;;;;;;CAOA,IAAc,WAAiB;EAC7B,OAAO,KAAK,YAAY,OAAO,KAAK,MAAM;CAC5C;;;;;CAMA,AAAO,kBAAuB;EAC5B,OAAO,OAAO,KAAK,iBAAiB,aAAa,KAAK,aAAa,IAAI,KAAK;CAC9E;;;;;;;CAQA,AAAO,WAAwC;EAC7C,MAAM,WAAW,KAAK;EACtB,SAAS,aAAa;EACtB,OAAO;CACT;;;;;;;CAQA,AAAO,cAA4C;EACjD,MAAM,WAAW,KAAK;EACtB,SAAS,aAAa;EACtB,OAAO;CACT;;;;;;;;;;;;;;;;;;;CAoBA,AAAO,eAAe,WAAgC,UAAe,C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K,QAAQ,iBACX,OAAO,KAAK,eAAe,KAAK,UAAU,WACrC,KAAK,eAAe,KAAK,QAC1B,KAAK;CACb;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8CA,KAAK,eAA4D;EAC/D,OAAO;GACL,SAAS;GACT,QAAQ;GACR,OAAO;GACP,UAAU,OAAO,UAAmB;IAElC,OAAO,oBAAoB,MADN,SAAS,MAAM,KAAK,CACR;GACnC;GACA,YAAY;IACV,QAAQ,YAAY,KAAK,aAAa,QAAQ,MAAM;IACpD,SAAS,YAAY,KAAK,aAAa,QAAQ,MAAM;GACvD;EACF;CACF;;;;;;;;;;;;;;;;;;;;;;;;;;CA2BA,AAAO,aAAa,UAA4B,iBAAmC;EACjF,OAAO,CAAC;CACV;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@warlock.js/seal",
|
|
3
3
|
"description": "Comprehensive Validation library",
|
|
4
|
+
"warlock": {
|
|
5
|
+
"environment": "universal"
|
|
6
|
+
},
|
|
4
7
|
"dependencies": {
|
|
5
8
|
"@mongez/supportive-is": "^2.1.4",
|
|
6
9
|
"@mongez/reinforcements": "^4.0.1",
|
|
@@ -19,7 +22,7 @@
|
|
|
19
22
|
],
|
|
20
23
|
"author": "hassanzohdy",
|
|
21
24
|
"license": "MIT",
|
|
22
|
-
"version": "
|
|
25
|
+
"version": "5.0.0",
|
|
23
26
|
"main": "./cjs/index.cjs",
|
|
24
27
|
"module": "./esm/index.mjs",
|
|
25
28
|
"types": "./esm/index.d.mts",
|