@warlock.js/seal 5.10.0 → 5.11.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/esm/index.d.mts CHANGED
@@ -87,7 +87,7 @@ import { getFieldValue } from "./helpers/get-field-value.mjs";
87
87
  import { setKeyPath } from "./helpers/path-helpers.mjs";
88
88
  import { VALID_RULE, invalidRule, resolveTranslation } from "./helpers/validation-helpers.mjs";
89
89
  import { flipArrayMutator, removeEmptyArrayElementsMutator, reverseArrayMutator, sortArrayMutator, uniqueArrayMutator } from "./mutators/array-mutators.mjs";
90
- import { booleanCoerceMutator } from "./mutators/boolean-mutators.mjs";
90
+ import { booleanCoerceMutator, formBooleanMutator } from "./mutators/boolean-mutators.mjs";
91
91
  import { addDaysMutator, addHoursMutator, addMonthsMutator, addYearsMutator, dateMutator, toDateOnlyMutator, toEndOfDayMutator, toEndOfMonthMutator, toEndOfYearMutator, toFormatMutator, toISOStringMutator, toStartOfDayMutator, toStartOfMonthMutator, toStartOfYearMutator, toTimeOnlyMutator, toTimestampMutator, toUTCMutator } from "./mutators/date-mutators.mjs";
92
92
  import { absMutator, booleanMutator, ceilMutator, floorMutator, numberMutator, numericMutator, roundMutator, roundNumberMutator, toFixedMutator } from "./mutators/number-mutators.mjs";
93
93
  import { jsonMutator, objectTrimMutator, stripUnknownMutator } from "./mutators/object-mutators.mjs";
@@ -98,7 +98,7 @@ import { ValidateOptions, ValidatorV, v } from "./factory/validators.mjs";
98
98
  import { validate } from "./factory/validate.mjs";
99
99
  import { PluginContext, SealPlugin, getInstalledPlugins, hasPlugin, registerPlugin, unregisterPlugin } from "./plugins/plugin-system.mjs";
100
100
  import { mapToStandardResult } from "./standard-schema/map-result.mjs";
101
- 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, booleanCoerceMutator, 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
+ 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, booleanCoerceMutator, 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, formBooleanMutator, 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 };
102
102
  import "./validators/methods/equality-conditional-methods.mjs";
103
103
  import "./validators/methods/forbidden-methods.mjs";
104
104
  import "./validators/methods/present-methods.mjs";
package/esm/index.mjs CHANGED
@@ -12,7 +12,7 @@ import { mapToStandardResult } from "./standard-schema/map-result.mjs";
12
12
  import { BaseValidator } from "./validators/base-validator.mjs";
13
13
  import { AnyValidator } from "./validators/any-validator.mjs";
14
14
  import { flipArrayMutator, removeEmptyArrayElementsMutator, reverseArrayMutator, sortArrayMutator, uniqueArrayMutator } from "./mutators/array-mutators.mjs";
15
- import { booleanCoerceMutator } from "./mutators/boolean-mutators.mjs";
15
+ import { booleanCoerceMutator, formBooleanMutator } from "./mutators/boolean-mutators.mjs";
16
16
  import { addDaysMutator, addHoursMutator, addMonthsMutator, addYearsMutator, dateMutator, toDateOnlyMutator, toEndOfDayMutator, toEndOfMonthMutator, toEndOfYearMutator, toFormatMutator, toISOStringMutator, toStartOfDayMutator, toStartOfMonthMutator, toStartOfYearMutator, toTimeOnlyMutator, toTimestampMutator, toUTCMutator } from "./mutators/date-mutators.mjs";
17
17
  import { absMutator, booleanMutator, ceilMutator, floorMutator, numberMutator, numericMutator, roundMutator, roundNumberMutator, toFixedMutator } from "./mutators/number-mutators.mjs";
18
18
  import { jsonMutator, objectTrimMutator, stripUnknownMutator } from "./mutators/object-mutators.mjs";
@@ -94,4 +94,4 @@ import { v } from "./factory/validators.mjs";
94
94
  import "./factory/index.mjs";
95
95
  import { getInstalledPlugins, hasPlugin, registerPlugin, unregisterPlugin } from "./plugins/plugin-system.mjs";
96
96
 
97
- 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, booleanCoerceMutator, 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 };
97
+ 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, booleanCoerceMutator, 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, formBooleanMutator, 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 };
@@ -9,6 +9,22 @@ import { Mutator } from "../types/mutator-types.mjs";
9
9
  * `2`, `null`, etc.) passes through unchanged so the boolean type rule rejects it.
10
10
  */
11
11
  declare const booleanCoerceMutator: Mutator;
12
+ /**
13
+ * Parse form-shaped boolean values into a real boolean, ahead of the type
14
+ * rule.
15
+ *
16
+ * Opted into by calling any `accepted*`/`declined*` method on
17
+ * `v.boolean()` (see `BooleanValidator`'s `withFormBooleanMutator`). Converts
18
+ * every value in `ACCEPTED_VALUES` (`1`, `"1"`, `true`, `"true"`, `"yes"`,
19
+ * `"y"`, `"on"`, `"Yes"`, `"Y"`, `"On"`) to `true`, and every value in
20
+ * `DECLINED_VALUES` (`0`, `"0"`, `false`, `"false"`, `"no"`, `"n"`, `"off"`,
21
+ * `"No"`, `"N"`, `"Off"`) to `false`. Any other value passes through
22
+ * unchanged so the boolean type rule still rejects it.
23
+ *
24
+ * Named (not anonymous) so callers can detect whether it has already been
25
+ * added — see the idempotence check in `BooleanValidator`.
26
+ */
27
+ declare const formBooleanMutator: Mutator;
12
28
  //#endregion
13
- export { booleanCoerceMutator };
29
+ export { booleanCoerceMutator, formBooleanMutator };
14
30
  //# sourceMappingURL=boolean-mutators.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"boolean-mutators.d.mts","names":[],"sources":["../../../../../../../seal/src/mutators/boolean-mutators.ts"],"mappings":";;;;;AASA;;;;AAUC;cAVY,oBAAA,EAAsB,OAUlC"}
1
+ {"version":3,"file":"boolean-mutators.d.mts","names":[],"sources":["../../../../../../../seal/src/mutators/boolean-mutators.ts"],"mappings":";;;;;AAWA;;;;AAUC;cAVY,oBAAA,EAAsB,OAUlC;;;;AA2BA;;;;;;;;;;;;cAVY,kBAAA,EAAoB,OAUhC"}
@@ -1,3 +1,6 @@
1
+ import { ACCEPTED_VALUES } from "../rules/scalar/accepted-rule.mjs";
2
+ import { DECLINED_VALUES } from "../rules/scalar/declined-rule.mjs";
3
+
1
4
  //#region ../seal/src/mutators/boolean-mutators.ts
2
5
  /**
3
6
  * Coerce a query-string-shaped boolean into a real boolean.
@@ -11,7 +14,27 @@ const booleanCoerceMutator = async (value) => {
11
14
  if (value === "false" || value === "0" || value === 0) return false;
12
15
  return value;
13
16
  };
17
+ /**
18
+ * Parse form-shaped boolean values into a real boolean, ahead of the type
19
+ * rule.
20
+ *
21
+ * Opted into by calling any `accepted*`/`declined*` method on
22
+ * `v.boolean()` (see `BooleanValidator`'s `withFormBooleanMutator`). Converts
23
+ * every value in `ACCEPTED_VALUES` (`1`, `"1"`, `true`, `"true"`, `"yes"`,
24
+ * `"y"`, `"on"`, `"Yes"`, `"Y"`, `"On"`) to `true`, and every value in
25
+ * `DECLINED_VALUES` (`0`, `"0"`, `false`, `"false"`, `"no"`, `"n"`, `"off"`,
26
+ * `"No"`, `"N"`, `"Off"`) to `false`. Any other value passes through
27
+ * unchanged so the boolean type rule still rejects it.
28
+ *
29
+ * Named (not anonymous) so callers can detect whether it has already been
30
+ * added — see the idempotence check in `BooleanValidator`.
31
+ */
32
+ const formBooleanMutator = async (value) => {
33
+ if (ACCEPTED_VALUES.includes(value)) return true;
34
+ if (DECLINED_VALUES.includes(value)) return false;
35
+ return value;
36
+ };
14
37
 
15
38
  //#endregion
16
- export { booleanCoerceMutator };
39
+ export { booleanCoerceMutator, formBooleanMutator };
17
40
  //# sourceMappingURL=boolean-mutators.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"boolean-mutators.mjs","names":[],"sources":["../../../../../../../seal/src/mutators/boolean-mutators.ts"],"sourcesContent":["import type { Mutator } from \"../types\";\n\n/**\n * Coerce a query-string-shaped boolean into a real boolean.\n *\n * Converts exactly: `\"true\"` / `\"1\"` / `1` → `true`, `\"false\"` / `\"0\"` / `0` → `false`.\n * Case-sensitive, no trimming. Any other value (`\"yes\"`, `\"on\"`, `\"TRUE\"`, `\"\"`,\n * `2`, `null`, etc.) passes through unchanged so the boolean type rule rejects it.\n */\nexport const booleanCoerceMutator: Mutator = async (value) => {\n if (value === \"true\" || value === \"1\" || value === 1) {\n return true;\n }\n\n if (value === \"false\" || value === \"0\" || value === 0) {\n return false;\n }\n\n return value;\n};\n"],"mappings":";;;;;;;;AASA,MAAa,uBAAgC,OAAO,UAAU;CAC5D,IAAI,UAAU,UAAU,UAAU,OAAO,UAAU,GACjD,OAAO;CAGT,IAAI,UAAU,WAAW,UAAU,OAAO,UAAU,GAClD,OAAO;CAGT,OAAO;AACT"}
