@warlock.js/seal 5.9.0 → 5.10.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 +8 -1
- package/cjs/index.cjs +37 -0
- package/cjs/index.cjs.map +1 -1
- package/esm/index.d.mts +2 -1
- package/esm/index.mjs +2 -1
- package/esm/mutators/boolean-mutators.d.mts +14 -0
- package/esm/mutators/boolean-mutators.d.mts.map +1 -0
- package/esm/mutators/boolean-mutators.mjs +17 -0
- package/esm/mutators/boolean-mutators.mjs.map +1 -0
- package/esm/mutators/index.mjs +1 -0
- package/esm/validators/boolean-validator.d.mts +21 -0
- package/esm/validators/boolean-validator.d.mts.map +1 -1
- package/esm/validators/boolean-validator.mjs +22 -0
- package/esm/validators/boolean-validator.mjs.map +1 -1
- package/llms-full.txt +24 -0
- package/package.json +1 -1
- package/skills/pick-seal-primitive/boolean-methods.md +46 -22
package/esm/index.d.mts
CHANGED
|
@@ -87,6 +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
91
|
import { addDaysMutator, addHoursMutator, addMonthsMutator, addYearsMutator, dateMutator, toDateOnlyMutator, toEndOfDayMutator, toEndOfMonthMutator, toEndOfYearMutator, toFormatMutator, toISOStringMutator, toStartOfDayMutator, toStartOfMonthMutator, toStartOfYearMutator, toTimeOnlyMutator, toTimestampMutator, toUTCMutator } from "./mutators/date-mutators.mjs";
|
|
91
92
|
import { absMutator, booleanMutator, ceilMutator, floorMutator, numberMutator, numericMutator, roundMutator, roundNumberMutator, toFixedMutator } from "./mutators/number-mutators.mjs";
|
|
92
93
|
import { jsonMutator, objectTrimMutator, stripUnknownMutator } from "./mutators/object-mutators.mjs";
|
|
@@ -97,7 +98,7 @@ import { ValidateOptions, ValidatorV, v } from "./factory/validators.mjs";
|
|
|
97
98
|
import { validate } from "./factory/validate.mjs";
|
|
98
99
|
import { PluginContext, SealPlugin, getInstalledPlugins, hasPlugin, registerPlugin, unregisterPlugin } from "./plugins/plugin-system.mjs";
|
|
99
100
|
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, 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, 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
102
|
import "./validators/methods/equality-conditional-methods.mjs";
|
|
102
103
|
import "./validators/methods/forbidden-methods.mjs";
|
|
103
104
|
import "./validators/methods/present-methods.mjs";
|
package/esm/index.mjs
CHANGED
|
@@ -12,6 +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
16
|
import { addDaysMutator, addHoursMutator, addMonthsMutator, addYearsMutator, dateMutator, toDateOnlyMutator, toEndOfDayMutator, toEndOfMonthMutator, toEndOfYearMutator, toFormatMutator, toISOStringMutator, toStartOfDayMutator, toStartOfMonthMutator, toStartOfYearMutator, toTimeOnlyMutator, toTimestampMutator, toUTCMutator } from "./mutators/date-mutators.mjs";
|
|
16
17
|
import { absMutator, booleanMutator, ceilMutator, floorMutator, numberMutator, numericMutator, roundMutator, roundNumberMutator, toFixedMutator } from "./mutators/number-mutators.mjs";
|
|
17
18
|
import { jsonMutator, objectTrimMutator, stripUnknownMutator } from "./mutators/object-mutators.mjs";
|
|
@@ -93,4 +94,4 @@ import { v } from "./factory/validators.mjs";
|
|
|
93
94
|
import "./factory/index.mjs";
|
|
94
95
|
import { getInstalledPlugins, hasPlugin, registerPlugin, unregisterPlugin } from "./plugins/plugin-system.mjs";
|
|
95
96
|
|
|
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 };
|
|
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 };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Mutator } from "../types/mutator-types.mjs";
|
|
2
|
+
|
|
3
|
+
//#region ../seal/src/mutators/boolean-mutators.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Coerce a query-string-shaped boolean into a real boolean.
|
|
6
|
+
*
|
|
7
|
+
* Converts exactly: `"true"` / `"1"` / `1` → `true`, `"false"` / `"0"` / `0` → `false`.
|
|
8
|
+
* Case-sensitive, no trimming. Any other value (`"yes"`, `"on"`, `"TRUE"`, `""`,
|
|
9
|
+
* `2`, `null`, etc.) passes through unchanged so the boolean type rule rejects it.
|
|
10
|
+
*/
|
|
11
|
+
declare const booleanCoerceMutator: Mutator;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { booleanCoerceMutator };
|
|
14
|
+
//# sourceMappingURL=boolean-mutators.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"boolean-mutators.d.mts","names":[],"sources":["../../../../../../../seal/src/mutators/boolean-mutators.ts"],"mappings":";;;;;AASA;;;;AAUC;cAVY,oBAAA,EAAsB,OAUlC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//#region ../seal/src/mutators/boolean-mutators.ts
|
|
2
|
+
/**
|
|
3
|
+
* Coerce a query-string-shaped boolean into a real boolean.
|
|
4
|
+
*
|
|
5
|
+
* Converts exactly: `"true"` / `"1"` / `1` → `true`, `"false"` / `"0"` / `0` → `false`.
|
|
6
|
+
* Case-sensitive, no trimming. Any other value (`"yes"`, `"on"`, `"TRUE"`, `""`,
|
|
7
|
+
* `2`, `null`, etc.) passes through unchanged so the boolean type rule rejects it.
|
|
8
|
+
*/
|
|
9
|
+
const booleanCoerceMutator = async (value) => {
|
|
10
|
+
if (value === "true" || value === "1" || value === 1) return true;
|
|
11
|
+
if (value === "false" || value === "0" || value === 0) return false;
|
|
12
|
+
return value;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
//#endregion
|
|
16
|
+
export { booleanCoerceMutator };
|
|
17
|
+
//# sourceMappingURL=boolean-mutators.mjs.map
|
|
@@ -0,0 +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"}
|
package/esm/mutators/index.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { flipArrayMutator, removeEmptyArrayElementsMutator, reverseArrayMutator, sortArrayMutator, uniqueArrayMutator } from "./array-mutators.mjs";
|
|
2
|
+
import { booleanCoerceMutator } from "./boolean-mutators.mjs";
|
|
2
3
|
import { addDaysMutator, addHoursMutator, addMonthsMutator, addYearsMutator, dateMutator, toDateOnlyMutator, toEndOfDayMutator, toEndOfMonthMutator, toEndOfYearMutator, toFormatMutator, toISOStringMutator, toStartOfDayMutator, toStartOfMonthMutator, toStartOfYearMutator, toTimeOnlyMutator, toTimestampMutator, toUTCMutator } from "./date-mutators.mjs";
|
|
3
4
|
import { absMutator, booleanMutator, ceilMutator, floorMutator, numberMutator, numericMutator, roundMutator, roundNumberMutator, toFixedMutator } from "./number-mutators.mjs";
|
|
4
5
|
import { jsonMutator, objectTrimMutator, stripUnknownMutator } from "./object-mutators.mjs";
|
|
@@ -39,6 +39,27 @@ declare class BooleanValidator extends PrimitiveValidator {
|
|
|
39
39
|
declinedIfPresent(field: string, errorMessage?: string): this;
|
|
40
40
|
/** Value must be declined if another field is missing */
|
|
41
41
|
declinedWithout(field: string, errorMessage?: string): this;
|
|
42
|
+
/**
|
|
43
|
+
* Opt in to coercion: an exact query-string-shaped boolean is converted to a
|
|
44
|
+
* real boolean **before** the type rules run; any other value passes through
|
|
45
|
+
* unchanged so bad input still fails the type rule.
|
|
46
|
+
*
|
|
47
|
+
* Converts exactly `"true"` / `"1"` / `1` → `true` and `"false"` / `"0"` / `0`
|
|
48
|
+
* → `false`. Case-sensitive, no trimming — `"TRUE"`, `"yes"`, `"on"`, `""`, and
|
|
49
|
+
* `2` all pass through unchanged and fail the type rule. `v.boolean()` does
|
|
50
|
+
* **not** coerce by default; this only takes effect when explicitly chained.
|
|
51
|
+
* For form-style truthy strings like `"yes"` / `"on"`, use `.accepted()` /
|
|
52
|
+
* `.declined()` instead — those are separate pass/fail rules, not coercion.
|
|
53
|
+
*
|
|
54
|
+
* The output type is unchanged (`Infer<>` keys off the validator class), so
|
|
55
|
+
* `v.boolean().coerce()` still infers `boolean`.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* v.boolean().coerce() // "true" → true; "1" → true; "0" → false; "yes" → invalid
|
|
59
|
+
*/
|
|
60
|
+
coerce(): this & {
|
|
61
|
+
isCoerced: true;
|
|
62
|
+
};
|
|
42
63
|
/**
|
|
43
64
|
* Value must be strictly true (not "yes", "on", 1, etc.)
|
|
44
65
|
* @alias accepted - strict version
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"boolean-validator.d.mts","names":[],"sources":["../../../../../../../seal/src/validators/boolean-validator.ts"],"mappings":";;;;;;
|
|
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,YAAA;EApBpB;;;;;;;;;;;;;;;;;;EA4CX,MAAA;IACoD,SAAA;EAAA;EAiBxC;;;;EARZ,UAAA,CAAW,YAAA;EA2BwE;AAAA;;;EAnBnF,WAAA,CAAY,YAAA;;;;;;;;;;;;;;;;EAmBH,YAAA,CAAa,MAAA,GAAQ,gBAAA,GAAqC,gBAAA;AAAA"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { applyNullable } from "../standard-schema/json-schema.mjs";
|
|
2
|
+
import { booleanCoerceMutator } from "../mutators/boolean-mutators.mjs";
|
|
2
3
|
import { booleanRule } from "../rules/common/type-rules.mjs";
|
|
3
4
|
import "../rules/index.mjs";
|
|
4
5
|
import { PrimitiveValidator } from "./primitive-validator.mjs";
|
|
@@ -86,6 +87,27 @@ var BooleanValidator = class extends PrimitiveValidator {
|
|
|
86
87
|
return this.addRule(declinedWithoutRule, errorMessage, { field });
|
|
87
88
|
}
|
|
88
89
|
/**
|
|
90
|
+
* Opt in to coercion: an exact query-string-shaped boolean is converted to a
|
|
91
|
+
* real boolean **before** the type rules run; any other value passes through
|
|
92
|
+
* unchanged so bad input still fails the type rule.
|
|
93
|
+
*
|
|
94
|
+
* Converts exactly `"true"` / `"1"` / `1` → `true` and `"false"` / `"0"` / `0`
|
|
95
|
+
* → `false`. Case-sensitive, no trimming — `"TRUE"`, `"yes"`, `"on"`, `""`, and
|
|
96
|
+
* `2` all pass through unchanged and fail the type rule. `v.boolean()` does
|
|
97
|
+
* **not** coerce by default; this only takes effect when explicitly chained.
|
|
98
|
+
* For form-style truthy strings like `"yes"` / `"on"`, use `.accepted()` /
|
|
99
|
+
* `.declined()` instead — those are separate pass/fail rules, not coercion.
|
|
100
|
+
*
|
|
101
|
+
* The output type is unchanged (`Infer<>` keys off the validator class), so
|
|
102
|
+
* `v.boolean().coerce()` still infers `boolean`.
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* v.boolean().coerce() // "true" → true; "1" → true; "0" → false; "yes" → invalid
|
|
106
|
+
*/
|
|
107
|
+
coerce() {
|
|
108
|
+
return this.addMutator(booleanCoerceMutator);
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
89
111
|
* Value must be strictly true (not "yes", "on", 1, etc.)
|
|
90
112
|
* @alias accepted - strict version
|
|
91
113
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"boolean-validator.mjs","names":[],"sources":["../../../../../../../seal/src/validators/boolean-validator.ts"],"sourcesContent":["import {\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 // ==================== 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":"
|
|
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;EAAM,CAAC;CACpE;;CAGA,AAAO,eAAe,OAAe,OAAY,cAAuB;EACtE,OAAO,KAAK,QAAQ,oBAAoB,cAAc;GAAE;GAAO;EAAM,CAAC;CACxE;;CAGA,AAAO,mBAAmB,OAAe,cAAuB;EAC9D,OAAO,KAAK,QAAQ,wBAAwB,cAAc,EAAE,MAAM,CAAC;CACrE;;CAGA,AAAO,kBAAkB,OAAe,cAAuB;EAC7D,OAAO,KAAK,QAAQ,uBAAuB,cAAc,EAAE,MAAM,CAAC;CACpE;;CAGA,AAAO,gBAAgB,OAAe,cAAuB;EAC3D,OAAO,KAAK,QAAQ,qBAAqB,cAAc,EAAE,MAAM,CAAC;CAClE;;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;EAAM,CAAC;CACpE;;CAGA,AAAO,eAAe,OAAe,OAAY,cAAuB;EACtE,OAAO,KAAK,QAAQ,oBAAoB,cAAc;GAAE;GAAO;EAAM,CAAC;CACxE;;CAGA,AAAO,mBAAmB,OAAe,cAAuB;EAC9D,OAAO,KAAK,QAAQ,wBAAwB,cAAc,EAAE,MAAM,CAAC;CACrE;;CAGA,AAAO,kBAAkB,OAAe,cAAuB;EAC7D,OAAO,KAAK,QAAQ,uBAAuB,cAAc,EAAE,MAAM,CAAC;CACpE;;CAGA,AAAO,gBAAgB,OAAe,cAAuB;EAC3D,OAAO,KAAK,QAAQ,qBAAqB,cAAc,EAAE,MAAM,CAAC;CAClE;;;;;;;;;;;;;;;;;;;CAsBA,AAAO,SAAS;EACd,OAAO,KAAK,WAAW,oBAAoB;CAC7C;;;;;CAQA,AAAO,WAAW,cAAuB;EACvC,OAAO,KAAK,MAAM,MAAM,YAAY;CACtC;;;;;CAMA,AAAO,YAAY,cAAuB;EACxC,OAAO,KAAK,MAAM,OAAO,YAAY;CACvC;;;;;;;;;;;;;;;;CAiBA,AAAgB,aAAa,SAA2B,iBAAmC;EACzF,MAAM,SAA2B,EAAE,MAAM,UAAU;EACnD,IAAI,KAAK,YAAY,cAAc,QAAQ,MAAM;EACjD,OAAO;CACT;AACF"}
|
package/llms-full.txt
CHANGED
|
@@ -1569,6 +1569,24 @@ The "accepted" rules treat `true`, `"yes"`, `"on"`, `1`, `"1"`, `"true"` as acce
|
|
|
1569
1569
|
| `.accepted(msg?)` | value must be accepted |
|
|
1570
1570
|
| `.declined(msg?)` | value must be declined |
|
|
1571
1571
|
|
|
1572
|
+
## Query-string coercion — `.coerce()`
|
|
1573
|
+
|
|
1574
|
+
`.coerce()` (5.10+) is the opt-in for query-string flags: `?active=true` arrives as the
|
|
1575
|
+
string `"true"`, and bare `v.boolean()` is strict by default — it rejects that string. Add
|
|
1576
|
+
`.coerce()` when a schema validates `request.query`:
|
|
1577
|
+
|
|
1578
|
+
```ts
|
|
1579
|
+
v.object({ active: v.boolean().coerce() }) // "true" → true, passes
|
|
1580
|
+
```
|
|
1581
|
+
|
|
1582
|
+
It converts *exactly* `"true"` / `"1"` / `1` → `true` and `"false"` / `"0"` / `0` → `false`.
|
|
1583
|
+
Case-sensitive, no trimming — anything else (`"yes"`, `"on"`, `"TRUE"`, `""`, `2`) passes
|
|
1584
|
+
through unchanged and still fails the type rule. That's the line between this and
|
|
1585
|
+
`accepted()`/`declined()` below: `.coerce()` is for the narrow, exact query-string
|
|
1586
|
+
serialization; `accepted()`/`declined()` are for broader form-style truthy strings like
|
|
1587
|
+
`"yes"`/`"on"`. `v.boolean()` does not coerce by default; the output type is unaffected
|
|
1588
|
+
(`v.boolean().coerce()` still infers `boolean`).
|
|
1589
|
+
|
|
1572
1590
|
## Conditional variants — accepted
|
|
1573
1591
|
|
|
1574
1592
|
| Method | Args | Effect |
|
|
@@ -1596,6 +1614,7 @@ All conditional variants only run inside `v.object` — sibling resolution silen
|
|
|
1596
1614
|
- `v.boolean()` → `{ type: "boolean" }`
|
|
1597
1615
|
- `.mustBeTrue()` / `.mustBeFalse()` — not currently emitted (could add `const: true/false` in the future)
|
|
1598
1616
|
- `.accepted()` / `.declined()` and their conditional variants — runtime coercion concerns, not representable
|
|
1617
|
+
- `.coerce()` — a pre-validation mutator, not representable; the schema still emits `{ type: "boolean" }`
|
|
1599
1618
|
|
|
1600
1619
|
## Common chains
|
|
1601
1620
|
|
|
@@ -1617,6 +1636,11 @@ v.object({
|
|
|
1617
1636
|
region: v.string(),
|
|
1618
1637
|
marketingOptIn: v.boolean().declinedUnless("region", "US"),
|
|
1619
1638
|
})
|
|
1639
|
+
|
|
1640
|
+
// Query-string flag — ?active=true
|
|
1641
|
+
v.object({
|
|
1642
|
+
active: v.boolean().coerce(),
|
|
1643
|
+
})
|
|
1620
1644
|
```
|
|
1621
1645
|
|
|
1622
1646
|
|
package/package.json
CHANGED
|
@@ -4,10 +4,10 @@ Picking guide is in [`@warlock.js/seal/pick-seal-primitive/SKILL.md`](@warlock.j
|
|
|
4
4
|
|
|
5
5
|
## Strict equality
|
|
6
6
|
|
|
7
|
-
| Method
|
|
8
|
-
|
|
9
|
-
| `.mustBeTrue(msg?)`
|
|
10
|
-
| `.mustBeFalse(msg?)` | strictly `=== false`
|
|
7
|
+
| Method | Effect |
|
|
8
|
+
| -------------------- | -------------------------------------------------- |
|
|
9
|
+
| `.mustBeTrue(msg?)` | strictly `=== true` (rejects `"yes"`, `1`, `"on"`) |
|
|
10
|
+
| `.mustBeFalse(msg?)` | strictly `=== false` |
|
|
11
11
|
|
|
12
12
|
Use these when the field is a real boolean checkbox value — e.g. "agree to terms" must be exactly `true`, not a truthy string.
|
|
13
13
|
|
|
@@ -15,30 +15,48 @@ Use these when the field is a real boolean checkbox value — e.g. "agree to ter
|
|
|
15
15
|
|
|
16
16
|
The "accepted" rules treat `true`, `"yes"`, `"on"`, `1`, `"1"`, `"true"` as accepted. "Declined" treats their counterparts (`false`, `"no"`, `"off"`, `0`, etc.) as declined. Designed for form inputs where a checkbox/radio arrives as a string.
|
|
17
17
|
|
|
18
|
-
| Method
|
|
19
|
-
|
|
18
|
+
| Method | Effect |
|
|
19
|
+
| ----------------- | ---------------------- |
|
|
20
20
|
| `.accepted(msg?)` | value must be accepted |
|
|
21
21
|
| `.declined(msg?)` | value must be declined |
|
|
22
22
|
|
|
23
|
+
## Query-string coercion — `.coerce()`
|
|
24
|
+
|
|
25
|
+
`.coerce()` (5.10+) is the opt-in for query-string flags: `?active=true` arrives as the
|
|
26
|
+
string `"true"`, and bare `v.boolean()` is strict by default — it rejects that string. Add
|
|
27
|
+
`.coerce()` when a schema validates `request.query`:
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
v.object({ active: v.boolean().coerce() }); // "true" → true, passes
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
It converts _exactly_ `"true"` / `"1"` / `1` → `true` and `"false"` / `"0"` / `0` → `false`.
|
|
34
|
+
Case-sensitive, no trimming — anything else (`"yes"`, `"on"`, `"TRUE"`, `""`, `2`) passes
|
|
35
|
+
through unchanged and still fails the type rule. That's the line between this and
|
|
36
|
+
`accepted()`/`declined()` below: `.coerce()` is for the narrow, exact query-string
|
|
37
|
+
serialization; `accepted()`/`declined()` are for broader form-style truthy strings like
|
|
38
|
+
`"yes"`/`"on"`. `v.boolean()` does not coerce by default; the output type is unaffected
|
|
39
|
+
(`v.boolean().coerce()` still infers `boolean`).
|
|
40
|
+
|
|
23
41
|
## Conditional variants — accepted
|
|
24
42
|
|
|
25
|
-
| Method
|
|
26
|
-
|
|
27
|
-
| `.acceptedIf(field, value, msg?)`
|
|
43
|
+
| Method | Args | Effect |
|
|
44
|
+
| ------------------------------------- | -------------------------- | ----------------------------------- |
|
|
45
|
+
| `.acceptedIf(field, value, msg?)` | sibling field equals value | must be accepted in that case |
|
|
28
46
|
| `.acceptedUnless(field, value, msg?)` | sibling field equals value | must be accepted unless that's true |
|
|
29
|
-
| `.acceptedIfRequired(field, msg?)`
|
|
30
|
-
| `.acceptedIfPresent(field, msg?)`
|
|
31
|
-
| `.acceptedWithout(field, msg?)`
|
|
47
|
+
| `.acceptedIfRequired(field, msg?)` | sibling field is required | — |
|
|
48
|
+
| `.acceptedIfPresent(field, msg?)` | sibling field is present | — |
|
|
49
|
+
| `.acceptedWithout(field, msg?)` | sibling field is absent | — |
|
|
32
50
|
|
|
33
51
|
## Conditional variants — declined
|
|
34
52
|
|
|
35
|
-
| Method
|
|
36
|
-
|
|
37
|
-
| `.declinedIf(field, value, msg?)`
|
|
53
|
+
| Method | Args | Effect |
|
|
54
|
+
| ------------------------------------- | -------------------------- | ----------------------------------- |
|
|
55
|
+
| `.declinedIf(field, value, msg?)` | sibling field equals value | must be declined in that case |
|
|
38
56
|
| `.declinedUnless(field, value, msg?)` | sibling field equals value | must be declined unless that's true |
|
|
39
|
-
| `.declinedIfRequired(field, msg?)`
|
|
40
|
-
| `.declinedIfPresent(field, msg?)`
|
|
41
|
-
| `.declinedWithout(field, msg?)`
|
|
57
|
+
| `.declinedIfRequired(field, msg?)` | — | — |
|
|
58
|
+
| `.declinedIfPresent(field, msg?)` | — | — |
|
|
59
|
+
| `.declinedWithout(field, msg?)` | — | — |
|
|
42
60
|
|
|
43
61
|
All conditional variants only run inside `v.object` — sibling resolution silently passes otherwise.
|
|
44
62
|
|
|
@@ -47,25 +65,31 @@ All conditional variants only run inside `v.object` — sibling resolution silen
|
|
|
47
65
|
- `v.boolean()` → `{ type: "boolean" }`
|
|
48
66
|
- `.mustBeTrue()` / `.mustBeFalse()` — not currently emitted (could add `const: true/false` in the future)
|
|
49
67
|
- `.accepted()` / `.declined()` and their conditional variants — runtime coercion concerns, not representable
|
|
68
|
+
- `.coerce()` — a pre-validation mutator, not representable; the schema still emits `{ type: "boolean" }`
|
|
50
69
|
|
|
51
70
|
## Common chains
|
|
52
71
|
|
|
53
72
|
```ts
|
|
54
73
|
// Strict consent checkbox
|
|
55
|
-
v.boolean().mustBeTrue("You must accept the terms")
|
|
74
|
+
v.boolean().mustBeTrue("You must accept the terms");
|
|
56
75
|
|
|
57
76
|
// Form-style "remember me" — accepts "on" / true / 1
|
|
58
|
-
v.boolean().accepted().optional()
|
|
77
|
+
v.boolean().accepted().optional();
|
|
59
78
|
|
|
60
79
|
// Cross-field — newsletter must be accepted if subscriptionType = "premium"
|
|
61
80
|
v.object({
|
|
62
81
|
subscriptionType: v.string().oneOf(["free", "premium"]),
|
|
63
82
|
newsletter: v.boolean().acceptedIf("subscriptionType", "premium"),
|
|
64
|
-
})
|
|
83
|
+
});
|
|
65
84
|
|
|
66
85
|
// Marketing opt-in — declined unless region is GDPR-exempt
|
|
67
86
|
v.object({
|
|
68
87
|
region: v.string(),
|
|
69
88
|
marketingOptIn: v.boolean().declinedUnless("region", "US"),
|
|
70
|
-
})
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
// Query-string flag — ?active=true
|
|
92
|
+
v.object({
|
|
93
|
+
active: v.boolean().coerce(),
|
|
94
|
+
});
|
|
71
95
|
```
|