@warlock.js/seal 5.24.0 → 5.26.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 +17 -0
- package/LICENSE +21 -21
- package/cjs/index.cjs +10 -5
- package/cjs/index.cjs.map +1 -1
- package/cjs/{object-DPPttDAF.cjs → object-BuKApaax.cjs} +3 -3
- package/cjs/object-BuKApaax.cjs.map +1 -0
- package/cjs/object.cjs +2 -2
- package/cjs/{required-methods-DJTm7yNP.cjs → required-methods-BOVNRtci.cjs} +12 -2
- package/cjs/required-methods-BOVNRtci.cjs.map +1 -0
- package/cjs/{string-C_pAtZPC.cjs → string-DpDpgefH.cjs} +2 -2
- package/cjs/string-DpDpgefH.cjs.map +1 -0
- package/cjs/string.cjs +2 -2
- package/esm/config.d.mts +0 -1
- package/esm/config.d.mts.map +1 -1
- package/esm/config.mjs.map +1 -1
- package/esm/factory/validate.mjs.map +1 -1
- package/esm/factory/validators.d.mts.map +1 -1
- package/esm/factory/validators.mjs +1 -1
- package/esm/factory/validators.mjs.map +1 -1
- package/esm/helpers/date-helpers.mjs.map +1 -1
- package/esm/helpers/get-field-value.d.mts +0 -1
- package/esm/helpers/get-field-value.d.mts.map +1 -1
- package/esm/helpers/get-field-value.mjs.map +1 -1
- package/esm/helpers/index.d.mts +5 -0
- package/esm/helpers/path-helpers.mjs.map +1 -1
- package/esm/helpers/validation-helpers.d.mts +0 -1
- package/esm/helpers/validation-helpers.d.mts.map +1 -1
- package/esm/mutators/array-mutators.d.mts +0 -1
- package/esm/mutators/array-mutators.d.mts.map +1 -1
- package/esm/mutators/array-mutators.mjs.map +1 -1
- package/esm/mutators/boolean-mutators.d.mts +0 -1
- package/esm/mutators/boolean-mutators.d.mts.map +1 -1
- package/esm/mutators/date-mutators.d.mts +0 -1
- package/esm/mutators/date-mutators.d.mts.map +1 -1
- package/esm/mutators/date-mutators.mjs.map +1 -1
- package/esm/mutators/index.d.mts +7 -0
- package/esm/mutators/number-mutators.d.mts +0 -1
- package/esm/mutators/number-mutators.d.mts.map +1 -1
- package/esm/mutators/number-mutators.mjs.map +1 -1
- package/esm/mutators/object-mutators.d.mts +0 -1
- package/esm/mutators/object-mutators.d.mts.map +1 -1
- package/esm/mutators/object-mutators.mjs.map +1 -1
- package/esm/mutators/scalar-mutators.d.mts +0 -1
- package/esm/mutators/scalar-mutators.d.mts.map +1 -1
- package/esm/mutators/scalar-mutators.mjs.map +1 -1
- package/esm/mutators/string-mutators.d.mts +0 -1
- package/esm/mutators/string-mutators.d.mts.map +1 -1
- package/esm/mutators/string-mutators.mjs.map +1 -1
- package/esm/plugins/plugin-system.mjs.map +1 -1
- package/esm/rules/array/array-rules.d.mts +0 -1
- package/esm/rules/array/array-rules.d.mts.map +1 -1
- package/esm/rules/array/array-rules.mjs.map +1 -1
- package/esm/rules/array/index.d.mts +1 -0
- package/esm/rules/color/color-rules.d.mts +0 -1
- package/esm/rules/color/color-rules.d.mts.map +1 -1
- package/esm/rules/color/color-rules.mjs.map +1 -1
- package/esm/rules/color/index.d.mts +1 -0
- package/esm/rules/common/enum.d.mts +0 -1
- package/esm/rules/common/enum.d.mts.map +1 -1
- package/esm/rules/common/enum.mjs.map +1 -1
- package/esm/rules/common/equals-field-rules.d.mts +0 -1
- package/esm/rules/common/equals-field-rules.d.mts.map +1 -1
- package/esm/rules/common/equals-field-rules.mjs.map +1 -1
- package/esm/rules/common/index.d.mts +6 -0
- package/esm/rules/common/instanceof.d.mts +0 -1
- package/esm/rules/common/instanceof.d.mts.map +1 -1
- package/esm/rules/common/literal.d.mts +0 -1
- package/esm/rules/common/literal.d.mts.map +1 -1
- package/esm/rules/common/type-rules.d.mts +0 -1
- package/esm/rules/common/type-rules.d.mts.map +1 -1
- package/esm/rules/common/type-rules.mjs.map +1 -1
- package/esm/rules/common/unknown-key.d.mts +0 -1
- package/esm/rules/common/unknown-key.d.mts.map +1 -1
- package/esm/rules/conditional/forbidden-if-rules.d.mts +0 -1
- package/esm/rules/conditional/forbidden-if-rules.d.mts.map +1 -1
- package/esm/rules/conditional/forbidden-if-rules.mjs.map +1 -1
- package/esm/rules/conditional/index.d.mts +10 -0
- package/esm/rules/conditional/present-if-rules.d.mts +0 -1
- package/esm/rules/conditional/present-if-rules.d.mts.map +1 -1
- package/esm/rules/conditional/present-if-rules.mjs.map +1 -1
- package/esm/rules/conditional/present-unless-rules.d.mts +0 -1
- package/esm/rules/conditional/present-unless-rules.d.mts.map +1 -1
- package/esm/rules/conditional/present-unless-rules.mjs.map +1 -1
- package/esm/rules/conditional/present-with-rules.d.mts +0 -1
- package/esm/rules/conditional/present-with-rules.d.mts.map +1 -1
- package/esm/rules/conditional/present-with-rules.mjs.map +1 -1
- package/esm/rules/conditional/present-without-rules.d.mts +0 -1
- package/esm/rules/conditional/present-without-rules.d.mts.map +1 -1
- package/esm/rules/conditional/present-without-rules.mjs.map +1 -1
- package/esm/rules/conditional/required-if-rules.d.mts +0 -1
- package/esm/rules/conditional/required-if-rules.d.mts.map +1 -1
- package/esm/rules/conditional/required-if-rules.mjs.map +1 -1
- package/esm/rules/conditional/required-unless-rules.d.mts +0 -1
- package/esm/rules/conditional/required-unless-rules.d.mts.map +1 -1
- package/esm/rules/conditional/required-unless-rules.mjs.map +1 -1
- package/esm/rules/conditional/required-when-rule.d.mts +0 -1
- package/esm/rules/conditional/required-when-rule.d.mts.map +1 -1
- package/esm/rules/conditional/required-with-rules.d.mts +0 -1
- package/esm/rules/conditional/required-with-rules.d.mts.map +1 -1
- package/esm/rules/conditional/required-with-rules.mjs.map +1 -1
- package/esm/rules/conditional/required-without-rules.d.mts +0 -1
- package/esm/rules/conditional/required-without-rules.d.mts.map +1 -1
- package/esm/rules/conditional/required-without-rules.mjs.map +1 -1
- package/esm/rules/core/equal.d.mts +0 -1
- package/esm/rules/core/equal.d.mts.map +1 -1
- package/esm/rules/core/equal.mjs.map +1 -1
- package/esm/rules/core/forbidden.d.mts +0 -1
- package/esm/rules/core/forbidden.d.mts.map +1 -1
- package/esm/rules/core/forbidden.mjs.map +1 -1
- package/esm/rules/core/index.d.mts +5 -0
- package/esm/rules/core/required.d.mts +0 -1
- package/esm/rules/core/required.d.mts.map +1 -1
- package/esm/rules/core/required.mjs.map +1 -1
- package/esm/rules/core/union.d.mts.map +1 -1
- package/esm/rules/core/union.mjs.map +1 -1
- package/esm/rules/core/when.d.mts +0 -1
- package/esm/rules/core/when.d.mts.map +1 -1
- package/esm/rules/core/when.mjs.map +1 -1
- package/esm/rules/date/date-comparison-rules.d.mts +0 -1
- package/esm/rules/date/date-comparison-rules.d.mts.map +1 -1
- package/esm/rules/date/date-comparison-rules.mjs.map +1 -1
- package/esm/rules/date/date-day-rules.d.mts +0 -1
- package/esm/rules/date/date-day-rules.d.mts.map +1 -1
- package/esm/rules/date/date-day-rules.mjs.map +1 -1
- package/esm/rules/date/date-field-comparison-rules.d.mts +0 -1
- package/esm/rules/date/date-field-comparison-rules.d.mts.map +1 -1
- package/esm/rules/date/date-field-comparison-rules.mjs.map +1 -1
- package/esm/rules/date/date-period-rules.d.mts +0 -1
- package/esm/rules/date/date-period-rules.d.mts.map +1 -1
- package/esm/rules/date/date-period-rules.mjs.map +1 -1
- package/esm/rules/date/date-relative-rules.d.mts +0 -1
- package/esm/rules/date/date-relative-rules.d.mts.map +1 -1
- package/esm/rules/date/date-relative-rules.mjs.map +1 -1
- package/esm/rules/date/date-special-rules.d.mts +0 -1
- package/esm/rules/date/date-special-rules.d.mts.map +1 -1
- package/esm/rules/date/date-special-rules.mjs.map +1 -1
- package/esm/rules/date/date.d.mts +0 -1
- package/esm/rules/date/date.d.mts.map +1 -1
- package/esm/rules/date/date.mjs.map +1 -1
- package/esm/rules/date/index.d.mts +7 -0
- package/esm/rules/file/dimensions.d.mts +0 -1
- package/esm/rules/file/dimensions.d.mts.map +1 -1
- package/esm/rules/file/dimensions.mjs.map +1 -1
- package/esm/rules/file/file-size.d.mts +0 -1
- package/esm/rules/file/file-size.d.mts.map +1 -1
- package/esm/rules/file/file-size.mjs.map +1 -1
- package/esm/rules/file/index.d.mts +2 -0
- package/esm/rules/index.d.mts +45 -0
- package/esm/rules/length/index.d.mts +1 -0
- package/esm/rules/length/length-rules.d.mts +0 -1
- package/esm/rules/length/length-rules.d.mts.map +1 -1
- package/esm/rules/length/length-rules.mjs.map +1 -1
- package/esm/rules/number/index.d.mts +1 -0
- package/esm/rules/number/number-rules.d.mts +0 -1
- package/esm/rules/number/number-rules.d.mts.map +1 -1
- package/esm/rules/number/number-rules.mjs.map +1 -1
- package/esm/rules/scalar/accepted-rule.mjs.map +1 -1
- package/esm/rules/scalar/declined-rule.mjs.map +1 -1
- package/esm/rules/string/alpha.d.mts +0 -1
- package/esm/rules/string/alpha.d.mts.map +1 -1
- package/esm/rules/string/alpha.mjs.map +1 -1
- package/esm/rules/string/credit-card.d.mts +0 -1
- package/esm/rules/string/credit-card.d.mts.map +1 -1
- package/esm/rules/string/credit-card.mjs.map +1 -1
- package/esm/rules/string/email.d.mts +0 -1
- package/esm/rules/string/email.d.mts.map +1 -1
- package/esm/rules/string/email.mjs.map +1 -1
- package/esm/rules/string/id-formats.d.mts +0 -1
- package/esm/rules/string/id-formats.d.mts.map +1 -1
- package/esm/rules/string/index.d.mts +11 -0
- package/esm/rules/string/ip.d.mts +0 -1
- package/esm/rules/string/ip.d.mts.map +1 -1
- package/esm/rules/string/matches.d.mts +0 -1
- package/esm/rules/string/matches.d.mts.map +1 -1
- package/esm/rules/string/matches.mjs.map +1 -1
- package/esm/rules/string/pattern.d.mts +0 -1
- package/esm/rules/string/pattern.d.mts.map +1 -1
- package/esm/rules/string/pattern.mjs.map +1 -1
- package/esm/rules/string/string-comparison.d.mts +0 -1
- package/esm/rules/string/string-comparison.d.mts.map +1 -1
- package/esm/rules/string/string-comparison.mjs.map +1 -1
- package/esm/rules/string/strong-password-rule.d.mts +0 -1
- package/esm/rules/string/strong-password-rule.d.mts.map +1 -1
- package/esm/rules/string/strong-password-rule.mjs.map +1 -1
- package/esm/rules/string/url.d.mts +0 -1
- package/esm/rules/string/url.d.mts.map +1 -1
- package/esm/rules/string/url.mjs.map +1 -1
- package/esm/rules/string/without-whitespace.d.mts +0 -1
- package/esm/rules/string/without-whitespace.d.mts.map +1 -1
- package/esm/rules/string/without-whitespace.mjs.map +1 -1
- package/esm/standard-schema/index.d.mts +3 -0
- package/esm/standard-schema/map-result.d.mts +0 -1
- package/esm/standard-schema/map-result.d.mts.map +1 -1
- package/esm/types/date-types.mjs.map +1 -1
- package/esm/types/index.d.mts +10 -0
- package/esm/validators/any-validator.mjs.map +1 -1
- package/esm/validators/array-validator.d.mts.map +1 -1
- package/esm/validators/array-validator.mjs +1 -0
- package/esm/validators/array-validator.mjs.map +1 -1
- package/esm/validators/base-validator.d.mts +2 -1
- package/esm/validators/base-validator.d.mts.map +1 -1
- package/esm/validators/base-validator.mjs +11 -1
- package/esm/validators/base-validator.mjs.map +1 -1
- package/esm/validators/boolean-validator.d.mts.map +1 -1
- package/esm/validators/boolean-validator.mjs +1 -0
- package/esm/validators/boolean-validator.mjs.map +1 -1
- package/esm/validators/computed-validator.d.mts.map +1 -1
- package/esm/validators/date-validator.d.mts +0 -1
- package/esm/validators/date-validator.d.mts.map +1 -1
- package/esm/validators/date-validator.mjs +1 -0
- package/esm/validators/date-validator.mjs.map +1 -1
- package/esm/validators/discriminated-union-validator.d.mts.map +1 -1
- package/esm/validators/float-validator.mjs.map +1 -1
- package/esm/validators/int-validator.mjs.map +1 -1
- package/esm/validators/lazy-validator.d.mts.map +1 -1
- package/esm/validators/literal-validator.d.mts.map +1 -1
- package/esm/validators/literal-validator.mjs +1 -3
- package/esm/validators/literal-validator.mjs.map +1 -1
- package/esm/validators/managed-validator.d.mts.map +1 -1
- package/esm/validators/methods/equality-conditional-methods.d.mts +0 -1
- package/esm/validators/methods/equality-conditional-methods.d.mts.map +1 -1
- package/esm/validators/methods/equality-conditional-methods.mjs.map +1 -1
- package/esm/validators/methods/forbidden-methods.mjs.map +1 -1
- package/esm/validators/methods/present-methods.mjs.map +1 -1
- package/esm/validators/methods/required-methods.d.mts +0 -1
- package/esm/validators/methods/required-methods.d.mts.map +1 -1
- package/esm/validators/methods/required-methods.mjs.map +1 -1
- package/esm/validators/number-validator.d.mts.map +1 -1
- package/esm/validators/number-validator.mjs +1 -0
- package/esm/validators/number-validator.mjs.map +1 -1
- package/esm/validators/numeric-validator.mjs.map +1 -1
- package/esm/validators/object-validator.d.mts.map +1 -1
- package/esm/validators/object-validator.mjs +1 -1
- package/esm/validators/object-validator.mjs.map +1 -1
- package/esm/validators/record-validator.d.mts.map +1 -1
- package/esm/validators/record-validator.mjs.map +1 -1
- package/esm/validators/scalar-validator.d.mts.map +1 -1
- package/esm/validators/scalar-validator.mjs +1 -0
- package/esm/validators/scalar-validator.mjs.map +1 -1
- package/esm/validators/string-validator.mjs.map +1 -1
- package/esm/validators/tuple-validator.d.mts.map +1 -1
- package/esm/validators/tuple-validator.mjs.map +1 -1
- package/esm/validators/union-validator.mjs.map +1 -1
- package/llms-full.txt +1166 -1168
- package/llms.txt +1 -1
- package/package.json +1 -1
- package/skills/bridge-standard-schema/SKILL.md +138 -138
- package/skills/define-structural-shape/SKILL.md +138 -138
- package/skills/extend-seal-with-plugins/SKILL.md +178 -178
- package/skills/generate-json-schema/SKILL.md +143 -143
- package/skills/handle-seal-errors/SKILL.md +148 -148
- package/skills/pick-seal-primitive/SKILL.md +149 -149
- package/cjs/object-DPPttDAF.cjs.map +0 -1
- package/cjs/required-methods-DJTm7yNP.cjs.map +0 -1
- package/cjs/string-C_pAtZPC.cjs.map +0 -1
|
@@ -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\";\
|
|
1
|
+
{"version":3,"file":"accepted-rule.mjs","names":[],"sources":["../../../../../../../../seal/src/rules/scalar/accepted-rule.ts"],"sourcesContent":["import { getFieldValue, invalidRule, VALID_RULE } from \"../../helpers\";\nimport { isEmptyValue } from \"../../helpers/is-empty-value\";\nimport type { SchemaRule } from \"../../types\";\n\n/**\n * The full set of values treated as \"accepted\" by `acceptedRule` and its\n * conditional variants. Shared with `formBooleanMutator` (see\n * `../../mutators/boolean-mutators`) so `v.boolean().accepted()` recognizes\n * exactly this list — single source of truth, no duplicated literals.\n */\nexport const ACCEPTED_VALUES: readonly unknown[] = [\n \"1\",\n \"true\",\n \"yes\",\n \"y\",\n \"on\",\n 1,\n true,\n \"Yes\",\n \"Y\",\n \"On\",\n];\n\nconst isAcceptedValue = (value: any) => {\n return ACCEPTED_VALUES.includes(value);\n};\n\n/**\n * Validate value as accepted if it equals:\n * 1 | \"1\" | true | \"true\" | \"yes\" | \"y\" | \"on\"\n */\nexport const acceptedRule: SchemaRule = {\n name: \"accepted\",\n defaultErrorMessage: \"The :input must be accepted\",\n description:\n \"The value must be accepted if it equals: 1 | '1' | true | 'true' | 'yes' | 'y' | 'on' | 1 | true | 'Yes' | 'Y' | 'On'\",\n async validate(value: any, context) {\n if (isAcceptedValue(value)) {\n return VALID_RULE;\n }\n\n return invalidRule(this, context);\n },\n};\n\n/**\n * Accepted value if another field's value equals to a specific value\n */\nexport const acceptedIfRule: SchemaRule<{ field: string; value: any }> = {\n name: \"acceptedIf\",\n description: \"The field must be accepted if :field's value equals to :value\",\n defaultErrorMessage: \"The :input must be accepted\",\n async validate(value: any, context) {\n const fieldValue = getFieldValue(this, context);\n const { value: expectedValue } = this.context.options;\n\n this.context.translatableParams.field = this.context.options.field;\n this.context.translatableParams.value = this.context.options.value;\n if (fieldValue !== expectedValue) {\n return invalidRule(this, context);\n }\n\n if (!isAcceptedValue(value)) {\n return invalidRule(this, context);\n }\n\n return VALID_RULE;\n },\n};\n\n/**\n * Accepted if another field is not equal to the given value\n */\nexport const acceptedUnlessRule: SchemaRule<{ field: string; value: any }> = {\n name: \"acceptedUnless\",\n description: \"The field must be accepted if :field's value is not equal to :value\",\n defaultErrorMessage: \"The :input must be accepted\",\n async validate(value: any, context) {\n const fieldValue = getFieldValue(this, context);\n const { value: expectedValue } = this.context.options;\n\n this.context.translatableParams.field = this.context.options.field;\n this.context.translatableParams.value = this.context.options.value;\n\n if (fieldValue === expectedValue) {\n return invalidRule(this, context);\n }\n\n if (!isAcceptedValue(value)) {\n return invalidRule(this, context);\n }\n\n return VALID_RULE;\n },\n};\n\n/**\n * Accepted if another field is required\n */\nexport const acceptedIfRequiredRule: SchemaRule<{ field: string }> = {\n name: \"acceptedIfRequired\",\n description: \"The field must be accepted if :field is required\",\n defaultErrorMessage: \"The :input must be accepted\",\n async validate(value: any, context) {\n const fieldValue = getFieldValue(this, context);\n this.context.translatableParams.field = this.context.options.field;\n\n if (isEmptyValue(fieldValue)) {\n return invalidRule(this, context);\n }\n\n if (!isAcceptedValue(value)) {\n return invalidRule(this, context);\n }\n\n return VALID_RULE;\n },\n};\n\n/**\n * Accepted if another field is present\n */\nexport const acceptedIfPresentRule: SchemaRule<{ field: string }> = {\n name: \"acceptedIfPresent\",\n description: \"The field must be accepted if :field is present\",\n defaultErrorMessage: \"The :input must be accepted\",\n async validate(value: any, context) {\n const fieldValue = getFieldValue(this, context);\n this.context.translatableParams.field = this.context.options.field;\n\n if (fieldValue === undefined) {\n return invalidRule(this, context);\n }\n\n if (!isAcceptedValue(value)) {\n return invalidRule(this, context);\n }\n\n return VALID_RULE;\n },\n};\n\n/**\n * Accepted if another field is missing\n */\nexport const acceptedWithoutRule: SchemaRule<{ field: string }> = {\n name: \"acceptedWithout\",\n description: \"The field must be accepted if :field is missing\",\n defaultErrorMessage: \"The :input must be accepted\",\n async validate(value: any, context) {\n const fieldValue = getFieldValue(this, context);\n this.context.translatableParams.field = this.context.options.field;\n\n if (fieldValue !== undefined) {\n return invalidRule(this, context);\n }\n\n if (!isAcceptedValue(value)) {\n return invalidRule(this, context);\n }\n\n return VALID_RULE;\n },\n};\n"],"mappings":";;;;;;;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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 +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\";\
|
|
1
|
+
{"version":3,"file":"declined-rule.mjs","names":[],"sources":["../../../../../../../../seal/src/rules/scalar/declined-rule.ts"],"sourcesContent":["import { getFieldValue, invalidRule, VALID_RULE } from \"../../helpers\";\nimport { isEmptyValue } from \"../../helpers/is-empty-value\";\nimport type { SchemaRule } from \"../../types\";\n\n/**\n * The full set of values treated as \"declined\" by `declinedRule` and its\n * conditional variants. Shared with `formBooleanMutator` (see\n * `../../mutators/boolean-mutators`) so `v.boolean().declined()` recognizes\n * exactly this list — single source of truth, no duplicated literals.\n */\nexport const DECLINED_VALUES: readonly unknown[] = [\n \"0\",\n \"false\",\n \"no\",\n \"n\",\n \"off\",\n 0,\n false,\n \"No\",\n \"N\",\n \"Off\",\n];\n\nconst isDeclinedValue = (value: any) => {\n return DECLINED_VALUES.includes(value);\n};\n\n/**\n * Validate value as declined if it equals:\n * 0 | \"0\" | false | \"false\" | \"no\" | \"n\" | \"off\" | 0 | false | \"No\" | \"N\" | \"Off\"\n */\nexport const declinedRule: SchemaRule = {\n name: \"declined\",\n defaultErrorMessage: \"The :input must be declined\",\n description:\n \"The value must be declined if it equals: 0 | '0' | false | 'false' | 'no' | 'n' | 'off' | 0 | false | 'No' | 'N' | 'Off'\",\n async validate(value: any, context) {\n if (isDeclinedValue(value)) {\n return VALID_RULE;\n }\n\n return invalidRule(this, context);\n },\n};\n\n/**\n * Declined value if another field's value equals to a specific value\n */\nexport const declinedIfRule: SchemaRule<{ field: string; value: any }> = {\n name: \"declinedIf\",\n description: \"The field must be declined if :field's value equals to :value\",\n defaultErrorMessage: \"The :input must be declined\",\n async validate(value: any, context) {\n const fieldValue = getFieldValue(this, context);\n const { value: expectedValue } = this.context.options;\n\n this.context.translatableParams.field = this.context.options.field;\n this.context.translatableParams.value = this.context.options.value;\n\n if (fieldValue !== expectedValue) {\n return invalidRule(this, context);\n }\n\n if (!isDeclinedValue(value)) {\n return invalidRule(this, context);\n }\n\n return VALID_RULE;\n },\n};\n\n/**\n * Declined if another field is not equal to the given value\n */\nexport const declinedUnlessRule: SchemaRule<{ field: string; value: any }> = {\n name: \"declinedUnless\",\n description: \"The field must be declined if :field's value is not equal to :value\",\n defaultErrorMessage: \"The :input must be declined\",\n async validate(value: any, context) {\n const fieldValue = getFieldValue(this, context);\n const { value: expectedValue } = this.context.options;\n\n this.context.translatableParams.field = this.context.options.field;\n this.context.translatableParams.value = this.context.options.value;\n if (fieldValue === expectedValue) {\n return invalidRule(this, context);\n }\n\n if (!isDeclinedValue(value)) {\n return invalidRule(this, context);\n }\n\n return VALID_RULE;\n },\n};\n\n/**\n * Declined if another field is required\n */\nexport const declinedIfRequiredRule: SchemaRule<{ field: string }> = {\n name: \"declinedIfRequired\",\n description: \"The field must be declined if :field is required\",\n defaultErrorMessage: \"The :input must be declined\",\n async validate(value: any, context) {\n const fieldValue = getFieldValue(this, context);\n this.context.translatableParams.field = this.context.options.field;\n\n if (isEmptyValue(fieldValue)) {\n return invalidRule(this, context);\n }\n\n if (!isDeclinedValue(value)) {\n return invalidRule(this, context);\n }\n\n return VALID_RULE;\n },\n};\n\n/**\n * Declined if another field is present\n */\nexport const declinedIfPresentRule: SchemaRule<{ field: string }> = {\n name: \"declinedIfPresent\",\n description: \"The field must be declined if :field is present\",\n defaultErrorMessage: \"The :input must be declined\",\n async validate(value: any, context) {\n const fieldValue = getFieldValue(this, context);\n this.context.translatableParams.field = this.context.options.field;\n\n if (fieldValue === undefined) {\n return invalidRule(this, context);\n }\n\n if (!isDeclinedValue(value)) {\n return invalidRule(this, context);\n }\n\n return VALID_RULE;\n },\n};\n\n/**\n * Declined if another field is missing\n */\nexport const declinedWithoutRule: SchemaRule<{ field: string }> = {\n name: \"declinedWithout\",\n description: \"The field must be declined if :field is missing\",\n defaultErrorMessage: \"The :input must be declined\",\n async validate(value: any, context) {\n const fieldValue = getFieldValue(this, context);\n this.context.translatableParams.field = this.context.options.field;\n\n if (fieldValue !== undefined) {\n return invalidRule(this, context);\n }\n\n if (!isDeclinedValue(value)) {\n return invalidRule(this, context);\n }\n\n return VALID_RULE;\n },\n};\n"],"mappings":";;;;;;;;;;;;AAUA,MAAa,kBAAsC;CACjD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,MAAM,mBAAmB,UAAe;CACtC,OAAO,gBA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,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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alpha.d.mts","names":[],"sources":["../../../../../../../../seal/src/rules/string/alpha.ts"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"alpha.d.mts","names":[],"sources":["../../../../../../../../seal/src/rules/string/alpha.ts"],"mappings":";;;;;cAMa,SAAA,EAAW,UASvB;;;;cAKY,gBAAA,EAAkB,UAS9B;AATD;;;AAAA,cAca,aAAA,EAAe,UAS3B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alpha.mjs","names":[],"sources":["../../../../../../../../seal/src/rules/string/alpha.ts"],"sourcesContent":["import { invalidRule, VALID_RULE } from \"../../helpers\";\
|
|
1
|
+
{"version":3,"file":"alpha.mjs","names":[],"sources":["../../../../../../../../seal/src/rules/string/alpha.ts"],"sourcesContent":["import { invalidRule, VALID_RULE } from \"../../helpers\";\nimport type { SchemaRule } from \"../../types\";\n\n/**\n * Alpha rule - allows only alphabetic characters\n */\nexport const alphaRule: SchemaRule = {\n name: \"alpha\",\n defaultErrorMessage: \"The :input must contain only alphabetic characters\",\n async validate(value: any, context) {\n if (/^[a-zA-Z]+$/.test(value)) {\n return VALID_RULE;\n }\n return invalidRule(this, context);\n },\n};\n\n/**\n * AlphaNumeric rule - allows only alphanumeric characters\n */\nexport const alphaNumericRule: SchemaRule = {\n name: \"alphaNumeric\",\n defaultErrorMessage: \"The :input must contain only alphanumeric characters\",\n async validate(value: any, context) {\n if (/^[a-zA-Z0-9]+$/.test(value)) {\n return VALID_RULE;\n }\n return invalidRule(this, context);\n },\n};\n\n/**\n * Numeric string rule - allows only numeric characters\n */\nexport const isNumericRule: SchemaRule = {\n name: \"numeric\",\n defaultErrorMessage: \"The :input must contain only numeric characters\",\n async validate(value: any, context) {\n if (/^[0-9]+$/.test(String(value))) {\n return VALID_RULE;\n }\n return invalidRule(this, context);\n },\n};\n"],"mappings":";;;;;;;AAMA,MAAa,YAAwB;CACnC,MAAM;CACN,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAClC,IAAI,cAAc,KAAK,KAAK,GAC1B,OAAO;EAET,OAAO,YAAY,MAAM,OAAO;CAClC;AACF;;;;AAKA,MAAa,mBAA+B;CAC1C,MAAM;CACN,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAClC,IAAI,iBAAiB,KAAK,KAAK,GAC7B,OAAO;EAET,OAAO,YAAY,MAAM,OAAO;CAClC;AACF;;;;AAKA,MAAa,gBAA4B;CACvC,MAAM;CACN,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAClC,IAAI,WAAW,KAAK,OAAO,KAAK,CAAC,GAC/B,OAAO;EAET,OAAO,YAAY,MAAM,OAAO;CAClC;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"credit-card.d.mts","names":[],"sources":["../../../../../../../../seal/src/rules/string/credit-card.ts"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"credit-card.d.mts","names":[],"sources":["../../../../../../../../seal/src/rules/string/credit-card.ts"],"mappings":";;;;;cAMa,gBAAA,EAAkB,UAkC9B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"credit-card.mjs","names":[],"sources":["../../../../../../../../seal/src/rules/string/credit-card.ts"],"sourcesContent":["import { invalidRule, VALID_RULE } from \"../../helpers\";\
|
|
1
|
+
{"version":3,"file":"credit-card.mjs","names":[],"sources":["../../../../../../../../seal/src/rules/string/credit-card.ts"],"sourcesContent":["import { invalidRule, VALID_RULE } from \"../../helpers\";\nimport type { SchemaRule } from \"../../types\";\n\n/**\n * Credit card rule - validates credit card number\n */\nexport const isCreditCardRule: SchemaRule = {\n name: \"creditCard\",\n defaultErrorMessage: \"The :input must be a valid credit card number\",\n async validate(value: any, context) {\n // Luhn algorithm for credit card validation\n const cardNumber = String(value).replace(/\\s/g, \"\");\n\n if (!/^\\d+$/.test(cardNumber)) {\n return invalidRule(this, context);\n }\n\n let sum = 0;\n let isEven = false;\n\n for (let i = cardNumber.length - 1; i >= 0; i--) {\n let digit = parseInt(cardNumber.charAt(i), 10);\n\n if (isEven) {\n digit *= 2;\n if (digit > 9) {\n digit -= 9;\n }\n }\n\n sum += digit;\n isEven = !isEven;\n }\n\n if (sum % 10 === 0) {\n return VALID_RULE;\n }\n\n return invalidRule(this, context);\n },\n};\n"],"mappings":";;;;;;;AAMA,MAAa,mBAA+B;CAC1C,MAAM;CACN,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAElC,MAAM,aAAa,OAAO,KAAK,CAAC,CAAC,QAAQ,OAAO,EAAE;EAElD,IAAI,CAAC,QAAQ,KAAK,UAAU,GAC1B,OAAO,YAAY,MAAM,OAAO;EAGlC,IAAI,MAAM;EACV,IAAI,SAAS;EAEb,KAAK,IAAI,IAAI,WAAW,SAAS,GAAG,KAAK,GAAG,KAAK;GAC/C,IAAI,QAAQ,SAAS,WAAW,OAAO,CAAC,GAAG,EAAE;GAE7C,IAAI,QAAQ;IACV,SAAS;IACT,IAAI,QAAQ,GACV,SAAS;GAEb;GAEA,OAAO;GACP,SAAS,CAAC;EACZ;EAEA,IAAI,MAAM,OAAO,GACf,OAAO;EAGT,OAAO,YAAY,MAAM,OAAO;CAClC;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"email.d.mts","names":[],"sources":["../../../../../../../../seal/src/rules/string/email.ts"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"email.d.mts","names":[],"sources":["../../../../../../../../seal/src/rules/string/email.ts"],"mappings":";;;;;cAOa,SAAA,EAAW,UASvB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"email.mjs","names":[],"sources":["../../../../../../../../seal/src/rules/string/email.ts"],"sourcesContent":["import { isEmail } from \"@mongez/supportive-is\";\
|
|
1
|
+
{"version":3,"file":"email.mjs","names":[],"sources":["../../../../../../../../seal/src/rules/string/email.ts"],"sourcesContent":["import { isEmail } from \"@mongez/supportive-is\";\nimport { invalidRule, VALID_RULE } from \"../../helpers\";\nimport type { SchemaRule } from \"../../types\";\n\n/**\n * Email rule - validates email format\n */\nexport const emailRule: SchemaRule = {\n name: \"email\",\n defaultErrorMessage: \"The :input must be a valid email address\",\n async validate(value: any, context) {\n if (isEmail(value)) {\n return VALID_RULE;\n }\n return invalidRule(this, context);\n },\n};\n"],"mappings":";;;;;;;;AAOA,MAAa,YAAwB;CACnC,MAAM;CACN,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAClC,IAAI,QAAQ,KAAK,GACf,OAAO;EAET,OAAO,YAAY,MAAM,OAAO;CAClC;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"id-formats.d.mts","names":[],"sources":["../../../../../../../../seal/src/rules/string/id-formats.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"id-formats.d.mts","names":[],"sources":["../../../../../../../../seal/src/rules/string/id-formats.ts"],"mappings":";;KAuBY,WAAA;;;AAAZ;;;;AAAuB;AAUvB;cAAa,QAAA,EAAU,UAAU;EAAG,OAAA,GAAU,WAAA;AAAA;;;;;AAAW;AA8BzD;;;;AAA2C;AAqB3C;cArBa,QAAA,EAAU,UAAU;EAAG,OAAO;AAAA;AA6B1C;AAYD;;;;AAA4C;;;AAZ3C,cARY,QAAA,EAAU,UAQtB;;;;;;;;;;;cAYY,UAAA,EAAY,UAAU;EAAG,MAAM;AAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { alphaNumericRule, alphaRule, isNumericRule } from "./alpha.mjs";
|
|
2
|
+
import { isCreditCardRule } from "./credit-card.mjs";
|
|
3
|
+
import { emailRule } from "./email.mjs";
|
|
4
|
+
import { UUIDVersion, cuidRule, nanoidRule, ulidRule, uuidRule } from "./id-formats.mjs";
|
|
5
|
+
import { ip4Rule, ip6Rule, ipRule, isIP, isIPv4, isIPv6 } from "./ip.mjs";
|
|
6
|
+
import { matchesRule } from "./matches.mjs";
|
|
7
|
+
import { patternRule } from "./pattern.mjs";
|
|
8
|
+
import { containsRule, endsWithRule, notContainsRule, startsWithRule } from "./string-comparison.mjs";
|
|
9
|
+
import { strongPasswordRule } from "./strong-password-rule.mjs";
|
|
10
|
+
import { urlRule } from "./url.mjs";
|
|
11
|
+
import { withoutWhitespaceRule } from "./without-whitespace.mjs";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ip.d.mts","names":[],"sources":["../../../../../../../../seal/src/rules/string/ip.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"ip.d.mts","names":[],"sources":["../../../../../../../../seal/src/rules/string/ip.ts"],"mappings":";;iBA0BgB,MAAA,CAAO,KAAa;AAAA,iBAIpB,MAAA,CAAO,KAAa;;AAJpC;;;iBAYgB,IAAA,CAAK,KAAa;AAZE;AAIpC;;AAJoC,cAqBvB,MAAA,EAAQ,UASpB;;AA1BmC;AAQpC;cAuBa,OAAA,EAAS,UASrB;;;AAhCiC;cAqCrB,OAAA,EAAS,UASrB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"matches.d.mts","names":[],"sources":["../../../../../../../../seal/src/rules/string/matches.ts"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"matches.d.mts","names":[],"sources":["../../../../../../../../seal/src/rules/string/matches.ts"],"mappings":";;;;;cAOa,WAAA,EAAa,UAAU;EAAG,KAAK;AAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"matches.mjs","names":[],"sources":["../../../../../../../../seal/src/rules/string/matches.ts"],"sourcesContent":["import { get } from \"@mongez/reinforcements\";\
|
|
1
|
+
{"version":3,"file":"matches.mjs","names":[],"sources":["../../../../../../../../seal/src/rules/string/matches.ts"],"sourcesContent":["import { get } from \"@mongez/reinforcements\";\nimport { invalidRule, VALID_RULE } from \"../../helpers\";\nimport type { SchemaRule } from \"../../types\";\n\n/**\n * Matches rule - value must match another field value\n */\nexport const matchesRule: SchemaRule<{ field: string }> = {\n name: \"matches\",\n defaultErrorMessage: \"The :input must match :field\",\n async validate(value: any, context) {\n const otherFieldValue = get(context.allValues, this.context.options.field);\n\n if (value === otherFieldValue) {\n return VALID_RULE;\n }\n\n this.context.translatableParams.field = this.context.options.field;\n\n return invalidRule(this, context);\n },\n};\n"],"mappings":";;;;;;;;AAOA,MAAa,cAA6C;CACxD,MAAM;CACN,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAGlC,IAAI,UAFoB,IAAI,QAAQ,WAAW,KAAK,QAAQ,QAAQ,KAExC,GAC1B,OAAO;EAGT,KAAK,QAAQ,mBAAmB,QAAQ,KAAK,QAAQ,QAAQ;EAE7D,OAAO,YAAY,MAAM,OAAO;CAClC;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pattern.d.mts","names":[],"sources":["../../../../../../../../seal/src/rules/string/pattern.ts"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"pattern.d.mts","names":[],"sources":["../../../../../../../../seal/src/rules/string/pattern.ts"],"mappings":";;;;;cAMa,WAAA,EAAa,UAAU;EAAG,OAAA,EAAS,MAAA;AAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pattern.mjs","names":[],"sources":["../../../../../../../../seal/src/rules/string/pattern.ts"],"sourcesContent":["import { invalidRule, VALID_RULE } from \"../../helpers\";\
|
|
1
|
+
{"version":3,"file":"pattern.mjs","names":[],"sources":["../../../../../../../../seal/src/rules/string/pattern.ts"],"sourcesContent":["import { invalidRule, VALID_RULE } from \"../../helpers\";\nimport type { SchemaRule } from \"../../types\";\n\n/**\n * Pattern rule - validates against regex pattern\n */\nexport const patternRule: SchemaRule<{ pattern: RegExp }> = {\n name: \"pattern\",\n defaultErrorMessage: \"The :input does not match the required pattern\",\n async validate(value: any, context) {\n if (this.context.options.pattern.test(value)) {\n return VALID_RULE;\n }\n\n this.context.translationParams.pattern = this.context.options.pattern.toString();\n return invalidRule(this, context);\n },\n};\n"],"mappings":";;;;;;;AAMA,MAAa,cAA+C;CAC1D,MAAM;CACN,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAClC,IAAI,KAAK,QAAQ,QAAQ,QAAQ,KAAK,KAAK,GACzC,OAAO;EAGT,KAAK,QAAQ,kBAAkB,UAAU,KAAK,QAAQ,QAAQ,QAAQ,SAAS;EAC/E,OAAO,YAAY,MAAM,OAAO;CAClC;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"string-comparison.d.mts","names":[],"sources":["../../../../../../../../seal/src/rules/string/string-comparison.ts"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"string-comparison.d.mts","names":[],"sources":["../../../../../../../../seal/src/rules/string/string-comparison.ts"],"mappings":";;;;;cAMa,cAAA,EAAgB,UAAU;EAAG,KAAK;AAAA;;AAAA;AAiB/C;cAAa,YAAA,EAAc,UAAU;EAAG,KAAK;AAAA;AAAA;AAiB7C;;AAjB6C,cAiBhC,YAAA,EAAc,UAAU;EAAG,KAAK;AAAA;AAiB7C;;;AAAA,cAAa,eAAA,EAAiB,UAAU;EAAG,KAAK;AAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"string-comparison.mjs","names":[],"sources":["../../../../../../../../seal/src/rules/string/string-comparison.ts"],"sourcesContent":["import { invalidRule, VALID_RULE } from \"../../helpers\";\
|
|
1
|
+
{"version":3,"file":"string-comparison.mjs","names":[],"sources":["../../../../../../../../seal/src/rules/string/string-comparison.ts"],"sourcesContent":["import { invalidRule, VALID_RULE } from \"../../helpers\";\nimport type { SchemaRule } from \"../../types\";\n\n/**\n * Starts with rule\n */\nexport const startsWithRule: SchemaRule<{ value: string }> = {\n name: \"startsWith\",\n defaultErrorMessage: \"The :input must start with :value\",\n async validate(value: any, context) {\n if (String(value).startsWith(this.context.options.value)) {\n return VALID_RULE;\n }\n\n this.context.translatableParams.value = this.context.options.value;\n\n return invalidRule(this, context);\n },\n};\n\n/**\n * Ends with rule\n */\nexport const endsWithRule: SchemaRule<{ value: string }> = {\n name: \"endsWith\",\n defaultErrorMessage: \"The :input must end with :value\",\n async validate(value: any, context) {\n if (String(value).endsWith(this.context.options.value)) {\n return VALID_RULE;\n }\n\n this.context.translatableParams.value = this.context.options.value;\n\n return invalidRule(this, context);\n },\n};\n\n/**\n * Contains rule\n */\nexport const containsRule: SchemaRule<{ value: string }> = {\n name: \"contains\",\n defaultErrorMessage: \"The :input must contain :value\",\n async validate(value: any, context) {\n if (String(value).includes(this.context.options.value)) {\n return VALID_RULE;\n }\n\n this.context.translatableParams.value = this.context.options.value;\n\n return invalidRule(this, context);\n },\n};\n\n/**\n * Not contains rule\n */\nexport const notContainsRule: SchemaRule<{ value: string }> = {\n name: \"notContains\",\n defaultErrorMessage: \"The :input must not contain :value\",\n async validate(value: any, context) {\n if (!String(value).includes(this.context.options.value)) {\n return VALID_RULE;\n }\n\n this.context.translatableParams.value = this.context.options.value;\n\n return invalidRule(this, context);\n },\n};\n"],"mappings":";;;;;;;AAMA,MAAa,iBAAgD;CAC3D,MAAM;CACN,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAClC,IAAI,OAAO,KAAK,CAAC,CAAC,WAAW,KAAK,QAAQ,QAAQ,KAAK,GACrD,OAAO;EAGT,KAAK,QAAQ,mBAAmB,QAAQ,KAAK,QAAQ,QAAQ;EAE7D,OAAO,YAAY,MAAM,OAAO;CAClC;AACF;;;;AAKA,MAAa,eAA8C;CACzD,MAAM;CACN,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAClC,IAAI,OAAO,KAAK,CAAC,CAAC,SAAS,KAAK,QAAQ,QAAQ,KAAK,GACnD,OAAO;EAGT,KAAK,QAAQ,mBAAmB,QAAQ,KAAK,QAAQ,QAAQ;EAE7D,OAAO,YAAY,MAAM,OAAO;CAClC;AACF;;;;AAKA,MAAa,eAA8C;CACzD,MAAM;CACN,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAClC,IAAI,OAAO,KAAK,CAAC,CAAC,SAAS,KAAK,QAAQ,QAAQ,KAAK,GACnD,OAAO;EAGT,KAAK,QAAQ,mBAAmB,QAAQ,KAAK,QAAQ,QAAQ;EAE7D,OAAO,YAAY,MAAM,OAAO;CAClC;AACF;;;;AAKA,MAAa,kBAAiD;CAC5D,MAAM;CACN,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAClC,IAAI,CAAC,OAAO,KAAK,CAAC,CAAC,SAAS,KAAK,QAAQ,QAAQ,KAAK,GACpD,OAAO;EAGT,KAAK,QAAQ,mBAAmB,QAAQ,KAAK,QAAQ,QAAQ;EAE7D,OAAO,YAAY,MAAM,OAAO;CAClC;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"strong-password-rule.d.mts","names":[],"sources":["../../../../../../../../seal/src/rules/string/strong-password-rule.ts"],"mappings":";;;;;AAYA;;;;AAAuD
|
|
1
|
+
{"version":3,"file":"strong-password-rule.d.mts","names":[],"sources":["../../../../../../../../seal/src/rules/string/strong-password-rule.ts"],"mappings":";;;;;AAYA;;;;AAAuD;;cAA1C,kBAAA,EAAoB,UAAU;EAAG,SAAS;AAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"strong-password-rule.mjs","names":[],"sources":["../../../../../../../../seal/src/rules/string/strong-password-rule.ts"],"sourcesContent":["import { invalidRule, VALID_RULE } from \"../../helpers\";\
|
|
1
|
+
{"version":3,"file":"strong-password-rule.mjs","names":[],"sources":["../../../../../../../../seal/src/rules/string/strong-password-rule.ts"],"sourcesContent":["import { invalidRule, VALID_RULE } from \"../../helpers\";\nimport type { SchemaRule } from \"../../types\";\n\n/**\n * Strong Password rule - validates password strength\n * Requirements:\n * - At least 8 characters\n * - At least 1 uppercase letter\n * - At least 1 lowercase letter\n * - At least 1 number\n * - At least 1 special character\n */\nexport const strongPasswordRule: SchemaRule<{ minLength?: number }> = {\n name: \"strongPassword\",\n defaultErrorMessage:\n \"The :input must be at least 8 characters and contain at least one uppercase letter, one lowercase letter, one number, and one special character\",\n async validate(value: any, context) {\n const password = String(value);\n const minLength = this.context.options.minLength ?? 8;\n\n // Check minimum length\n if (password.length < minLength) {\n return invalidRule(this, context);\n }\n\n // Check for at least one uppercase letter\n if (!/[A-Z]/.test(password)) {\n return invalidRule(this, context);\n }\n\n // Check for at least one lowercase letter\n if (!/[a-z]/.test(password)) {\n return invalidRule(this, context);\n }\n\n // Check for at least one number\n if (!/[0-9]/.test(password)) {\n return invalidRule(this, context);\n }\n\n // Check for at least one special character\n if (!/[!@#$%^&*()_+\\-=[\\]{};':\"\\\\|,.<>/?]/.test(password)) {\n return invalidRule(this, context);\n }\n\n return VALID_RULE;\n },\n};\n"],"mappings":";;;;;;;;;;;;;AAYA,MAAa,qBAAyD;CACpE,MAAM;CACN,qBACE;CACF,MAAM,SAAS,OAAY,SAAS;EAClC,MAAM,WAAW,OAAO,KAAK;EAC7B,MAAM,YAAY,KAAK,QAAQ,QAAQ,aAAa;EAGpD,IAAI,SAAS,SAAS,WACpB,OAAO,YAAY,MAAM,OAAO;EAIlC,IAAI,CAAC,QAAQ,KAAK,QAAQ,GACxB,OAAO,YAAY,MAAM,OAAO;EAIlC,IAAI,CAAC,QAAQ,KAAK,QAAQ,GACxB,OAAO,YAAY,MAAM,OAAO;EAIlC,IAAI,CAAC,QAAQ,KAAK,QAAQ,GACxB,OAAO,YAAY,MAAM,OAAO;EAIlC,IAAI,CAAC,sCAAsC,KAAK,QAAQ,GACtD,OAAO,YAAY,MAAM,OAAO;EAGlC,OAAO;CACT;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"url.d.mts","names":[],"sources":["../../../../../../../../seal/src/rules/string/url.ts"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"url.d.mts","names":[],"sources":["../../../../../../../../seal/src/rules/string/url.ts"],"mappings":";;;;;cAMa,OAAA,EAAS,UAWrB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"url.mjs","names":[],"sources":["../../../../../../../../seal/src/rules/string/url.ts"],"sourcesContent":["import { invalidRule, VALID_RULE } from \"../../helpers\";\
|
|
1
|
+
{"version":3,"file":"url.mjs","names":[],"sources":["../../../../../../../../seal/src/rules/string/url.ts"],"sourcesContent":["import { invalidRule, VALID_RULE } from \"../../helpers\";\nimport type { SchemaRule } from \"../../types\";\n\n/**\n * URL rule - validates URL format\n */\nexport const urlRule: SchemaRule = {\n name: \"url\",\n defaultErrorMessage: \"The :input must be a valid URL\",\n async validate(value: any, context) {\n try {\n new URL(value);\n return VALID_RULE;\n } catch {\n return invalidRule(this, context);\n }\n },\n};\n"],"mappings":";;;;;;;AAMA,MAAa,UAAsB;CACjC,MAAM;CACN,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAClC,IAAI;GACF,IAAI,IAAI,KAAK;GACb,OAAO;EACT,QAAQ;GACN,OAAO,YAAY,MAAM,OAAO;EAClC;CACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"without-whitespace.d.mts","names":[],"sources":["../../../../../../../../seal/src/rules/string/without-whitespace.ts"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"without-whitespace.d.mts","names":[],"sources":["../../../../../../../../seal/src/rules/string/without-whitespace.ts"],"mappings":";;;;;cAMa,qBAAA,EAAuB,UASnC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"without-whitespace.mjs","names":[],"sources":["../../../../../../../../seal/src/rules/string/without-whitespace.ts"],"sourcesContent":["import { invalidRule, VALID_RULE } from \"../../helpers\";\
|
|
1
|
+
{"version":3,"file":"without-whitespace.mjs","names":[],"sources":["../../../../../../../../seal/src/rules/string/without-whitespace.ts"],"sourcesContent":["import { invalidRule, VALID_RULE } from \"../../helpers\";\nimport type { SchemaRule } from \"../../types\";\n\n/**\n * Without whitespace rule - value must not contain whitespace\n */\nexport const withoutWhitespaceRule: SchemaRule = {\n name: \"withoutWhitespace\",\n defaultErrorMessage: \"The :input must not contain whitespace\",\n async validate(value: any, context) {\n if (!/\\s/.test(value)) {\n return VALID_RULE;\n }\n return invalidRule(this, context);\n },\n};\n"],"mappings":";;;;;;;AAMA,MAAa,wBAAoC;CAC/C,MAAM;CACN,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAClC,IAAI,CAAC,KAAK,KAAK,KAAK,GAClB,OAAO;EAET,OAAO,YAAY,MAAM,OAAO;CAClC;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"map-result.d.mts","names":[],"sources":["../../../../../../../seal/src/standard-schema/map-result.ts"],"mappings":";;;;;;AAiBA;;;;;;;;;AAE0B
|
|
1
|
+
{"version":3,"file":"map-result.d.mts","names":[],"sources":["../../../../../../../seal/src/standard-schema/map-result.ts"],"mappings":";;;;;;AAiBA;;;;;;;;;AAE0B;;iBAFV,mBAAA,CACd,MAAA,EAAQ,gBAAA,GACP,gBAAA,CAAiB,MAAM"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"date-types.mjs","names":[],"sources":["../../../../../../../seal/src/types/date-types.ts"],"sourcesContent":["/**\
|
|
1
|
+
{"version":3,"file":"date-types.mjs","names":[],"sources":["../../../../../../../seal/src/types/date-types.ts"],"sourcesContent":["/**\n * Week day names for validation\n */\nexport type WeekDay =\n | \"sunday\"\n | \"monday\"\n | \"tuesday\"\n | \"wednesday\"\n | \"thursday\"\n | \"friday\"\n | \"saturday\";\n\n/**\n * Week day numbers mapping\n */\nexport const WEEK_DAYS: Record<WeekDay, number> = {\n sunday: 0,\n monday: 1,\n tuesday: 2,\n wednesday: 3,\n thursday: 4,\n friday: 5,\n saturday: 6,\n};\n"],"mappings":";;;;AAeA,MAAa,YAAqC;CAChD,QAAQ;CACR,QAAQ;CACR,SAAS;CACT,WAAW;CACX,UAAU;CACV,QAAQ;CACR,UAAU;AACZ"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Schema } from "./schema-types.mjs";
|
|
2
|
+
import { ContextualSchemaRule, RuleResult, SchemaRule, SchemaRuleOptions, ValidationAttributesList } from "./rule-types.mjs";
|
|
3
|
+
import { AttributeTranslation, RuleTranslation, SchemaContext } from "./context-types.mjs";
|
|
4
|
+
import { ValidationResult } from "./result-types.mjs";
|
|
5
|
+
import { ContextualizedMutator, Mutator, MutatorContext } from "./mutator-types.mjs";
|
|
6
|
+
import { WhenRuleOptions } from "./conditional-types.mjs";
|
|
7
|
+
import { ContextualizedTransformer, SimpleTransformerCallback, TransformerCallback } from "./data-transformer-types.mjs";
|
|
8
|
+
import { Infer, InferInput, InferInputObjectShape, InferObjectShape, InferOutput, InferOutputObjectShape, IsInputOptionalKey, IsOptionalKey, IsOutputOptionalKey } from "./inference-types.mjs";
|
|
9
|
+
import { WEEK_DAYS, WeekDay } from "./date-types.mjs";
|
|
10
|
+
import { FileSizeOption } from "./file.types.mjs";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"any-validator.mjs","names":[],"sources":["../../../../../../../seal/src/validators/any-validator.ts"],"sourcesContent":["import type { JsonSchemaResult, JsonSchemaTarget } from \"../standard-schema/json-schema\";\
|
|
1
|
+
{"version":3,"file":"any-validator.mjs","names":[],"sources":["../../../../../../../seal/src/validators/any-validator.ts"],"sourcesContent":["import type { JsonSchemaResult, JsonSchemaTarget } from \"../standard-schema/json-schema\";\nimport { applyNullable } from \"../standard-schema/json-schema\";\nimport { BaseValidator } from \"./base-validator\";\n\n/**\n * Any validator - accepts any value\n */\nexport class AnyValidator extends BaseValidator {\n /**\n * Any validator means any value, so we disable the default required requirement.\n */\n public override requiredRule = null;\n\n /**\n * Set is optional to be true\n */\n public override isOptional = true;\n\n /**\n * @inheritdoc\n *\n * Any validator accepts anything. In JSON Schema, an empty object `{}`\n * is the permissive schema that accepts any valid JSON value.\n *\n * @example\n * ```ts\n * v.any().toJsonSchema(\"draft-2020-12\")\n * // → {}\n * ```\n */\n public override toJsonSchema(target: JsonSchemaTarget = \"draft-2020-12\"): JsonSchemaResult {\n const schema: JsonSchemaResult = {};\n if (this.isNullable) applyNullable(schema, target);\n return schema;\n }\n}\n"],"mappings":";;;;;;;AAOA,IAAa,eAAb,cAAkC,cAAc;;;sBAIf;oBAKF;;;;;;;;;;;;;;CAc7B,AAAgB,aAAa,SAA2B,iBAAmC;EACzF,MAAM,SAA2B,CAAC;EAClC,IAAI,KAAK,YAAY,cAAc,QAAQ,MAAM;EACjD,OAAO;CACT;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array-validator.d.mts","names":[],"sources":["../../../../../../../seal/src/validators/array-validator.ts"],"mappings":";;;;;;;;;cAmBa,cAAA,SAAuB,aAAA;EAEzB,SAAA,EAAW,aAAA;cAAX,SAAA,EAAW,aAAA,EAClB,YAAA
|
|
1
|
+
{"version":3,"file":"array-validator.d.mts","names":[],"sources":["../../../../../../../seal/src/validators/array-validator.ts"],"mappings":";;;;;;;;;cAmBa,cAAA,SAAuB,aAAA;EAEzB,SAAA,EAAW,aAAA;cAAX,SAAA,EAAW,aAAA,EAClB,YAAA;;;;EAUK,WAAA,CAAY,KAAA;EA8GuB;;;EAvG1B,KAAA;EAoK0D;EA3JnE,IAAA;EA7BwC;EAkCxC,OAAA;EAlC2B;EAuC3B,UAAA;EArCa;EA0Cb,IAAA,CAAK,SAAA,mBAAmC,GAAA;EA1C3B;EA+Cb,GAAA,CAAI,GAAA,UAAa,YAAA;EA9CtB;EAmDK,SAAA,CAAU,MAAA,UAAgB,YAAA;EAzCd;EA8CZ,GAAA,CAAI,GAAA,UAAa,YAAA;EA9BjB;EAmCA,SAAA,CAAU,MAAA,UAAgB,YAAA;EAzB1B;EA8BA,MAAA,CAAO,MAAA,UAAgB,YAAA;EAzBlB;;;;;;;;;;;;;;EA2CL,OAAA,CAAQ,GAAA,UAAa,GAAA,UAAa,YAAA;EAlB3B;;;EA4BP,aAAA,CAAc,GAAA,UAAa,GAAA,UAAa,YAAA;EAVnB;EAerB,MAAA,CAAO,YAAA;EALP;EAUA,MAAA,CAAO,SAAA,mBAAmC,YAAA;EAVf;EAe3B,MAAA,CAAO,IAAA,OAAW,OAAA,EAAS,aAAA;EAV3B;;;;;;EAqBM,QAAA,CAAS,IAAA,OAAW,OAAA,EAAS,aAAA,GAAgB,OAAA,CAAQ,gBAAA;EAXhC;;;;;;;;;;;EAwElB,YAAA,CAAa,MAAA,GAAQ,gBAAA,GAAqC,gBAAA;AAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array-validator.mjs","names":[],"sources":["../../../../../../../seal/src/validators/array-validator.ts"],"sourcesContent":["import { setKeyPath } from \"../helpers\";\r\nimport { flipArrayMutator, sortArrayMutator, uniqueArrayMutator } from \"../mutators\";\r\nimport {\r\n arrayRule,\r\n betweenLengthRule,\r\n lengthRule,\r\n maxLengthRule,\r\n minLengthRule,\r\n sortedArrayRule,\r\n uniqueArrayRule,\r\n} from \"../rules\";\r\nimport type { SchemaContext, ValidationResult } from \"../types\";\r\nimport { BaseValidator } from \"./base-validator\";\r\nimport { applyNullable, getRuleOptions } from \"../standard-schema/json-schema\";\r\nimport type { JsonSchemaResult, JsonSchemaTarget } from \"../standard-schema/json-schema\";\r\n\r\n/**\r\n * Array validator class\r\n */\r\nexport class ArrayValidator extends BaseValidator {\r\n public constructor(\r\n public validator: BaseValidator,\r\n errorMessage?: string,\r\n ) {\r\n super();\r\n this.addMutableRule(arrayRule, errorMessage);\r\n }\r\n\r\n /**\r\n * Check if value is an array type\r\n */\r\n public matchesType(value: any): boolean {\r\n return Array.isArray(value);\r\n }\r\n\r\n /**\r\n * Clone the validator\r\n */\r\n public override clone(): this {\r\n const cloned = super.clone();\r\n\r\n cloned.validator = this.validator.clone();\r\n\r\n return cloned;\r\n }\r\n\r\n /** Reverse array order */\r\n public flip() {\r\n return this.addMutator(flipArrayMutator);\r\n }\r\n\r\n /** Reverse array order (alias) */\r\n public reverse() {\r\n return this.addMutator(flipArrayMutator);\r\n }\r\n\r\n /** Make it has only unique values */\r\n public onlyUnique() {\r\n return this.addMutator(uniqueArrayMutator);\r\n }\r\n\r\n /** Sort array */\r\n public sort(direction: \"asc\" | \"desc\" = \"asc\", key?: string) {\r\n return this.addMutator(sortArrayMutator, { direction, key });\r\n }\r\n\r\n /** Array length must be greater than the given length */\n public min(min: number, errorMessage?: string) {\n return this.addRule(minLengthRule, errorMessage, { minLength: min });\n }\n\n /** @alias min */\n public minLength(length: number, errorMessage?: string) {\n return this.min(length, errorMessage);\n }\n\n /** Array length must be less than the given length */\n public max(max: number, errorMessage?: string) {\n return this.addRule(maxLengthRule, errorMessage, { maxLength: max });\n }\n\n /** @alias max */\n public maxLength(length: number, errorMessage?: string) {\n return this.max(length, errorMessage);\n }\n\r\n /** Array length must be of the given length */\r\n public length(length: number, errorMessage?: string) {\r\n return this.addRule(lengthRule, errorMessage, { length });\r\n }\r\n\r\n /**\r\n * Array length must be between min and max (inclusive)\r\n *\r\n * @param min - Minimum length (inclusive)\r\n * @param max - Maximum length (inclusive)\r\n *\r\n * @example\r\n * ```ts\r\n * v.array(v.string()).between(1, 10) // Array must have 1 to 10 items\r\n * v.array(v.number()).lengthBetween(5, 20) // Same using alias\r\n * ```\r\n *\r\n * @category Validation Rule\r\n */\r\n public between(min: number, max: number, errorMessage?: string) {\r\n return this.addRule(betweenLengthRule, errorMessage, {\r\n minLength: min,\r\n maxLength: max,\r\n });\r\n }\r\n\r\n /**\r\n * Alias for between() - array length between min and max\r\n */\r\n public lengthBetween(min: number, max: number, errorMessage?: string) {\r\n return this.between(min, max, errorMessage);\r\n }\r\n\r\n /** Array must have unique values */\r\n public unique(errorMessage?: string) {\r\n return this.addRule(uniqueArrayRule, errorMessage);\r\n }\r\n\r\n /** Array must be sorted */\r\n public sorted(direction: \"asc\" | \"desc\" = \"asc\", errorMessage?: string) {\r\n return this.addRule(sortedArrayRule, errorMessage, { direction });\r\n }\r\n\r\n /** Mutate the data */\r\n public mutate(data: any, context: SchemaContext) {\r\n if (!Array.isArray(data)) return data;\r\n return super.mutate([...data], context);\r\n }\r\n\r\n /** Validate array\r\n *\r\n * Absent input (and absent without `.default()`) propagates as `data: undefined`\r\n * so the parent ObjectValidator can omit the key. Without this, optional array\r\n * fields would silently materialise as `[]` in the validated output.\r\n */\r\n public async validate(data: any, context: SchemaContext): Promise<ValidationResult> {\r\n // Apply default when absent, then mutate. Mirrors BaseValidator's\r\n // `valueForRules = data ?? this.getDefaultValue()` so `.default([...])`\r\n // works on arrays too.\r\n const valueForRules = data ?? this.getDefaultValue();\r\n const mutatedData = await this.mutate(valueForRules, context);\r\n\r\n const result = await super.validate(data, context);\r\n\r\n if (result.isValid === false) return result;\r\n\r\n // Nothing to iterate for absent (no default) or null (nullable) inputs —\r\n // propagate so the parent ObjectValidator can omit the key.\r\n if (mutatedData === undefined || mutatedData === null) return result;\r\n\r\n // Defensive: type rule (arrayRule) should have failed for non-arrays.\r\n if (!Array.isArray(mutatedData)) return result;\r\n\r\n const errors: ValidationResult[\"errors\"] = [];\r\n\r\n // Validate all items in parallel (consistent with ObjectValidator)\r\n const validationPromises = mutatedData.map(async (value: any, index: number) => {\r\n const childContext: SchemaContext = {\r\n ...context,\r\n parent: mutatedData,\r\n value,\r\n key: index.toString(),\r\n path: setKeyPath(context.path, index.toString()),\r\n };\r\n\r\n const childResult = await this.validator.validate(value, childContext);\r\n\r\n // Update mutated data with validated result\r\n mutatedData[index] = childResult.data;\r\n\r\n // Collect errors from this element\r\n if (childResult.isValid === false) {\r\n errors.push(...childResult.errors);\r\n }\r\n });\r\n\r\n await Promise.all(validationPromises);\r\n\r\n return {\r\n isValid: errors.length === 0,\r\n errors,\r\n data: await this.startTransformationPipeline(mutatedData, context),\r\n };\r\n }\r\n\r\n /**\r\n * @inheritdoc\r\n *\r\n * Recursively generates JSON Schema for the array items.\r\n *\r\n * @example\r\n * ```ts\r\n * v.array(v.string().min(1)).minLength(1).toJsonSchema(\"draft-2020-12\")\r\n * // → { type: \"array\", items: { type: \"string\", minLength: 1 }, minItems: 1 }\r\n * ```\r\n */\r\n public override toJsonSchema(target: JsonSchemaTarget = \"draft-2020-12\"): JsonSchemaResult {\r\n const schema: JsonSchemaResult = {\r\n type: \"array\",\r\n items: this.validator.toJsonSchema(target),\r\n };\r\n\r\n const minOpts = getRuleOptions(this.rules, \"minLength\");\r\n if (minOpts?.minLength !== undefined) schema.minItems = minOpts.minLength;\r\n\r\n const maxOpts = getRuleOptions(this.rules, \"maxLength\");\r\n if (maxOpts?.maxLength !== undefined) schema.maxItems = maxOpts.maxLength;\r\n\r\n const betweenOpts = getRuleOptions(this.rules, \"betweenLength\");\r\n if (betweenOpts) {\r\n if (betweenOpts.minLength !== undefined) schema.minItems = betweenOpts.minLength;\r\n if (betweenOpts.maxLength !== undefined) schema.maxItems = betweenOpts.maxLength;\r\n }\r\n\r\n const lengthOpts = getRuleOptions(this.rules, \"length\");\r\n if (lengthOpts?.length !== undefined) {\r\n schema.minItems = lengthOpts.length;\r\n schema.maxItems = lengthOpts.length;\r\n }\r\n\r\n if (this.isNullable) applyNullable(schema, target);\r\n\r\n return schema;\r\n }\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;AAmBA,IAAa,iBAAb,cAAoC,cAAc;CAChD,AAAO,YACL,AAAO,WACP,cACA;EACA,MAAM;EAHC;EAIP,KAAK,eAAe,WAAW,YAAY;CAC7C;;;;CAKA,AAAO,YAAY,OAAqB;EACtC,OAAO,MAAM,QAAQ,KAAK;CAC5B;;;;CAKA,AAAgB,QAAc;EAC5B,MAAM,SAAS,MAAM,MAAM;EAE3B,OAAO,YAAY,KAAK,UAAU,MAAM;EAExC,OAAO;CACT;;CAGA,AAAO,OAAO;EACZ,OAAO,KAAK,WAAW,gBAAgB;CACzC;;CAGA,AAAO,UAAU;EACf,OAAO,KAAK,WAAW,gBAAgB;CACzC;;CAGA,AAAO,aAAa;EAClB,OAAO,KAAK,WAAW,kBAAkB;CAC3C;;CAGA,AAAO,KAAK,YAA4B,OAAO,KAAc;EAC3D,OAAO,KAAK,WAAW,kBAAkB;GAAE;GAAW;EAAI,CAAC;CAC7D;;CAGA,AAAO,IAAI,KAAa,cAAuB;EAC7C,OAAO,KAAK,QAAQ,eAAe,cAAc,EAAE,WAAW,IAAI,CAAC;CACrE;;CAGA,AAAO,UAAU,QAAgB,cAAuB;EACtD,OAAO,KAAK,IAAI,QAAQ,YAAY;CACtC;;CAGA,AAAO,IAAI,KAAa,cAAuB;EAC7C,OAAO,KAAK,QAAQ,eAAe,cAAc,EAAE,WAAW,IAAI,CAAC;CACrE;;CAGA,AAAO,UAAU,QAAgB,cAAuB;EACtD,OAAO,KAAK,IAAI,QAAQ,YAAY;CACtC;;CAGA,AAAO,OAAO,QAA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,YAAY,YAAY,OAC1B,OAAO,KAAK,GAAG,YAAY,MAAM;EAErC,CAAC;EAED,MAAM,QAAQ,IAAI,kBAAkB;EAEpC,OAAO;GACL,SAAS,OAAO,WAAW;GAC3B;GACA,MAAM,MAAM,KAAK,4BAA4B,aAAa,OAAO;EACnE;CACF;;;;;;;;;;;;CAaA,AAAgB,aAAa,SAA2B,iBAAmC;EACzF,MAAM,SAA2B;GAC/B,MAAM;GACN,OAAO,KAAK,UAAU,aAAa,MAAM;EAC3C;EAEA,MAAM,UAAU,eAAe,KAAK,OAAO,WAAW;EACtD,IAAI,SAAS,cAAc,QAAW,OAAO,WAAW,QAAQ;EAEhE,MAAM,UAAU,eAAe,KAAK,OAAO,WAAW;EACtD,IAAI,SAAS,cAAc,QAAW,OAAO,WAAW,QAAQ;EAEhE,MAAM,cAAc,eAAe,KAAK,OAAO,eAAe;EAC9D,IAAI,aAAa;GACf,IAAI,YAAY,cAAc,QAAW,OAAO,WAAW,YAAY;GACvE,IAAI,YAAY,cAAc,QAAW,OAAO,WAAW,YAAY;EACzE;EAEA,MAAM,aAAa,eAAe,KAAK,OAAO,QAAQ;EACtD,IAAI,YAAY,WAAW,QAAW;GACpC,OAAO,WAAW,WAAW;GAC7B,OAAO,WAAW,WAAW;EAC/B;EAEA,IAAI,KAAK,YAAY,cAAc,QAAQ,MAAM;EAEjD,OAAO;CACT;AACF"}
|
|
1
|
+
{"version":3,"file":"array-validator.mjs","names":[],"sources":["../../../../../../../seal/src/validators/array-validator.ts"],"sourcesContent":["import { setKeyPath } from \"../helpers\";\nimport { flipArrayMutator, sortArrayMutator, uniqueArrayMutator } from \"../mutators\";\nimport {\n arrayRule,\n betweenLengthRule,\n lengthRule,\n maxLengthRule,\n minLengthRule,\n sortedArrayRule,\n uniqueArrayRule,\n} from \"../rules\";\nimport type { SchemaContext, ValidationResult } from \"../types\";\nimport { BaseValidator } from \"./base-validator\";\nimport { applyNullable, getRuleOptions } from \"../standard-schema/json-schema\";\nimport type { JsonSchemaResult, JsonSchemaTarget } from \"../standard-schema/json-schema\";\n\n/**\n * Array validator class\n */\nexport class ArrayValidator extends BaseValidator {\n public constructor(\n public validator: BaseValidator,\n errorMessage?: string,\n ) {\n super();\n this.blankIsMissing = true;\n this.addMutableRule(arrayRule, errorMessage);\n }\n\n /**\n * Check if value is an array type\n */\n public matchesType(value: any): boolean {\n return Array.isArray(value);\n }\n\n /**\n * Clone the validator\n */\n public override clone(): this {\n const cloned = super.clone();\n\n cloned.validator = this.validator.clone();\n\n return cloned;\n }\n\n /** Reverse array order */\n public flip() {\n return this.addMutator(flipArrayMutator);\n }\n\n /** Reverse array order (alias) */\n public reverse() {\n return this.addMutator(flipArrayMutator);\n }\n\n /** Make it has only unique values */\n public onlyUnique() {\n return this.addMutator(uniqueArrayMutator);\n }\n\n /** Sort array */\n public sort(direction: \"asc\" | \"desc\" = \"asc\", key?: string) {\n return this.addMutator(sortArrayMutator, { direction, key });\n }\n\n /** Array length must be greater than the given length */\n public min(min: number, errorMessage?: string) {\n return this.addRule(minLengthRule, errorMessage, { minLength: min });\n }\n\n /** @alias min */\n public minLength(length: number, errorMessage?: string) {\n return this.min(length, errorMessage);\n }\n\n /** Array length must be less than the given length */\n public max(max: number, errorMessage?: string) {\n return this.addRule(maxLengthRule, errorMessage, { maxLength: max });\n }\n\n /** @alias max */\n public maxLength(length: number, errorMessage?: string) {\n return this.max(length, errorMessage);\n }\n\n /** Array length must be of the given length */\n public length(length: number, errorMessage?: string) {\n return this.addRule(lengthRule, errorMessage, { length });\n }\n\n /**\n * Array length must be between min and max (inclusive)\n *\n * @param min - Minimum length (inclusive)\n * @param max - Maximum length (inclusive)\n *\n * @example\n * ```ts\n * v.array(v.string()).between(1, 10) // Array must have 1 to 10 items\n * v.array(v.number()).lengthBetween(5, 20) // Same using alias\n * ```\n *\n * @category Validation Rule\n */\n public between(min: number, max: number, errorMessage?: string) {\n return this.addRule(betweenLengthRule, errorMessage, {\n minLength: min,\n maxLength: max,\n });\n }\n\n /**\n * Alias for between() - array length between min and max\n */\n public lengthBetween(min: number, max: number, errorMessage?: string) {\n return this.between(min, max, errorMessage);\n }\n\n /** Array must have unique values */\n public unique(errorMessage?: string) {\n return this.addRule(uniqueArrayRule, errorMessage);\n }\n\n /** Array must be sorted */\n public sorted(direction: \"asc\" | \"desc\" = \"asc\", errorMessage?: string) {\n return this.addRule(sortedArrayRule, errorMessage, { direction });\n }\n\n /** Mutate the data */\n public mutate(data: any, context: SchemaContext) {\n if (!Array.isArray(data)) return data;\n return super.mutate([...data], context);\n }\n\n /** Validate array\n *\n * Absent input (and absent without `.default()`) propagates as `data: undefined`\n * so the parent ObjectValidator can omit the key. Without this, optional array\n * fields would silently materialise as `[]` in the validated output.\n */\n public async validate(data: any, context: SchemaContext): Promise<ValidationResult> {\n // Apply default when absent, then mutate. Mirrors BaseValidator's\n // `valueForRules = data ?? this.getDefaultValue()` so `.default([...])`\n // works on arrays too.\n const valueForRules = data ?? this.getDefaultValue();\n const mutatedData = await this.mutate(valueForRules, context);\n\n const result = await super.validate(data, context);\n\n if (result.isValid === false) return result;\n\n // Nothing to iterate for absent (no default) or null (nullable) inputs —\n // propagate so the parent ObjectValidator can omit the key.\n if (mutatedData === undefined || mutatedData === null) return result;\n\n // Defensive: type rule (arrayRule) should have failed for non-arrays.\n if (!Array.isArray(mutatedData)) return result;\n\n const errors: ValidationResult[\"errors\"] = [];\n\n // Validate all items in parallel (consistent with ObjectValidator)\n const validationPromises = mutatedData.map(async (value: any, index: number) => {\n const childContext: SchemaContext = {\n ...context,\n parent: mutatedData,\n value,\n key: index.toString(),\n path: setKeyPath(context.path, index.toString()),\n };\n\n const childResult = await this.validator.validate(value, childContext);\n\n // Update mutated data with validated result\n mutatedData[index] = childResult.data;\n\n // Collect errors from this element\n if (childResult.isValid === false) {\n errors.push(...childResult.errors);\n }\n });\n\n await Promise.all(validationPromises);\n\n return {\n isValid: errors.length === 0,\n errors,\n data: await this.startTransformationPipeline(mutatedData, context),\n };\n }\n\n /**\n * @inheritdoc\n *\n * Recursively generates JSON Schema for the array items.\n *\n * @example\n * ```ts\n * v.array(v.string().min(1)).minLength(1).toJsonSchema(\"draft-2020-12\")\n * // → { type: \"array\", items: { type: \"string\", minLength: 1 }, minItems: 1 }\n * ```\n */\n public override toJsonSchema(target: JsonSchemaTarget = \"draft-2020-12\"): JsonSchemaResult {\n const schema: JsonSchemaResult = {\n type: \"array\",\n items: this.validator.toJsonSchema(target),\n };\n\n const minOpts = getRuleOptions(this.rules, \"minLength\");\n if (minOpts?.minLength !== undefined) schema.minItems = minOpts.minLength;\n\n const maxOpts = getRuleOptions(this.rules, \"maxLength\");\n if (maxOpts?.maxLength !== undefined) schema.maxItems = maxOpts.maxLength;\n\n const betweenOpts = getRuleOptions(this.rules, \"betweenLength\");\n if (betweenOpts) {\n if (betweenOpts.minLength !== undefined) schema.minItems = betweenOpts.minLength;\n if (betweenOpts.maxLength !== undefined) schema.maxItems = betweenOpts.maxLength;\n }\n\n const lengthOpts = getRuleOptions(this.rules, \"length\");\n if (lengthOpts?.length !== undefined) {\n schema.minItems = lengthOpts.length;\n schema.maxItems = lengthOpts.length;\n }\n\n if (this.isNullable) applyNullable(schema, target);\n\n return schema;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAmBA,IAAa,iBAAb,cAAoC,cAAc;CAChD,AAAO,YACL,AAAO,WACP,cACA;EACA,MAAM;EAHC;EAIP,KAAK,iBAAiB;EACtB,KAAK,eAAe,WAAW,YAAY;CAC7C;;;;CAKA,AAAO,YAAY,OAAqB;EACtC,OAAO,MAAM,QAAQ,KAAK;CAC5B;;;;CAKA,AAAgB,QAAc;EAC5B,MAAM,SAAS,MAAM,MAAM;EAE3B,OAAO,YAAY,KAAK,UAAU,MAAM;EAExC,OAAO;CACT;;CAGA,AAAO,OAAO;EACZ,OAAO,KAAK,WAAW,gBAAgB;CACzC;;CAGA,AAAO,UAAU;EACf,OAAO,KAAK,WAAW,gBAAgB;CACzC;;CAGA,AAAO,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;EACtD,IAAI,YAAY,WAAW,QAAW;GACpC,OAAO,WAAW,WAAW;GAC7B,OAAO,WAAW,WAAW;EAC/B;EAEA,IAAI,KAAK,YAAY,cAAc,QAAQ,MAAM;EAEjD,OAAO;CACT;AACF"}
|
|
@@ -5,7 +5,6 @@ import { SchemaContext } from "../types/context-types.mjs";
|
|
|
5
5
|
import { ValidationResult } from "../types/result-types.mjs";
|
|
6
6
|
import { ContextualizedMutator, Mutator } from "../types/mutator-types.mjs";
|
|
7
7
|
import { ContextualizedTransformer, SimpleTransformerCallback, TransformerCallback } from "../types/data-transformer-types.mjs";
|
|
8
|
-
|
|
9
8
|
//#region ../seal/src/validators/base-validator.d.ts
|
|
10
9
|
/**
|
|
11
10
|
* Base validator class - foundation for all validators
|
|
@@ -18,6 +17,8 @@ declare class BaseValidator<TInput = unknown, TOutput = TInput> {
|
|
|
18
17
|
protected shouldOmit: boolean;
|
|
19
18
|
protected isNullable: boolean;
|
|
20
19
|
protected isMutable: boolean;
|
|
20
|
+
/** Treat empty or whitespace-only form strings as an absent value. */
|
|
21
|
+
protected blankIsMissing: boolean;
|
|
21
22
|
/**
|
|
22
23
|
* Catch state — when `hasCatch` is true and validation fails, `catchValue`
|
|
23
24
|
* (or its callback result) substitutes for the failed value, and the public
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-validator.d.mts","names":[],"sources":["../../../../../../../seal/src/validators/base-validator.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"base-validator.d.mts","names":[],"sources":["../../../../../../../seal/src/validators/base-validator.ts"],"mappings":";;;;;;;;;;;cAyBa,aAAA,6BAA0C,MAAA;EAC9C,KAAA,EAAO,oBAAA;EACP,QAAA,EAAU,qBAAA;EAAA,UACP,YAAA;EAAA,UACA,WAAA;EAAA,UACA,UAAA;EAAA,UACA,UAAA;EAAA,UACA,SAAA;EANI;EAAA,UAQJ,cAAA;EAUQ;;;;;;;EAAA,UADR,UAAA,UACA,MAAA,EAAQ,gBAA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sB,IAAA,EAAM,oBAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBAoDjB,oBAAA,CAAqB,KAAA,CAAM,MAAA,EAAQ,OAAA;;;;;;;;;;;;;;;;;;;;;;;;;;EAyCjD,YAAA,CAAa,OAAA,GAAS,gBAAA,GAAqC,gBAAA;AAAA"}
|
|
@@ -16,6 +16,7 @@ var BaseValidator = class {
|
|
|
16
16
|
this.shouldOmit = false;
|
|
17
17
|
this.isNullable = false;
|
|
18
18
|
this.isMutable = false;
|
|
19
|
+
this.blankIsMissing = false;
|
|
19
20
|
this.hasCatch = false;
|
|
20
21
|
this.isOptional = false;
|
|
21
22
|
this.requiredRule = this.createRule(requiredRule);
|
|
@@ -276,8 +277,10 @@ var BaseValidator = class {
|
|
|
276
277
|
cloned.shouldOmit = this.shouldOmit;
|
|
277
278
|
cloned.description = this.description;
|
|
278
279
|
cloned.attributesText = { ...this.attributesText };
|
|
280
|
+
cloned.translatedAttributes = { ...this.translatedAttributes };
|
|
279
281
|
cloned.isNullable = this.isNullable;
|
|
280
282
|
cloned.isOptional = this.isOptional;
|
|
283
|
+
cloned.blankIsMissing = this.blankIsMissing;
|
|
281
284
|
cloned.requiredRule = this.requiredRule;
|
|
282
285
|
cloned.catchValue = this.catchValue;
|
|
283
286
|
cloned.hasCatch = this.hasCatch;
|
|
@@ -523,7 +526,13 @@ var BaseValidator = class {
|
|
|
523
526
|
errors: [],
|
|
524
527
|
data: null
|
|
525
528
|
};
|
|
526
|
-
const
|
|
529
|
+
const isBlank = this.blankIsMissing && typeof data === "string" && data.trim() === "";
|
|
530
|
+
if (isBlank && this.isNullable) return {
|
|
531
|
+
isValid: true,
|
|
532
|
+
errors: [],
|
|
533
|
+
data: null
|
|
534
|
+
};
|
|
535
|
+
const valueForRules = (isBlank ? void 0 : data) ?? this.getDefaultValue();
|
|
527
536
|
const mutatedData = this.isOptional && valueForRules === void 0 ? void 0 : await this.mutate(valueForRules, context);
|
|
528
537
|
const errors = [];
|
|
529
538
|
let isValid = true;
|
|
@@ -562,6 +571,7 @@ var BaseValidator = class {
|
|
|
562
571
|
*/
|
|
563
572
|
setRuleAttributesList(rule) {
|
|
564
573
|
rule.context.attributesList = typeof this.attributesText[rule.name] === "object" ? this.attributesText[rule.name] : this.attributesText;
|
|
574
|
+
rule.context.translatedAttributes = this.translatedAttributes;
|
|
565
575
|
}
|
|
566
576
|
/**
|
|
567
577
|
* Standard Schema V1 compliance.
|