1
+ {"version":3,"file":"boolean-mutators.mjs","names":[],"sources":["../../../../../../../seal/src/mutators/boolean-mutators.ts"],"sourcesContent":["import { ACCEPTED_VALUES } from \"../rules/scalar/accepted-rule\";\nimport { DECLINED_VALUES } from \"../rules/scalar/declined-rule\";\nimport type { Mutator } from \"../types\";\n\n/**\n * Coerce a query-string-shaped boolean into a real boolean.\n *\n * Converts exactly: `\"true\"` / `\"1\"` / `1` → `true`, `\"false\"` / `\"0\"` / `0` → `false`.\n * Case-sensitive, no trimming. Any other value (`\"yes\"`, `\"on\"`, `\"TRUE\"`, `\"\"`,\n * `2`, `null`, etc.) passes through unchanged so the boolean type rule rejects it.\n */\nexport const booleanCoerceMutator: Mutator = async (value) => {\n if (value === \"true\" || value === \"1\" || value === 1) {\n return true;\n }\n\n if (value === \"false\" || value === \"0\" || value === 0) {\n return false;\n }\n\n return value;\n};\n\n/**\n * Parse form-shaped boolean values into a real boolean, ahead of the type\n * rule.\n *\n * Opted into by calling any `accepted*`/`declined*` method on\n * `v.boolean()` (see `BooleanValidator`'s `withFormBooleanMutator`). Converts\n * every value in `ACCEPTED_VALUES` (`1`, `\"1\"`, `true`, `\"true\"`, `\"yes\"`,\n * `\"y\"`, `\"on\"`, `\"Yes\"`, `\"Y\"`, `\"On\"`) to `true`, and every value in\n * `DECLINED_VALUES` (`0`, `\"0\"`, `false`, `\"false\"`, `\"no\"`, `\"n\"`, `\"off\"`,\n * `\"No\"`, `\"N\"`, `\"Off\"`) to `false`. Any other value passes through\n * unchanged so the boolean type rule still rejects it.\n *\n * Named (not anonymous) so callers can detect whether it has already been\n * added — see the idempotence check in `BooleanValidator`.\n */\nexport const formBooleanMutator: Mutator = async (value) => {\n if (ACCEPTED_VALUES.includes(value)) {\n return true;\n }\n\n if (DECLINED_VALUES.includes(value)) {\n return false;\n }\n\n return value;\n};\n"],"mappings":";;;;;;;;;;;AAWA,MAAa,uBAAgC,OAAO,UAAU;CAC5D,IAAI,UAAU,UAAU,UAAU,OAAO,UAAU,GACjD,OAAO;CAGT,IAAI,UAAU,WAAW,UAAU,OAAO,UAAU,GAClD,OAAO;CAGT,OAAO;AACT;;;;;;;;;;;;;;;;AAiBA,MAAa,qBAA8B,OAAO,UAAU;CAC1D,IAAI,gBAAgB,SAAS,KAAK,GAChC,OAAO;CAGT,IAAI,gBAAgB,SAAS,KAAK,GAChC,OAAO;CAGT,OAAO;AACT"}
@@ -1,5 +1,5 @@
1
1
  import { flipArrayMutator, removeEmptyArrayElementsMutator, reverseArrayMutator, sortArrayMutator, uniqueArrayMutator } from "./array-mutators.mjs";
2
- import { booleanCoerceMutator } from "./boolean-mutators.mjs";
2
+ import { booleanCoerceMutator, formBooleanMutator } from "./boolean-mutators.mjs";
3
3
  import { addDaysMutator, addHoursMutator, addMonthsMutator, addYearsMutator, dateMutator, toDateOnlyMutator, toEndOfDayMutator, toEndOfMonthMutator, toEndOfYearMutator, toFormatMutator, toISOStringMutator, toStartOfDayMutator, toStartOfMonthMutator, toStartOfYearMutator, toTimeOnlyMutator, toTimestampMutator, toUTCMutator } from "./date-mutators.mjs";
4
4
  import { absMutator, booleanMutator, ceilMutator, floorMutator, numberMutator, numericMutator, roundMutator, roundNumberMutator, toFixedMutator } from "./number-mutators.mjs";
5
5
  import { jsonMutator, objectTrimMutator, stripUnknownMutator } from "./object-mutators.mjs";
@@ -4,19 +4,26 @@ import "../../helpers/index.mjs";
4
4
  import { isEmptyValue } from "../../helpers/is-empty-value.mjs";
5
5
 
6
6
  //#region ../seal/src/rules/scalar/accepted-rule.ts
7
+ /**
8
+ * The full set of values treated as "accepted" by `acceptedRule` and its
9
+ * conditional variants. Shared with `formBooleanMutator` (see
10
+ * `../../mutators/boolean-mutators`) so `v.boolean().accepted()` recognizes
11
+ * exactly this list — single source of truth, no duplicated literals.
12
+ */
13
+ const ACCEPTED_VALUES = [
14
+ "1",
15
+ "true",
16
+ "yes",
17
+ "y",
18
+ "on",
19
+ 1,
20
+ true,
21
+ "Yes",
22
+ "Y",
23
+ "On"
24
+ ];
7
25
  const isAcceptedValue = (value) => {
8
- return [
9
- "1",
10
- "true",
11
- "yes",
12
- "y",
13
- "on",
14
- 1,
15
- true,
16
- "Yes",
17
- "Y",
18
- "On"
19
- ].includes(value);
26
+ return ACCEPTED_VALUES.includes(value);
20
27
  };
21
28
  /**
22
29
  * Validate value as accepted if it equals:
@@ -112,5 +119,5 @@ const acceptedWithoutRule = {
112
119
  };
113
120
 
114
121
  //#endregion
115
- export { acceptedIfPresentRule, acceptedIfRequiredRule, acceptedIfRule, acceptedRule, acceptedUnlessRule, acceptedWithoutRule };
122
+ export { ACCEPTED_VALUES, acceptedIfPresentRule, acceptedIfRequiredRule, acceptedIfRule, acceptedRule, acceptedUnlessRule, acceptedWithoutRule };
116
123
  //# sourceMappingURL=accepted-rule.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"accepted-rule.mjs","names":[],"sources":["../../../../../../../../seal/src/rules/scalar/accepted-rule.ts"],"sourcesContent":["import { getFieldValue, invalidRule, VALID_RULE } from \"../../helpers\";\r\nimport { isEmptyValue } from \"../../helpers/is-empty-value\";\r\nimport type { SchemaRule } from \"../../types\";\r\n\r\nconst isAcceptedValue = (value: any) => {\r\n return [\"1\", \"true\", \"yes\", \"y\", \"on\", 1, true, \"Yes\", \"Y\", \"On\"].includes(value);\r\n};\r\n\r\n/**\r\n * Validate value as accepted if it equals:\r\n * 1 | \"1\" | true | \"true\" | \"yes\" | \"y\" | \"on\"\r\n */\r\nexport const acceptedRule: SchemaRule = {\r\n name: \"accepted\",\r\n defaultErrorMessage: \"The :input must be accepted\",\r\n description:\r\n \"The value must be accepted if it equals: 1 | '1' | true | 'true' | 'yes' | 'y' | 'on' | 1 | true | 'Yes' | 'Y' | 'On'\",\r\n async validate(value: any, context) {\r\n if (isAcceptedValue(value)) {\r\n return VALID_RULE;\r\n }\r\n\r\n return invalidRule(this, context);\r\n },\r\n};\r\n\r\n/**\r\n * Accepted value if another field's value equals to a specific value\r\n */\r\nexport const acceptedIfRule: SchemaRule<{ field: string; value: any }> = {\r\n name: \"acceptedIf\",\r\n description: \"The field must be accepted if :field's value equals to :value\",\r\n defaultErrorMessage: \"The :input must be accepted\",\r\n async validate(value: any, context) {\r\n const fieldValue = getFieldValue(this, context);\r\n const { value: expectedValue } = this.context.options;\r\n\r\n this.context.translatableParams.field = this.context.options.field;\r\n this.context.translatableParams.value = this.context.options.value;\r\n if (fieldValue !== expectedValue) {\r\n return invalidRule(this, context);\r\n }\r\n\r\n if (!isAcceptedValue(value)) {\r\n return invalidRule(this, context);\r\n }\r\n\r\n return VALID_RULE;\r\n },\r\n};\r\n\r\n/**\r\n * Accepted if another field is not equal to the given value\r\n */\r\nexport const acceptedUnlessRule: SchemaRule<{ field: string; value: any }> = {\r\n name: \"acceptedUnless\",\r\n description: \"The field must be accepted if :field's value is not equal to :value\",\r\n defaultErrorMessage: \"The :input must be accepted\",\r\n async validate(value: any, context) {\r\n const fieldValue = getFieldValue(this, context);\r\n const { value: expectedValue } = this.context.options;\r\n\r\n this.context.translatableParams.field = this.context.options.field;\r\n this.context.translatableParams.value = this.context.options.value;\r\n\r\n if (fieldValue === expectedValue) {\r\n return invalidRule(this, context);\r\n }\r\n\r\n if (!isAcceptedValue(value)) {\r\n return invalidRule(this, context);\r\n }\r\n\r\n return VALID_RULE;\r\n },\r\n};\r\n\r\n/**\r\n * Accepted if another field is required\r\n */\r\nexport const acceptedIfRequiredRule: SchemaRule<{ field: string }> = {\r\n name: \"acceptedIfRequired\",\r\n description: \"The field must be accepted if :field is required\",\r\n defaultErrorMessage: \"The :input must be accepted\",\r\n async validate(value: any, context) {\r\n const fieldValue = getFieldValue(this, context);\r\n this.context.translatableParams.field = this.context.options.field;\r\n\r\n if (isEmptyValue(fieldValue)) {\r\n return invalidRule(this, context);\r\n }\r\n\r\n if (!isAcceptedValue(value)) {\r\n return invalidRule(this, context);\r\n }\r\n\r\n return VALID_RULE;\r\n },\r\n};\r\n\r\n/**\r\n * Accepted if another field is present\r\n */\r\nexport const acceptedIfPresentRule: SchemaRule<{ field: string }> = {\r\n name: \"acceptedIfPresent\",\r\n description: \"The field must be accepted if :field is present\",\r\n defaultErrorMessage: \"The :input must be accepted\",\r\n async validate(value: any, context) {\r\n const fieldValue = getFieldValue(this, context);\r\n this.context.translatableParams.field = this.context.options.field;\r\n\r\n if (fieldValue === undefined) {\r\n return invalidRule(this, context);\r\n }\r\n\r\n if (!isAcceptedValue(value)) {\r\n return invalidRule(this, context);\r\n }\r\n\r\n return VALID_RULE;\r\n },\r\n};\r\n\r\n/**\r\n * Accepted if another field is missing\r\n */\r\nexport const acceptedWithoutRule: SchemaRule<{ field: string }> = {\r\n name: \"acceptedWithout\",\r\n description: \"The field must be accepted if :field is missing\",\r\n defaultErrorMessage: \"The :input must be accepted\",\r\n async validate(value: any, context) {\r\n const fieldValue = getFieldValue(this, context);\r\n this.context.translatableParams.field = this.context.options.field;\r\n\r\n if (fieldValue !== undefined) {\r\n return invalidRule(this, context);\r\n }\r\n\r\n if (!isAcceptedValue(value)) {\r\n return invalidRule(this, context);\r\n }\r\n\r\n return VALID_RULE;\r\n },\r\n};\r\n"],"mappings":";;;;;;AAIA,MAAM,mBAAmB,UAAe;CACtC,OAAO;EAAC;EAAK;EAAQ;EAAO;EAAK;EAAM;EAAG;EAAM;EAAO;EAAK;CAAI,CAAC,CAAC,SAAS,KAAK;AAClF;;;;;AAMA,MAAa,eAA2B;CACtC,MAAM;CACN,qBAAqB;CACrB,aACE;CACF,MAAM,SAAS,OAAY,SAAS;EAClC,IAAI,gBAAgB,KAAK,GACvB,OAAO;EAGT,OAAO,YAAY,MAAM,OAAO;CAClC;AACF;;;;AAKA,MAAa,iBAA4D;CACvE,MAAM;CACN,aAAa;CACb,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAClC,MAAM,aAAa,cAAc,MAAM,OAAO;EAC9C,MAAM,EAAE,OAAO,kBAAkB,KAAK,QAAQ;EAE9C,KAAK,QAAQ,mBAAmB,QAAQ,KAAK,QAAQ,QAAQ;EAC7D,KAAK,QAAQ,mBAAmB,QAAQ,KAAK,QAAQ,QAAQ;EAC7D,IAAI,eAAe,eACjB,OAAO,YAAY,MAAM,OAAO;EAGlC,IAAI,CAAC,gBAAgB,KAAK,GACxB,OAAO,YAAY,MAAM,OAAO;EAGlC,OAAO;CACT;AACF;;;;AAKA,MAAa,qBAAgE;CAC3E,MAAM;CACN,aAAa;CACb,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAClC,MAAM,aAAa,cAAc,MAAM,OAAO;EAC9C,MAAM,EAAE,OAAO,kBAAkB,KAAK,QAAQ;EAE9C,KAAK,QAAQ,mBAAmB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../../../../seal/src/rules/scalar/accepted-rule.ts"],"sourcesContent":["import { getFieldValue, invalidRule, VALID_RULE } from \"../../helpers\";\r\nimport { isEmptyValue } from \"../../helpers/is-empty-value\";\r\nimport type { SchemaRule } from \"../../types\";\r\n\r\n/**\r\n * The full set of values treated as \"accepted\" by `acceptedRule` and its\r\n * conditional variants. Shared with `formBooleanMutator` (see\r\n * `../../mutators/boolean-mutators`) so `v.boolean().accepted()` recognizes\r\n * exactly this list — single source of truth, no duplicated literals.\r\n */\r\nexport const ACCEPTED_VALUES: readonly unknown[] = [\r\n \"1\",\r\n \"true\",\r\n \"yes\",\r\n \"y\",\r\n \"on\",\r\n 1,\r\n true,\r\n \"Yes\",\r\n \"Y\",\r\n \"On\",\r\n];\r\n\r\nconst isAcceptedValue = (value: any) => {\r\n return ACCEPTED_VALUES.includes(value);\r\n};\r\n\r\n/**\r\n * Validate value as accepted if it equals:\r\n * 1 | \"1\" | true | \"true\" | \"yes\" | \"y\" | \"on\"\r\n */\r\nexport const acceptedRule: SchemaRule = {\r\n name: \"accepted\",\r\n defaultErrorMessage: \"The :input must be accepted\",\r\n description:\r\n \"The value must be accepted if it equals: 1 | '1' | true | 'true' | 'yes' | 'y' | 'on' | 1 | true | 'Yes' | 'Y' | 'On'\",\r\n async validate(value: any, context) {\r\n if (isAcceptedValue(value)) {\r\n return VALID_RULE;\r\n }\r\n\r\n return invalidRule(this, context);\r\n },\r\n};\r\n\r\n/**\r\n * Accepted value if another field's value equals to a specific value\r\n */\r\nexport const acceptedIfRule: SchemaRule<{ field: string; value: any }> = {\r\n name: \"acceptedIf\",\r\n description: \"The field must be accepted if :field's value equals to :value\",\r\n defaultErrorMessage: \"The :input must be accepted\",\r\n async validate(value: any, context) {\r\n const fieldValue = getFieldValue(this, context);\r\n const { value: expectedValue } = this.context.options;\r\n\r\n this.context.translatableParams.field = this.context.options.field;\r\n this.context.translatableParams.value = this.context.options.value;\r\n if (fieldValue !== expectedValue) {\r\n return invalidRule(this, context);\r\n }\r\n\r\n if (!isAcceptedValue(value)) {\r\n return invalidRule(this, context);\r\n }\r\n\r\n return VALID_RULE;\r\n },\r\n};\r\n\r\n/**\r\n * Accepted if another field is not equal to the given value\r\n */\r\nexport const acceptedUnlessRule: SchemaRule<{ field: string; value: any }> = {\r\n name: \"acceptedUnless\",\r\n description: \"The field must be accepted if :field's value is not equal to :value\",\r\n defaultErrorMessage: \"The :input must be accepted\",\r\n async validate(value: any, context) {\r\n const fieldValue = getFieldValue(this, context);\r\n const { value: expectedValue } = this.context.options;\r\n\r\n this.context.translatableParams.field = this.context.options.field;\r\n this.context.translatableParams.value = this.context.options.value;\r\n\r\n if (fieldValue === expectedValue) {\r\n return invalidRule(this, context);\r\n }\r\n\r\n if (!isAcceptedValue(value)) {\r\n return invalidRule(this, context);\r\n }\r\n\r\n return VALID_RULE;\r\n },\r\n};\r\n\r\n/**\r\n * Accepted if another field is required\r\n */\r\nexport const acceptedIfRequiredRule: SchemaRule<{ field: string }> = {\r\n name: \"acceptedIfRequired\",\r\n description: \"The field must be accepted if :field is required\",\r\n defaultErrorMessage: \"The :input must be accepted\",\r\n async validate(value: any, context) {\r\n const fieldValue = getFieldValue(this, context);\r\n this.context.translatableParams.field = this.context.options.field;\r\n\r\n if (isEmptyValue(fieldValue)) {\r\n return invalidRule(this, context);\r\n }\r\n\r\n if (!isAcceptedValue(value)) {\r\n return invalidRule(this, context);\r\n }\r\n\r\n return VALID_RULE;\r\n },\r\n};\r\n\r\n/**\r\n * Accepted if another field is present\r\n */\r\nexport const acceptedIfPresentRule: SchemaRule<{ field: string }> = {\r\n name: \"acceptedIfPresent\",\r\n description: \"The field must be accepted if :field is present\",\r\n defaultErrorMessage: \"The :input must be accepted\",\r\n async validate(value: any, context) {\r\n const fieldValue = getFieldValue(this, context);\r\n this.context.translatableParams.field = this.context.options.field;\r\n\r\n if (fieldValue === undefined) {\r\n return invalidRule(this, context);\r\n }\r\n\r\n if (!isAcceptedValue(value)) {\r\n return invalidRule(this, context);\r\n }\r\n\r\n return VALID_RULE;\r\n },\r\n};\r\n\r\n/**\r\n * Accepted if another field is missing\r\n */\r\nexport const acceptedWithoutRule: SchemaRule<{ field: string }> = {\r\n name: \"acceptedWithout\",\r\n description: \"The field must be accepted if :field is missing\",\r\n defaultErrorMessage: \"The :input must be accepted\",\r\n async validate(value: any, context) {\r\n const fieldValue = getFieldValue(this, context);\r\n this.context.translatableParams.field = this.context.options.field;\r\n\r\n if (fieldValue !== undefined) {\r\n return invalidRule(this, context);\r\n }\r\n\r\n if (!isAcceptedValue(value)) {\r\n return invalidRule(this, context);\r\n }\r\n\r\n return VALID_RULE;\r\n },\r\n};\r\n"],"mappings":";;;;;;;;;;;;AAUA,MAAa,kBAAsC;CACjD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,MAAM,mBAAmB,UAAe;CACtC,OAAO,gBAAgB,SAAS,KAAK;AACvC;;;;;AAMA,MAAa,eAA2B;CACtC,MAAM;CACN,qBAAqB;CACrB,aACE;CACF,MAAM,SAAS,OAAY,SAAS;EAClC,IAAI,gBAAgB,KAAK,GACvB,OAAO;EAGT,OAAO,YAAY,MAAM,OAAO;CAClC;AACF;;;;AAKA,MAAa,iBAA4D;CACvE,MAAM;CACN,aAAa;CACb,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAClC,MAAM,aAAa,cAAc,MAAM,OAAO;EAC9C,MAAM,EAAE,OAAO,kBAAkB,KAAK,QAAQ;EAE9C,KAAK,QAAQ,mBAAmB,QAAQ,KAAK,QAAQ,QAAQ;EAC7D,KAAK,QAAQ,mBAAmB,QAAQ,KAAK,QAAQ,QAAQ;EAC7D,IAAI,eAAe,eACjB,OAAO,YAAY,MAAM,OAAO;EAGlC,IAAI,CAAC,gBAAgB,KAAK,GACxB,OAAO,YAAY,MAAM,OAAO;EAGlC,OAAO;CACT;AACF;;;;AAKA,MAAa,qBAAgE;CAC3E,MAAM;CACN,aAAa;CACb,qBAAqB;CACrB,MA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GlC,IAAI,CAAC,gBAAgB,KAAK,GACxB,OAAO,YAAY,MAAM,OAAO;EAGlC,OAAO;CACT;AACF"}
@@ -4,19 +4,26 @@ import "../../helpers/index.mjs";
4
4
  import { isEmptyValue } from "../../helpers/is-empty-value.mjs";
5
5
 
6
6
  //#region ../seal/src/rules/scalar/declined-rule.ts
7
+ /**
8
+ * The full set of values treated as "declined" by `declinedRule` and its
9
+ * conditional variants. Shared with `formBooleanMutator` (see
10
+ * `../../mutators/boolean-mutators`) so `v.boolean().declined()` recognizes
11
+ * exactly this list — single source of truth, no duplicated literals.
12
+ */
13
+ const DECLINED_VALUES = [
14
+ "0",
15
+ "false",
16
+ "no",
17
+ "n",
18
+ "off",
19
+ 0,
20
+ false,
21
+ "No",
22
+ "N",
23
+ "Off"
24
+ ];
7
25
  const isDeclinedValue = (value) => {
8
- return [
9
- "0",
10
- "false",
11
- "no",
12
- "n",
13
- "off",
14
- 0,
15
- false,
16
- "No",
17
- "N",
18
- "Off"
19
- ].includes(value);
26
+ return DECLINED_VALUES.includes(value);
20
27
  };
21
28
  /**
22
29
  * Validate value as declined if it equals:
@@ -112,5 +119,5 @@ const declinedWithoutRule = {
112
119
  };
113
120
 
114
121
  //#endregion
115
- export { declinedIfPresentRule, declinedIfRequiredRule, declinedIfRule, declinedRule, declinedUnlessRule, declinedWithoutRule };
122
+ export { DECLINED_VALUES, declinedIfPresentRule, declinedIfRequiredRule, declinedIfRule, declinedRule, declinedUnlessRule, declinedWithoutRule };
116
123
  //# sourceMappingURL=declined-rule.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"declined-rule.mjs","names":[],"sources":["../../../../../../../../seal/src/rules/scalar/declined-rule.ts"],"sourcesContent":["import { getFieldValue, invalidRule, VALID_RULE } from \"../../helpers\";\r\nimport { isEmptyValue } from \"../../helpers/is-empty-value\";\r\nimport type { SchemaRule } from \"../../types\";\r\n\r\nconst isDeclinedValue = (value: any) => {\r\n return [\"0\", \"false\", \"no\", \"n\", \"off\", 0, false, \"No\", \"N\", \"Off\"].includes(value);\r\n};\r\n\r\n/**\r\n * Validate value as declined if it equals:\r\n * 0 | \"0\" | false | \"false\" | \"no\" | \"n\" | \"off\" | 0 | false | \"No\" | \"N\" | \"Off\"\r\n */\r\nexport const declinedRule: SchemaRule = {\r\n name: \"declined\",\r\n defaultErrorMessage: \"The :input must be declined\",\r\n description:\r\n \"The value must be declined if it equals: 0 | '0' | false | 'false' | 'no' | 'n' | 'off' | 0 | false | 'No' | 'N' | 'Off'\",\r\n async validate(value: any, context) {\r\n if (isDeclinedValue(value)) {\r\n return VALID_RULE;\r\n }\r\n\r\n return invalidRule(this, context);\r\n },\r\n};\r\n\r\n/**\r\n * Declined value if another field's value equals to a specific value\r\n */\r\nexport const declinedIfRule: SchemaRule<{ field: string; value: any }> = {\r\n name: \"declinedIf\",\r\n description: \"The field must be declined if :field's value equals to :value\",\r\n defaultErrorMessage: \"The :input must be declined\",\r\n async validate(value: any, context) {\r\n const fieldValue = getFieldValue(this, context);\r\n const { value: expectedValue } = this.context.options;\r\n\r\n this.context.translatableParams.field = this.context.options.field;\r\n this.context.translatableParams.value = this.context.options.value;\r\n\r\n if (fieldValue !== expectedValue) {\r\n return invalidRule(this, context);\r\n }\r\n\r\n if (!isDeclinedValue(value)) {\r\n return invalidRule(this, context);\r\n }\r\n\r\n return VALID_RULE;\r\n },\r\n};\r\n\r\n/**\r\n * Declined if another field is not equal to the given value\r\n */\r\nexport const declinedUnlessRule: SchemaRule<{ field: string; value: any }> = {\r\n name: \"declinedUnless\",\r\n description: \"The field must be declined if :field's value is not equal to :value\",\r\n defaultErrorMessage: \"The :input must be declined\",\r\n async validate(value: any, context) {\r\n const fieldValue = getFieldValue(this, context);\r\n const { value: expectedValue } = this.context.options;\r\n\r\n this.context.translatableParams.field = this.context.options.field;\r\n this.context.translatableParams.value = this.context.options.value;\r\n if (fieldValue === expectedValue) {\r\n return invalidRule(this, context);\r\n }\r\n\r\n if (!isDeclinedValue(value)) {\r\n return invalidRule(this, context);\r\n }\r\n\r\n return VALID_RULE;\r\n },\r\n};\r\n\r\n/**\r\n * Declined if another field is required\r\n */\r\nexport const declinedIfRequiredRule: SchemaRule<{ field: string }> = {\r\n name: \"declinedIfRequired\",\r\n description: \"The field must be declined if :field is required\",\r\n defaultErrorMessage: \"The :input must be declined\",\r\n async validate(value: any, context) {\r\n const fieldValue = getFieldValue(this, context);\r\n this.context.translatableParams.field = this.context.options.field;\r\n\r\n if (isEmptyValue(fieldValue)) {\r\n return invalidRule(this, context);\r\n }\r\n\r\n if (!isDeclinedValue(value)) {\r\n return invalidRule(this, context);\r\n }\r\n\r\n return VALID_RULE;\r\n },\r\n};\r\n\r\n/**\r\n * Declined if another field is present\r\n */\r\nexport const declinedIfPresentRule: SchemaRule<{ field: string }> = {\r\n name: \"declinedIfPresent\",\r\n description: \"The field must be declined if :field is present\",\r\n defaultErrorMessage: \"The :input must be declined\",\r\n async validate(value: any, context) {\r\n const fieldValue = getFieldValue(this, context);\r\n this.context.translatableParams.field = this.context.options.field;\r\n\r\n if (fieldValue === undefined) {\r\n return invalidRule(this, context);\r\n }\r\n\r\n if (!isDeclinedValue(value)) {\r\n return invalidRule(this, context);\r\n }\r\n\r\n return VALID_RULE;\r\n },\r\n};\r\n\r\n/**\r\n * Declined if another field is missing\r\n */\r\nexport const declinedWithoutRule: SchemaRule<{ field: string }> = {\r\n name: \"declinedWithout\",\r\n description: \"The field must be declined if :field is missing\",\r\n defaultErrorMessage: \"The :input must be declined\",\r\n async validate(value: any, context) {\r\n const fieldValue = getFieldValue(this, context);\r\n this.context.translatableParams.field = this.context.options.field;\r\n\r\n if (fieldValue !== undefined) {\r\n return invalidRule(this, context);\r\n }\r\n\r\n if (!isDeclinedValue(value)) {\r\n return invalidRule(this, context);\r\n }\r\n\r\n return VALID_RULE;\r\n },\r\n};\r\n"],"mappings":";;;;;;AAIA,MAAM,mBAAmB,UAAe;CACtC,OAAO;EAAC;EAAK;EAAS;EAAM;EAAK;EAAO;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AQ,KAAK,QAAQ,QAAQ;EAE7D,IAAI,aAAa,UAAU,GACzB,OAAO,YAAY,MAAM,OAAO;EAGlC,IAAI,CAAC,gBAAgB,KAAK,GACxB,OAAO,YAAY,MAAM,OAAO;EAGlC,OAAO;CACT;AACF;;;;AAKA,MAAa,wBAAuD;CAClE,MAAM;CACN,aAAa;CACb,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAClC,MAAM,aAAa,cAAc,MAAM,OAAO;EAC9C,KAAK,QAAQ,mBAAmB,QAAQ,KAAK,QAAQ,QAAQ;EAE7D,IAAI,eAAe,QACjB,OAAO,YAAY,MAAM,OAAO;EAGlC,IAAI,CAAC,gBAAgB,KAAK,GACxB,OAAO,YAAY,MAAM,OAAO;EAGlC,OAAO;CACT;AACF;;;;AAKA,MAAa,sBAAqD;CAChE,MAAM;CACN,aAAa;CACb,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAClC,MAAM,aAAa,cAAc,MAAM,OAAO;EAC9C,KAAK,QAAQ,mBAAmB,QAAQ,KAAK,QAAQ,QAAQ;EAE7D,IAAI,eAAe,QACjB,OAAO,YAAY,MAAM,OAAO;EAGlC,IAAI,CAAC,gBAAgB,KAAK,GACxB,OAAO,YAAY,MAAM,OAAO;EAGlC,OAAO;CACT;AACF"}
1
+ {"version":3,"file":"declined-rule.mjs","names":[],"sources":["../../../../../../../../seal/src/rules/scalar/declined-rule.ts"],"sourcesContent":["import { getFieldValue, invalidRule, VALID_RULE } from \"../../helpers\";\r\nimport { isEmptyValue } from \"../../helpers/is-empty-value\";\r\nimport type { SchemaRule } from \"../../types\";\r\n\r\n/**\r\n * The full set of values treated as \"declined\" by `declinedRule` and its\r\n * conditional variants. Shared with `formBooleanMutator` (see\r\n * `../../mutators/boolean-mutators`) so `v.boolean().declined()` recognizes\r\n * exactly this list — single source of truth, no duplicated literals.\r\n */\r\nexport const DECLINED_VALUES: readonly unknown[] = [\r\n \"0\",\r\n \"false\",\r\n \"no\",\r\n \"n\",\r\n \"off\",\r\n 0,\r\n false,\r\n \"No\",\r\n \"N\",\r\n \"Off\",\r\n];\r\n\r\nconst isDeclinedValue = (value: any) => {\r\n return DECLINED_VALUES.includes(value);\r\n};\r\n\r\n/**\r\n * Validate value as declined if it equals:\r\n * 0 | \"0\" | false | \"false\" | \"no\" | \"n\" | \"off\" | 0 | false | \"No\" | \"N\" | \"Off\"\r\n */\r\nexport const declinedRule: SchemaRule = {\r\n name: \"declined\",\r\n defaultErrorMessage: \"The :input must be declined\",\r\n description:\r\n \"The value must be declined if it equals: 0 | '0' | false | 'false' | 'no' | 'n' | 'off' | 0 | false | 'No' | 'N' | 'Off'\",\r\n async validate(value: any, context) {\r\n if (isDeclinedValue(value)) {\r\n return VALID_RULE;\r\n }\r\n\r\n return invalidRule(this, context);\r\n },\r\n};\r\n\r\n/**\r\n * Declined value if another field's value equals to a specific value\r\n */\r\nexport const declinedIfRule: SchemaRule<{ field: string; value: any }> = {\r\n name: \"declinedIf\",\r\n description: \"The field must be declined if :field's value equals to :value\",\r\n defaultErrorMessage: \"The :input must be declined\",\r\n async validate(value: any, context) {\r\n const fieldValue = getFieldValue(this, context);\r\n const { value: expectedValue } = this.context.options;\r\n\r\n this.context.translatableParams.field = this.context.options.field;\r\n this.context.translatableParams.value = this.context.options.value;\r\n\r\n if (fieldValue !== expectedValue) {\r\n return invalidRule(this, context);\r\n }\r\n\r\n if (!isDeclinedValue(value)) {\r\n return invalidRule(this, context);\r\n }\r\n\r\n return VALID_RULE;\r\n },\r\n};\r\n\r\n/**\r\n * Declined if another field is not equal to the given value\r\n */\r\nexport const declinedUnlessRule: SchemaRule<{ field: string; value: any }> = {\r\n name: \"declinedUnless\",\r\n description: \"The field must be declined if :field's value is not equal to :value\",\r\n defaultErrorMessage: \"The :input must be declined\",\r\n async validate(value: any, context) {\r\n const fieldValue = getFieldValue(this, context);\r\n const { value: expectedValue } = this.context.options;\r\n\r\n this.context.translatableParams.field = this.context.options.field;\r\n this.context.translatableParams.value = this.context.options.value;\r\n if (fieldValue === expectedValue) {\r\n return invalidRule(this, context);\r\n }\r\n\r\n if (!isDeclinedValue(value)) {\r\n return invalidRule(this, context);\r\n }\r\n\r\n return VALID_RULE;\r\n },\r\n};\r\n\r\n/**\r\n * Declined if another field is required\r\n */\r\nexport const declinedIfRequiredRule: SchemaRule<{ field: string }> = {\r\n name: \"declinedIfRequired\",\r\n description: \"The field must be declined if :field is required\",\r\n defaultErrorMessage: \"The :input must be declined\",\r\n async validate(value: any, context) {\r\n const fieldValue = getFieldValue(this, context);\r\n this.context.translatableParams.field = this.context.options.field;\r\n\r\n if (isEmptyValue(fieldValue)) {\r\n return invalidRule(this, context);\r\n }\r\n\r\n if (!isDeclinedValue(value)) {\r\n return invalidRule(this, context);\r\n }\r\n\r\n return VALID_RULE;\r\n },\r\n};\r\n\r\n/**\r\n * Declined if another field is present\r\n */\r\nexport const declinedIfPresentRule: SchemaRule<{ field: string }> = {\r\n name: \"declinedIfPresent\",\r\n description: \"The field must be declined if :field is present\",\r\n defaultErrorMessage: \"The :input must be declined\",\r\n async validate(value: any, context) {\r\n const fieldValue = getFieldValue(this, context);\r\n this.context.translatableParams.field = this.context.options.field;\r\n\r\n if (fieldValue === undefined) {\r\n return invalidRule(this, context);\r\n }\r\n\r\n if (!isDeclinedValue(value)) {\r\n return invalidRule(this, context);\r\n }\r\n\r\n return VALID_RULE;\r\n },\r\n};\r\n\r\n/**\r\n * Declined if another field is missing\r\n */\r\nexport const declinedWithoutRule: SchemaRule<{ field: string }> = {\r\n name: \"declinedWithout\",\r\n description: \"The field must be declined if :field is missing\",\r\n defaultErrorMessage: \"The :input must be declined\",\r\n async validate(value: any, context) {\r\n const fieldValue = getFieldValue(this, context);\r\n this.context.translatableParams.field = this.context.options.field;\r\n\r\n if (fieldValue !== undefined) {\r\n return invalidRule(this, context);\r\n }\r\n\r\n if (!isDeclinedValue(value)) {\r\n return invalidRule(this, context);\r\n }\r\n\r\n return VALID_RULE;\r\n },\r\n};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,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAClC,MAAM,aAAa,cAAc,MAAM,OAAO;EAC9C,KAAK,QAAQ,mBAAmB,QAAQ,KAAK,QAAQ,QAAQ;EAE7D,IAAI,aAAa,UAAU,GACzB,OAAO,YAAY,MAAM,OAAO;EAGlC,IAAI,CAAC,gBAAgB,KAAK,GACxB,OAAO,YAAY,MAAM,OAAO;EAGlC,OAAO;CACT;AACF;;;;AAKA,MAAa,wBAAuD;CAClE,MAAM;CACN,aAAa;CACb,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAClC,MAAM,aAAa,cAAc,MAAM,OAAO;EAC9C,KAAK,QAAQ,mBAAmB,QAAQ,KAAK,QAAQ,QAAQ;EAE7D,IAAI,eAAe,QACjB,OAAO,YAAY,MAAM,OAAO;EAGlC,IAAI,CAAC,gBAAgB,KAAK,GACxB,OAAO,YAAY,MAAM,OAAO;EAGlC,OAAO;CACT;AACF;;;;AAKA,MAAa,sBAAqD;CAChE,MAAM;CACN,aAAa;CACb,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAClC,MAAM,aAAa,cAAc,MAAM,OAAO;EAC9C,KAAK,QAAQ,mBAAmB,QAAQ,KAAK,QAAQ,QAAQ;EAE7D,IAAI,eAAe,QACjB,OAAO,YAAY,MAAM,OAAO;EAGlC,IAAI,CAAC,gBAAgB,KAAK,GACxB,OAAO,YAAY,MAAM,OAAO;EAGlC,OAAO;CACT;AACF"}
@@ -1,4 +1,4 @@
1
- import { acceptedIfPresentRule, acceptedIfRequiredRule, acceptedIfRule, acceptedRule, acceptedUnlessRule, acceptedWithoutRule } from "./accepted-rule.mjs";
2
- import { declinedIfPresentRule, declinedIfRequiredRule, declinedIfRule, declinedRule, declinedUnlessRule, declinedWithoutRule } from "./declined-rule.mjs";
1
+ import { ACCEPTED_VALUES, acceptedIfPresentRule, acceptedIfRequiredRule, acceptedIfRule, acceptedRule, acceptedUnlessRule, acceptedWithoutRule } from "./accepted-rule.mjs";
2
+ import { DECLINED_VALUES, declinedIfPresentRule, declinedIfRequiredRule, declinedIfRule, declinedRule, declinedUnlessRule, declinedWithoutRule } from "./declined-rule.mjs";
3
3
 
4
4
  export { };
@@ -15,7 +15,26 @@ declare class BooleanValidator extends PrimitiveValidator {
15
15
  * Check if value is a boolean type
16
16
  */
17
17
  matchesType(value: any): boolean;
18
- /** Value must be accepted (true, "yes", 1, "on", etc.) */
18
+ /**
19
+ * Add a rule from the accepted/declined family, opting the validator into
20
+ * form-boolean parsing.
21
+ *
22
+ * Calling ANY `accepted*`/`declined*` method on `v.boolean()` adds (once,
23
+ * idempotently — checked by mutator identity so chaining several of these
24
+ * methods never stacks duplicates) `formBooleanMutator`, which runs before
25
+ * the type rule and converts the accepted set (`1`, `"1"`, `true`,
26
+ * `"true"`, `"yes"`, `"y"`, `"on"`, `"Yes"`, `"Y"`, `"On"`) to `true` and
27
+ * the declined set (`0`, `"0"`, `false`, `"false"`, `"no"`, `"n"`, `"off"`,
28
+ * `"No"`, `"N"`, `"Off"`) to `false`; any other value passes through
29
+ * unchanged and is rejected by the strict type rule as before.
30
+ *
31
+ * The mutator and the rule are added to the SAME resolved instance in one
32
+ * pass — resolving `this.instance` twice (once per `addRule`/`addMutator`
33
+ * call) would clone twice on an immutable validator and silently drop one
34
+ * of the two additions.
35
+ */
36
+ private addFormBooleanRule;
37
+ /** Value must be accepted (true, "yes", 1, "on", etc. — form strings are parsed into a real boolean first) */
19
38
  accepted(errorMessage?: string): this;
20
39
  /** Value must be accepted if another field equals a value */
21
40
  acceptedIf(field: string, value: any, errorMessage?: string): this;
@@ -27,7 +46,7 @@ declare class BooleanValidator extends PrimitiveValidator {
27
46
  acceptedIfPresent(field: string, errorMessage?: string): this;
28
47
  /** Value must be accepted if another field is missing */
29
48
  acceptedWithout(field: string, errorMessage?: string): this;
30
- /** Value must be declined (false, "no", 0, "off", etc.) */
49
+ /** Value must be declined (false, "no", 0, "off", etc. — form strings are parsed into a real boolean first) */
31
50
  declined(errorMessage?: string): this;
32
51
  /** Value must be declined if another field equals a value */
33
52
  declinedIf(field: string, value: any, errorMessage?: string): this;
@@ -49,7 +68,9 @@ declare class BooleanValidator extends PrimitiveValidator {
49
68
  * `2` all pass through unchanged and fail the type rule. `v.boolean()` does
50
69
  * **not** coerce by default; this only takes effect when explicitly chained.
51
70
  * For form-style truthy strings like `"yes"` / `"on"`, use `.accepted()` /
52
- * `.declined()` instead — those are separate pass/fail rules, not coercion.
71
+ * `.declined()` instead — those methods opt into their own form-boolean
72
+ * parsing (a wider value set, case-insensitive on a few forms) and then
73
+ * apply the accepted/declined pass-fail rule on top of the parsed boolean.
53
74
  *
54
75
  * The output type is unchanged (`Infer<>` keys off the validator class), so
55
76
  * `v.boolean().coerce()` still infers `boolean`.
@@ -1 +1 @@
1
- {"version":3,"file":"boolean-validator.d.mts","names":[],"sources":["../../../../../../../seal/src/validators/boolean-validator.ts"],"mappings":";;;;;;AA2BA;;;;;cAAa,gBAAA,SAAyB,kBAAA;cACjB,YAAA;EADmC;;;EAS/C,WAAA,CAAY,KAAA;EAAZ;EAOA,QAAA,CAAS,YAAA;EAAT;EAKA,UAAA,CAAW,KAAA,UAAe,KAAA,OAAY,YAAA;EAAtC;EAKA,cAAA,CAAe,KAAA,UAAe,KAAA,OAAY,YAAA;EALhB;EAU1B,kBAAA,CAAmB,KAAA,UAAe,YAAA;EALlC;EAUA,iBAAA,CAAkB,KAAA,UAAe,YAAA;EAVH;EAe9B,eAAA,CAAgB,KAAA,UAAe,YAAA;EAV/B;EAiBA,QAAA,CAAS,YAAA;EAjByB;EAsBlC,UAAA,CAAW,KAAA,UAAe,KAAA,OAAY,YAAA;EAjBpB;EAsBlB,cAAA,CAAe,KAAA,UAAe,KAAA,OAAY,YAAA;EAjB1C;EAsBA,kBAAA,CAAmB,KAAA,UAAe,YAAA;EAtBH;EA2B/B,iBAAA,CAAkB,KAAA,UAAe,YAAA;EApBxB;EAyBT,eAAA,CAAgB,KAAA,UAAe,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 +1,10 @@
1
1
  import { applyNullable } from "../standard-schema/json-schema.mjs";
2
- import { booleanCoerceMutator } from "../mutators/boolean-mutators.mjs";
2
+ import { acceptedIfPresentRule, acceptedIfRequiredRule, acceptedIfRule, acceptedRule, acceptedUnlessRule, acceptedWithoutRule } from "../rules/scalar/accepted-rule.mjs";
3
+ import { declinedIfPresentRule, declinedIfRequiredRule, declinedIfRule, declinedRule, declinedUnlessRule, declinedWithoutRule } from "../rules/scalar/declined-rule.mjs";
4
+ import { booleanCoerceMutator, formBooleanMutator } from "../mutators/boolean-mutators.mjs";
3
5
  import { booleanRule } from "../rules/common/type-rules.mjs";
4
6
  import "../rules/index.mjs";
5
7
  import { PrimitiveValidator } from "./primitive-validator.mjs";
6
- import { acceptedIfPresentRule, acceptedIfRequiredRule, acceptedIfRule, acceptedRule, acceptedUnlessRule, acceptedWithoutRule } from "../rules/scalar/accepted-rule.mjs";
7
- import { declinedIfPresentRule, declinedIfRequiredRule, declinedIfRule, declinedRule, declinedUnlessRule, declinedWithoutRule } from "../rules/scalar/declined-rule.mjs";
8
8
  import "../rules/scalar/index.mjs";
9
9
 
10
10
  //#region ../seal/src/validators/boolean-validator.ts
@@ -26,65 +26,89 @@ var BooleanValidator = class extends PrimitiveValidator {
26
26
  matchesType(value) {
27
27
  return typeof value === "boolean";
28
28
  }
29
- /** Value must be accepted (true, "yes", 1, "on", etc.) */
29
+ /**
30
+ * Add a rule from the accepted/declined family, opting the validator into
31
+ * form-boolean parsing.
32
+ *
33
+ * Calling ANY `accepted*`/`declined*` method on `v.boolean()` adds (once,
34
+ * idempotently — checked by mutator identity so chaining several of these
35
+ * methods never stacks duplicates) `formBooleanMutator`, which runs before
36
+ * the type rule and converts the accepted set (`1`, `"1"`, `true`,
37
+ * `"true"`, `"yes"`, `"y"`, `"on"`, `"Yes"`, `"Y"`, `"On"`) to `true` and
38
+ * the declined set (`0`, `"0"`, `false`, `"false"`, `"no"`, `"n"`, `"off"`,
39
+ * `"No"`, `"N"`, `"Off"`) to `false`; any other value passes through
40
+ * unchanged and is rejected by the strict type rule as before.
41
+ *
42
+ * The mutator and the rule are added to the SAME resolved instance in one
43
+ * pass — resolving `this.instance` twice (once per `addRule`/`addMutator`
44
+ * call) would clone twice on an immutable validator and silently drop one
45
+ * of the two additions.
46
+ */
47
+ addFormBooleanRule(rule, errorMessage, options = {}) {
48
+ const instance = this.instance;
49
+ if (!instance.mutators.some((mutator) => mutator.mutate === formBooleanMutator)) instance.addMutableMutator(formBooleanMutator);
50
+ instance.addMutableRule(rule, errorMessage, options);
51
+ return instance;
52
+ }
53
+ /** Value must be accepted (true, "yes", 1, "on", etc. — form strings are parsed into a real boolean first) */
30
54
  accepted(errorMessage) {
31
- return this.addRule(acceptedRule, errorMessage);
55
+ return this.addFormBooleanRule(acceptedRule, errorMessage);
32
56
  }
33
57
  /** Value must be accepted if another field equals a value */
34
58
  acceptedIf(field, value, errorMessage) {
35
- return this.addRule(acceptedIfRule, errorMessage, {
59
+ return this.addFormBooleanRule(acceptedIfRule, errorMessage, {
36
60
  field,
37
61
  value
38
62
  });
39
63
  }
40
64
  /** Value must be accepted unless another field equals a value */
41
65
  acceptedUnless(field, value, errorMessage) {
42
- return this.addRule(acceptedUnlessRule, errorMessage, {
66
+ return this.addFormBooleanRule(acceptedUnlessRule, errorMessage, {
43
67
  field,
44
68
  value
45
69
  });
46
70
  }
47
71
  /** Value must be accepted if another field is required */
48
72
  acceptedIfRequired(field, errorMessage) {
49
- return this.addRule(acceptedIfRequiredRule, errorMessage, { field });
73
+ return this.addFormBooleanRule(acceptedIfRequiredRule, errorMessage, { field });
50
74
  }
51
75
  /** Value must be accepted if another field is present */
52
76
  acceptedIfPresent(field, errorMessage) {
53
- return this.addRule(acceptedIfPresentRule, errorMessage, { field });
77
+ return this.addFormBooleanRule(acceptedIfPresentRule, errorMessage, { field });
54
78
  }
55
79
  /** Value must be accepted if another field is missing */
56
80
  acceptedWithout(field, errorMessage) {
57
- return this.addRule(acceptedWithoutRule, errorMessage, { field });
81
+ return this.addFormBooleanRule(acceptedWithoutRule, errorMessage, { field });
58
82
  }
59
- /** Value must be declined (false, "no", 0, "off", etc.) */
83
+ /** Value must be declined (false, "no", 0, "off", etc. — form strings are parsed into a real boolean first) */
60
84
  declined(errorMessage) {
61
- return this.addRule(declinedRule, errorMessage);
85
+ return this.addFormBooleanRule(declinedRule, errorMessage);
62
86
  }
63
87
  /** Value must be declined if another field equals a value */
64
88
  declinedIf(field, value, errorMessage) {
65
- return this.addRule(declinedIfRule, errorMessage, {
89
+ return this.addFormBooleanRule(declinedIfRule, errorMessage, {
66
90
  field,
67
91
  value
68
92
  });
69
93
  }
70
94
  /** Value must be declined unless another field equals a value */
71
95
  declinedUnless(field, value, errorMessage) {
72
- return this.addRule(declinedUnlessRule, errorMessage, {
96
+ return this.addFormBooleanRule(declinedUnlessRule, errorMessage, {
73
97
  field,
74
98
  value
75
99
  });
76
100
  }
77
101
  /** Value must be declined if another field is required */
78
102
  declinedIfRequired(field, errorMessage) {
79
- return this.addRule(declinedIfRequiredRule, errorMessage, { field });
103
+ return this.addFormBooleanRule(declinedIfRequiredRule, errorMessage, { field });
80
104
  }
81
105
  /** Value must be declined if another field is present */
82
106
  declinedIfPresent(field, errorMessage) {
83
- return this.addRule(declinedIfPresentRule, errorMessage, { field });
107
+ return this.addFormBooleanRule(declinedIfPresentRule, errorMessage, { field });
84
108
  }
85
109
  /** Value must be declined if another field is missing */
86
110
  declinedWithout(field, errorMessage) {
87
- return this.addRule(declinedWithoutRule, errorMessage, { field });
111
+ return this.addFormBooleanRule(declinedWithoutRule, errorMessage, { field });
88
112
  }
89
113
  /**
90
114
  * Opt in to coercion: an exact query-string-shaped boolean is converted to a
@@ -96,7 +120,9 @@ var BooleanValidator = class extends PrimitiveValidator {
96
120
  * `2` all pass through unchanged and fail the type rule. `v.boolean()` does
97
121
  * **not** coerce by default; this only takes effect when explicitly chained.
98
122
  * For form-style truthy strings like `"yes"` / `"on"`, use `.accepted()` /
99
- * `.declined()` instead — those are separate pass/fail rules, not coercion.
123
+ * `.declined()` instead — those methods opt into their own form-boolean
124
+ * parsing (a wider value set, case-insensitive on a few forms) and then
125
+ * apply the accepted/declined pass-fail rule on top of the parsed boolean.
100
126
  *
101
127
  * The output type is unchanged (`Infer<>` keys off the validator class), so
102
128
  * `v.boolean().coerce()` still infers `boolean`.
@@ -1 +1 @@
1
- {"version":3,"file":"boolean-validator.mjs","names":[],"sources":["../../../../../../../seal/src/validators/boolean-validator.ts"],"sourcesContent":["import { booleanCoerceMutator } from \"../mutators/boolean-mutators\";\nimport {\n acceptedIfPresentRule,\n acceptedIfRequiredRule,\n acceptedIfRule,\n acceptedRule,\n acceptedUnlessRule,\n acceptedWithoutRule,\n declinedIfPresentRule,\n declinedIfRequiredRule,\n declinedIfRule,\n declinedRule,\n declinedUnlessRule,\n declinedWithoutRule,\n} from \"../rules/scalar\";\nimport { booleanRule } from \"../rules\";\nimport { PrimitiveValidator } from \"./primitive-validator\";\nimport { applyNullable } from \"../standard-schema/json-schema\";\nimport type { JsonSchemaResult, JsonSchemaTarget } from \"../standard-schema/json-schema\";\n\n/**\n * Boolean validator class\n *\n * Extends PrimitiveValidator — inherits enum/in/oneOf/allowsOnly/forbids/notIn.\n * Defines accepted/declined directly as real methods (not ScalarValidator field copies)\n * so they survive cloning correctly.\n */\nexport class BooleanValidator extends PrimitiveValidator {\n public constructor(errorMessage?: string) {\n super();\n this.addMutableRule(booleanRule, errorMessage);\n }\n\n /**\n * Check if value is a boolean type\n */\n public matchesType(value: any): boolean {\n return typeof value === \"boolean\";\n }\n\n // ==================== Accepted ====================\n\n /** Value must be accepted (true, \"yes\", 1, \"on\", etc.) */\n public accepted(errorMessage?: string) {\n return this.addRule(acceptedRule, errorMessage);\n }\n\n /** Value must be accepted if another field equals a value */\n public acceptedIf(field: string, value: any, errorMessage?: string) {\n return this.addRule(acceptedIfRule, errorMessage, { field, value });\n }\n\n /** Value must be accepted unless another field equals a value */\n public acceptedUnless(field: string, value: any, errorMessage?: string) {\n return this.addRule(acceptedUnlessRule, errorMessage, { field, value });\n }\n\n /** Value must be accepted if another field is required */\n public acceptedIfRequired(field: string, errorMessage?: string) {\n return this.addRule(acceptedIfRequiredRule, errorMessage, { field });\n }\n\n /** Value must be accepted if another field is present */\n public acceptedIfPresent(field: string, errorMessage?: string) {\n return this.addRule(acceptedIfPresentRule, errorMessage, { field });\n }\n\n /** Value must be accepted if another field is missing */\n public acceptedWithout(field: string, errorMessage?: string) {\n return this.addRule(acceptedWithoutRule, errorMessage, { field });\n }\n\n // ==================== Declined ====================\n\n /** Value must be declined (false, \"no\", 0, \"off\", etc.) */\n public declined(errorMessage?: string) {\n return this.addRule(declinedRule, errorMessage);\n }\n\n /** Value must be declined if another field equals a value */\n public declinedIf(field: string, value: any, errorMessage?: string) {\n return this.addRule(declinedIfRule, errorMessage, { field, value });\n }\n\n /** Value must be declined unless another field equals a value */\n public declinedUnless(field: string, value: any, errorMessage?: string) {\n return this.addRule(declinedUnlessRule, errorMessage, { field, value });\n }\n\n /** Value must be declined if another field is required */\n public declinedIfRequired(field: string, errorMessage?: string) {\n return this.addRule(declinedIfRequiredRule, errorMessage, { field });\n }\n\n /** Value must be declined if another field is present */\n public declinedIfPresent(field: string, errorMessage?: string) {\n return this.addRule(declinedIfPresentRule, errorMessage, { field });\n }\n\n /** Value must be declined if another field is missing */\n public declinedWithout(field: string, errorMessage?: string) {\n return this.addRule(declinedWithoutRule, errorMessage, { field });\n }\n\n // ==================== Coercion ====================\n\n /**\n * Opt in to coercion: an exact query-string-shaped boolean is converted to a\n * real boolean **before** the type rules run; any other value passes through\n * unchanged so bad input still fails the type rule.\n *\n * Converts exactly `\"true\"` / `\"1\"` / `1` → `true` and `\"false\"` / `\"0\"` / `0`\n * → `false`. Case-sensitive, no trimming — `\"TRUE\"`, `\"yes\"`, `\"on\"`, `\"\"`, and\n * `2` all pass through unchanged and fail the type rule. `v.boolean()` does\n * **not** coerce by default; this only takes effect when explicitly chained.\n * For form-style truthy strings like `\"yes\"` / `\"on\"`, use `.accepted()` /\n * `.declined()` instead — those are separate pass/fail rules, not coercion.\n *\n * The output type is unchanged (`Infer<>` keys off the validator class), so\n * `v.boolean().coerce()` still infers `boolean`.\n *\n * @example\n * v.boolean().coerce() // \"true\" → true; \"1\" → true; \"0\" → false; \"yes\" → invalid\n */\n public coerce() {\n return this.addMutator(booleanCoerceMutator) as this & { isCoerced: true };\n }\n\n // ==================== Strict boolean checks ====================\n\n /**\n * Value must be strictly true (not \"yes\", \"on\", 1, etc.)\n * @alias accepted - strict version\n */\n public mustBeTrue(errorMessage?: string) {\n return this.equal(true, errorMessage);\n }\n\n /**\n * Value must be strictly false (not \"no\", \"off\", 0, etc.)\n * @alias declined - strict version\n */\n public mustBeFalse(errorMessage?: string) {\n return this.equal(false, errorMessage);\n }\n\n /**\n * @inheritdoc\n *\n * @note accepted/declined rules and all cross-field boolean rules\n * are not representable in JSON Schema and are silently omitted.\n *\n * @example\n * ```ts\n * v.boolean().toJsonSchema(\"draft-2020-12\")\n * // → { type: \"boolean\" }\n *\n * v.boolean().nullable().toJsonSchema(\"openapi-3.0\")\n * // → { type: \"boolean\", nullable: true }\n * ```\n */\n public override toJsonSchema(target: JsonSchemaTarget = \"draft-2020-12\"): JsonSchemaResult {\n const schema: JsonSchemaResult = { type: \"boolean\" };\n if (this.isNullable) applyNullable(schema, target);\n return schema;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AA2BA,IAAa,mBAAb,cAAsC,mBAAmB;CACvD,AAAO,YAAY,cAAuB;EACxC,MAAM;EACN,KAAK,eAAe,aAAa,YAAY;CAC/C;;;;CAKA,AAAO,YAAY,OAAqB;EACtC,OAAO,OAAO,UAAU;CAC1B;;CAKA,AAAO,SAAS,cAAuB;EACrC,OAAO,KAAK,QAAQ,cAAc,YAAY;CAChD;;CAGA,AAAO,WAAW,OAAe,OAAY,cAAuB;EAClE,OAAO,KAAK,QAAQ,gBAAgB,cAAc;GAAE;GAAO;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vC;;;;;;;;;;;;;;;;CAiBA,AAAgB,aAAa,SAA2B,iBAAmC;EACzF,MAAM,SAA2B,EAAE,MAAM,UAAU;EACnD,IAAI,KAAK,YAAY,cAAc,QAAQ,MAAM;EACjD,OAAO;CACT;AACF"}
1
+ {"version":3,"file":"boolean-validator.mjs","names":[],"sources":["../../../../../../../seal/src/validators/boolean-validator.ts"],"sourcesContent":["import { booleanCoerceMutator, formBooleanMutator } from \"../mutators/boolean-mutators\";\nimport {\n acceptedIfPresentRule,\n acceptedIfRequiredRule,\n acceptedIfRule,\n acceptedRule,\n acceptedUnlessRule,\n acceptedWithoutRule,\n declinedIfPresentRule,\n declinedIfRequiredRule,\n declinedIfRule,\n declinedRule,\n declinedUnlessRule,\n declinedWithoutRule,\n} from \"../rules/scalar\";\nimport { booleanRule } from \"../rules\";\nimport { PrimitiveValidator } from \"./primitive-validator\";\nimport { applyNullable } from \"../standard-schema/json-schema\";\nimport type { JsonSchemaResult, JsonSchemaTarget } from \"../standard-schema/json-schema\";\nimport type { SchemaRule, SchemaRuleOptions } from \"../types\";\n\n/**\n * Boolean validator class\n *\n * Extends PrimitiveValidator — inherits enum/in/oneOf/allowsOnly/forbids/notIn.\n * Defines accepted/declined directly as real methods (not ScalarValidator field copies)\n * so they survive cloning correctly.\n */\nexport class BooleanValidator extends PrimitiveValidator {\n public constructor(errorMessage?: string) {\n super();\n this.addMutableRule(booleanRule, errorMessage);\n }\n\n /**\n * Check if value is a boolean type\n */\n public matchesType(value: any): boolean {\n return typeof value === \"boolean\";\n }\n\n /**\n * Add a rule from the accepted/declined family, opting the validator into\n * form-boolean parsing.\n *\n * Calling ANY `accepted*`/`declined*` method on `v.boolean()` adds (once,\n * idempotently — checked by mutator identity so chaining several of these\n * methods never stacks duplicates) `formBooleanMutator`, which runs before\n * the type rule and converts the accepted set (`1`, `\"1\"`, `true`,\n * `\"true\"`, `\"yes\"`, `\"y\"`, `\"on\"`, `\"Yes\"`, `\"Y\"`, `\"On\"`) to `true` and\n * the declined set (`0`, `\"0\"`, `false`, `\"false\"`, `\"no\"`, `\"n\"`, `\"off\"`,\n * `\"No\"`, `\"N\"`, `\"Off\"`) to `false`; any other value passes through\n * unchanged and is rejected by the strict type rule as before.\n *\n * The mutator and the rule are added to the SAME resolved instance in one\n * pass — resolving `this.instance` twice (once per `addRule`/`addMutator`\n * call) would clone twice on an immutable validator and silently drop one\n * of the two additions.\n */\n private addFormBooleanRule<T extends SchemaRuleOptions = SchemaRuleOptions>(\n rule: SchemaRule<T>,\n errorMessage?: string,\n options: T = {} as T,\n ): this {\n const instance = this.instance;\n\n if (!instance.mutators.some((mutator) => mutator.mutate === formBooleanMutator)) {\n instance.addMutableMutator(formBooleanMutator);\n }\n\n instance.addMutableRule(rule, errorMessage, options);\n\n return instance;\n }\n\n // ==================== Accepted ====================\n\n /** Value must be accepted (true, \"yes\", 1, \"on\", etc. — form strings are parsed into a real boolean first) */\n public accepted(errorMessage?: string) {\n return this.addFormBooleanRule(acceptedRule, errorMessage);\n }\n\n /** Value must be accepted if another field equals a value */\n public acceptedIf(field: string, value: any, errorMessage?: string) {\n return this.addFormBooleanRule(acceptedIfRule, errorMessage, { field, value });\n }\n\n /** Value must be accepted unless another field equals a value */\n public acceptedUnless(field: string, value: any, errorMessage?: string) {\n return this.addFormBooleanRule(acceptedUnlessRule, errorMessage, { field, value });\n }\n\n /** Value must be accepted if another field is required */\n public acceptedIfRequired(field: string, errorMessage?: string) {\n return this.addFormBooleanRule(acceptedIfRequiredRule, errorMessage, { field });\n }\n\n /** Value must be accepted if another field is present */\n public acceptedIfPresent(field: string, errorMessage?: string) {\n return this.addFormBooleanRule(acceptedIfPresentRule, errorMessage, { field });\n }\n\n /** Value must be accepted if another field is missing */\n public acceptedWithout(field: string, errorMessage?: string) {\n return this.addFormBooleanRule(acceptedWithoutRule, errorMessage, { field });\n }\n\n // ==================== Declined ====================\n\n /** Value must be declined (false, \"no\", 0, \"off\", etc. — form strings are parsed into a real boolean first) */\n public declined(errorMessage?: string) {\n return this.addFormBooleanRule(declinedRule, errorMessage);\n }\n\n /** Value must be declined if another field equals a value */\n public declinedIf(field: string, value: any, errorMessage?: string) {\n return this.addFormBooleanRule(declinedIfRule, errorMessage, { field, value });\n }\n\n /** Value must be declined unless another field equals a value */\n public declinedUnless(field: string, value: any, errorMessage?: string) {\n return this.addFormBooleanRule(declinedUnlessRule, errorMessage, { field, value });\n }\n\n /** Value must be declined if another field is required */\n public declinedIfRequired(field: string, errorMessage?: string) {\n return this.addFormBooleanRule(declinedIfRequiredRule, errorMessage, { field });\n }\n\n /** Value must be declined if another field is present */\n public declinedIfPresent(field: string, errorMessage?: string) {\n return this.addFormBooleanRule(declinedIfPresentRule, errorMessage, { field });\n }\n\n /** Value must be declined if another field is missing */\n public declinedWithout(field: string, errorMessage?: string) {\n return this.addFormBooleanRule(declinedWithoutRule, errorMessage, { field });\n }\n\n // ==================== Coercion ====================\n\n /**\n * Opt in to coercion: an exact query-string-shaped boolean is converted to a\n * real boolean **before** the type rules run; any other value passes through\n * unchanged so bad input still fails the type rule.\n *\n * Converts exactly `\"true\"` / `\"1\"` / `1` → `true` and `\"false\"` / `\"0\"` / `0`\n * → `false`. Case-sensitive, no trimming — `\"TRUE\"`, `\"yes\"`, `\"on\"`, `\"\"`, and\n * `2` all pass through unchanged and fail the type rule. `v.boolean()` does\n * **not** coerce by default; this only takes effect when explicitly chained.\n * For form-style truthy strings like `\"yes\"` / `\"on\"`, use `.accepted()` /\n * `.declined()` instead — those methods opt into their own form-boolean\n * parsing (a wider value set, case-insensitive on a few forms) and then\n * apply the accepted/declined pass-fail rule on top of the parsed boolean.\n *\n * The output type is unchanged (`Infer<>` keys off the validator class), so\n * `v.boolean().coerce()` still infers `boolean`.\n *\n * @example\n * v.boolean().coerce() // \"true\" → true; \"1\" → true; \"0\" → false; \"yes\" → invalid\n */\n public coerce() {\n return this.addMutator(booleanCoerceMutator) as this & { isCoerced: true };\n }\n\n // ==================== Strict boolean checks ====================\n\n /**\n * Value must be strictly true (not \"yes\", \"on\", 1, etc.)\n * @alias accepted - strict version\n */\n public mustBeTrue(errorMessage?: string) {\n return this.equal(true, errorMessage);\n }\n\n /**\n * Value must be strictly false (not \"no\", \"off\", 0, etc.)\n * @alias declined - strict version\n */\n public mustBeFalse(errorMessage?: string) {\n return this.equal(false, errorMessage);\n }\n\n /**\n * @inheritdoc\n *\n * @note accepted/declined rules and all cross-field boolean rules\n * are not representable in JSON Schema and are silently omitted.\n *\n * @example\n * ```ts\n * v.boolean().toJsonSchema(\"draft-2020-12\")\n * // → { type: \"boolean\" }\n *\n * v.boolean().nullable().toJsonSchema(\"openapi-3.0\")\n * // → { type: \"boolean\", nullable: true }\n * ```\n */\n public override toJsonSchema(target: JsonSchemaTarget = \"draft-2020-12\"): JsonSchemaResult {\n const schema: JsonSchemaResult = { type: \"boolean\" };\n if (this.isNullable) applyNullable(schema, target);\n return schema;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AA4BA,IAAa,mBAAb,cAAsC,mBAAmB;CACvD,AAAO,YAAY,cAAuB;EACxC,MAAM;EACN,KAAK,eAAe,aAAa,YAAY;CAC/C;;;;CAKA,AAAO,YAAY,OAAqB;EACtC,OAAO,OAAO,UAAU;CAC1B;;;;;;;;;;;;;;;;;;;CAoBA,AAAQ,mBACN,MACA,cACA,UAAa,CAAC,GACR;EACN,MAAM,WAAW,KAAK;EAEtB,IAAI,CAAC,SAAS,SAAS,MAAM,YAAY,QAAQ,WAAW,kBAAkB,GAC5E,SAAS,kBAAkB,kBAAkB;EAG/C,SAAS,eAAe,MAAM,cAAc,OAAO;EAEnD,OAAO;CACT;;CAKA,AAAO,SAAS,cAAuB;EACrC,OAAO,KAAK,mBAAmB,cAAc,YAAY;CAC3D;;CAGA,AAAO,WAAW,OAAe,OAAY,cAAuB;EAClE,OAAO,KAAK,mBAAmB,gBAAgB,cAAc;GAAE;GAAO;EAAM,CAAC;CAC/E;;CAGA,AAAO,eAAe,OAAe,OAAY,cAAuB;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,aAAa,SAA2B,iBAAmC;EACzF,MAAM,SAA2B,EAAE,MAAM,UAAU;EACnD,IAAI,KAAK,YAAY,cAAc,QAAQ,MAAM;EACjD,OAAO;CACT;AACF"}
@@ -1,12 +1,12 @@
1
1
  import { getRuleOptions } from "../standard-schema/json-schema.mjs";
2
2
  import { VALID_RULE, invalidRule } from "../helpers/validation-helpers.mjs";
3
3
  import "../helpers/index.mjs";
4
+ import { acceptedIfPresentRule, acceptedIfRequiredRule, acceptedIfRule, acceptedRule, acceptedUnlessRule, acceptedWithoutRule } from "../rules/scalar/accepted-rule.mjs";
5
+ import { declinedIfPresentRule, declinedIfRequiredRule, declinedIfRule, declinedRule, declinedUnlessRule, declinedWithoutRule } from "../rules/scalar/declined-rule.mjs";
4
6
  import { numberMutator } from "../mutators/number-mutators.mjs";
5
7
  import { stringMutator } from "../mutators/scalar-mutators.mjs";
6
8
  import "../mutators/index.mjs";
7
9
  import { PrimitiveValidator } from "./primitive-validator.mjs";
8
- import { acceptedIfPresentRule, acceptedIfRequiredRule, acceptedIfRule, acceptedRule, acceptedUnlessRule, acceptedWithoutRule } from "../rules/scalar/accepted-rule.mjs";
9
- import { declinedIfPresentRule, declinedIfRequiredRule, declinedIfRule, declinedRule, declinedUnlessRule, declinedWithoutRule } from "../rules/scalar/declined-rule.mjs";
10
10
  import "../rules/scalar/index.mjs";
11
11
 
12
12
  //#region ../seal/src/validators/scalar-validator.ts