@warlock.js/seal 4.0.134 → 4.0.136
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/cjs/factory/validators.d.ts +1 -1
- package/cjs/factory/validators.d.ts.map +1 -1
- package/cjs/factory/validators.js +2 -2
- package/cjs/factory/validators.js.map +1 -1
- package/cjs/helpers/validation-helpers.d.ts +22 -0
- package/cjs/helpers/validation-helpers.d.ts.map +1 -1
- package/cjs/helpers/validation-helpers.js +56 -34
- package/cjs/helpers/validation-helpers.js.map +1 -1
- package/cjs/index.js +1 -1
- package/cjs/mutators/date-mutators.js +1 -1
- package/cjs/mutators/date-mutators.js.map +1 -1
- package/cjs/rules/array/array-rules.d.ts.map +1 -1
- package/cjs/rules/array/array-rules.js +1 -0
- package/cjs/rules/array/array-rules.js.map +1 -1
- package/cjs/rules/common/enum.d.ts.map +1 -1
- package/cjs/rules/common/enum.js +17 -3
- package/cjs/rules/common/enum.js.map +1 -1
- package/cjs/rules/common/equals-field-rules.d.ts.map +1 -1
- package/cjs/rules/common/equals-field-rules.js +1 -0
- package/cjs/rules/common/equals-field-rules.js.map +1 -1
- package/cjs/rules/common/type-rules.d.ts +4 -0
- package/cjs/rules/common/type-rules.d.ts.map +1 -1
- package/cjs/rules/common/type-rules.js +14 -1
- package/cjs/rules/common/type-rules.js.map +1 -1
- package/cjs/rules/common/unknown-key.js +2 -2
- package/cjs/rules/common/unknown-key.js.map +1 -1
- package/cjs/rules/conditional/forbidden-if-rules.d.ts.map +1 -1
- package/cjs/rules/conditional/forbidden-if-rules.js +6 -0
- package/cjs/rules/conditional/forbidden-if-rules.js.map +1 -1
- package/cjs/rules/conditional/index.d.ts +1 -0
- package/cjs/rules/conditional/index.d.ts.map +1 -1
- package/cjs/rules/conditional/present-if-rules.d.ts.map +1 -1
- package/cjs/rules/conditional/present-if-rules.js +2 -0
- package/cjs/rules/conditional/present-if-rules.js.map +1 -1
- package/cjs/rules/conditional/present-unless-rules.d.ts.map +1 -1
- package/cjs/rules/conditional/present-unless-rules.js +2 -0
- package/cjs/rules/conditional/present-unless-rules.js.map +1 -1
- package/cjs/rules/conditional/present-with-rules.d.ts.map +1 -1
- package/cjs/rules/conditional/present-with-rules.js +9 -2
- package/cjs/rules/conditional/present-with-rules.js.map +1 -1
- package/cjs/rules/conditional/present-without-rules.d.ts.map +1 -1
- package/cjs/rules/conditional/present-without-rules.js +9 -2
- package/cjs/rules/conditional/present-without-rules.js.map +1 -1
- package/cjs/rules/conditional/required-if-rules.d.ts.map +1 -1
- package/cjs/rules/conditional/required-if-rules.js +22 -7
- package/cjs/rules/conditional/required-if-rules.js.map +1 -1
- package/cjs/rules/conditional/required-unless-rules.d.ts.map +1 -1
- package/cjs/rules/conditional/required-unless-rules.js +2 -0
- package/cjs/rules/conditional/required-unless-rules.js.map +1 -1
- package/cjs/rules/conditional/required-when-rule.d.ts +18 -0
- package/cjs/rules/conditional/required-when-rule.d.ts.map +1 -0
- package/cjs/rules/conditional/required-when-rule.js +26 -0
- package/cjs/rules/conditional/required-when-rule.js.map +1 -0
- package/cjs/rules/conditional/required-with-rules.d.ts.map +1 -1
- package/cjs/rules/conditional/required-with-rules.js +1 -0
- package/cjs/rules/conditional/required-with-rules.js.map +1 -1
- package/cjs/rules/conditional/required-without-rules.d.ts.map +1 -1
- package/cjs/rules/conditional/required-without-rules.js +1 -0
- package/cjs/rules/conditional/required-without-rules.js.map +1 -1
- package/cjs/rules/core/equal.d.ts.map +1 -1
- package/cjs/rules/core/equal.js +1 -0
- package/cjs/rules/core/equal.js.map +1 -1
- package/cjs/rules/core/required.d.ts +1 -1
- package/cjs/rules/core/required.js +1 -1
- package/cjs/rules/date/date-comparison-rules.d.ts.map +1 -1
- package/cjs/rules/date/date-comparison-rules.js +2 -0
- package/cjs/rules/date/date-comparison-rules.js.map +1 -1
- package/cjs/rules/date/date-day-rules.d.ts.map +1 -1
- package/cjs/rules/date/date-day-rules.js +4 -1
- package/cjs/rules/date/date-day-rules.js.map +1 -1
- package/cjs/rules/date/date-field-comparison-rules.d.ts.map +1 -1
- package/cjs/rules/date/date-field-comparison-rules.js +4 -0
- package/cjs/rules/date/date-field-comparison-rules.js.map +1 -1
- package/cjs/rules/date/date-period-rules.d.ts +20 -4
- package/cjs/rules/date/date-period-rules.d.ts.map +1 -1
- package/cjs/rules/date/date-period-rules.js +44 -5
- package/cjs/rules/date/date-period-rules.js.map +1 -1
- package/cjs/rules/date/date-relative-rules.d.ts.map +1 -1
- package/cjs/rules/date/date-relative-rules.js +3 -0
- package/cjs/rules/date/date-relative-rules.js.map +1 -1
- package/cjs/rules/date/date-special-rules.d.ts.map +1 -1
- package/cjs/rules/date/date-special-rules.js +5 -6
- package/cjs/rules/date/date-special-rules.js.map +1 -1
- package/cjs/rules/date/date.d.ts.map +1 -1
- package/cjs/rules/date/date.js +15 -6
- package/cjs/rules/date/date.js.map +1 -1
- package/cjs/rules/file/dimensions.d.ts.map +1 -1
- package/cjs/rules/file/dimensions.js +4 -0
- package/cjs/rules/file/dimensions.js.map +1 -1
- package/cjs/rules/file/file-size.d.ts.map +1 -1
- package/cjs/rules/file/file-size.js +4 -22
- package/cjs/rules/file/file-size.js.map +1 -1
- package/cjs/rules/length/length-rules.d.ts.map +1 -1
- package/cjs/rules/length/length-rules.js +13 -22
- package/cjs/rules/length/length-rules.js.map +1 -1
- package/cjs/rules/number/number-rules.d.ts.map +1 -1
- package/cjs/rules/number/number-rules.js +13 -2
- package/cjs/rules/number/number-rules.js.map +1 -1
- package/cjs/rules/scalar/accepted-rule.d.ts.map +1 -1
- package/cjs/rules/scalar/accepted-rule.js +12 -5
- package/cjs/rules/scalar/accepted-rule.js.map +1 -1
- package/cjs/rules/scalar/declined-rule.d.ts.map +1 -1
- package/cjs/rules/scalar/declined-rule.js +12 -5
- package/cjs/rules/scalar/declined-rule.js.map +1 -1
- package/cjs/rules/string/matches.d.ts.map +1 -1
- package/cjs/rules/string/matches.js +1 -0
- package/cjs/rules/string/matches.js.map +1 -1
- package/cjs/rules/string/pattern.d.ts.map +1 -1
- package/cjs/rules/string/pattern.js +1 -0
- package/cjs/rules/string/pattern.js.map +1 -1
- package/cjs/rules/string/string-comparison.d.ts.map +1 -1
- package/cjs/rules/string/string-comparison.js +4 -0
- package/cjs/rules/string/string-comparison.js.map +1 -1
- package/cjs/types/context-types.d.ts +0 -1
- package/cjs/types/context-types.d.ts.map +1 -1
- package/cjs/types/inference-types.d.ts +10 -5
- package/cjs/types/inference-types.d.ts.map +1 -1
- package/cjs/types/rule-types.d.ts +4 -0
- package/cjs/types/rule-types.d.ts.map +1 -1
- package/cjs/validators/array-validator.d.ts +2 -2
- package/cjs/validators/array-validator.d.ts.map +1 -1
- package/cjs/validators/array-validator.js +13 -23
- package/cjs/validators/array-validator.js.map +1 -1
- package/cjs/validators/base-validator.d.ts +79 -369
- package/cjs/validators/base-validator.d.ts.map +1 -1
- package/cjs/validators/base-validator.js +144 -826
- package/cjs/validators/base-validator.js.map +1 -1
- package/cjs/validators/boolean-validator.d.ts +18 -15
- package/cjs/validators/boolean-validator.d.ts.map +1 -1
- package/cjs/validators/boolean-validator.js +46 -16
- package/cjs/validators/boolean-validator.js.map +1 -1
- package/cjs/validators/date-validator.d.ts +8 -3
- package/cjs/validators/date-validator.d.ts.map +1 -1
- package/cjs/validators/date-validator.js +176 -246
- package/cjs/validators/date-validator.js.map +1 -1
- package/cjs/validators/float-validator.js +1 -1
- package/cjs/validators/float-validator.js.map +1 -1
- package/cjs/validators/index.d.ts +5 -0
- package/cjs/validators/index.d.ts.map +1 -1
- package/cjs/validators/int-validator.js +1 -1
- package/cjs/validators/int-validator.js.map +1 -1
- package/cjs/validators/methods/equality-conditional-methods.d.ts +88 -0
- package/cjs/validators/methods/equality-conditional-methods.d.ts.map +1 -0
- package/cjs/validators/methods/equality-conditional-methods.js +118 -0
- package/cjs/validators/methods/equality-conditional-methods.js.map +1 -0
- package/cjs/validators/methods/forbidden-methods.d.ts +58 -0
- package/cjs/validators/methods/forbidden-methods.d.ts.map +1 -0
- package/cjs/validators/methods/forbidden-methods.js +122 -0
- package/cjs/validators/methods/forbidden-methods.js.map +1 -0
- package/cjs/validators/methods/present-methods.d.ts +102 -0
- package/cjs/validators/methods/present-methods.d.ts.map +1 -0
- package/cjs/validators/methods/present-methods.js +229 -0
- package/cjs/validators/methods/present-methods.js.map +1 -0
- package/cjs/validators/methods/required-methods.d.ts +174 -0
- package/cjs/validators/methods/required-methods.d.ts.map +1 -0
- package/cjs/validators/methods/required-methods.js +246 -0
- package/cjs/validators/methods/required-methods.js.map +1 -0
- package/cjs/validators/number-validator.d.ts +11 -13
- package/cjs/validators/number-validator.d.ts.map +1 -1
- package/cjs/validators/number-validator.js +60 -78
- package/cjs/validators/number-validator.js.map +1 -1
- package/cjs/validators/numeric-validator.js +1 -1
- package/cjs/validators/numeric-validator.js.map +1 -1
- package/cjs/validators/object-validator.d.ts +1 -0
- package/cjs/validators/object-validator.d.ts.map +1 -1
- package/cjs/validators/object-validator.js +21 -15
- package/cjs/validators/object-validator.js.map +1 -1
- package/cjs/validators/primitive-validator.d.ts +70 -0
- package/cjs/validators/primitive-validator.d.ts.map +1 -0
- package/cjs/validators/primitive-validator.js +80 -0
- package/cjs/validators/primitive-validator.js.map +1 -0
- package/cjs/validators/record-validator.d.ts +4 -0
- package/cjs/validators/record-validator.d.ts.map +1 -1
- package/cjs/validators/record-validator.js +7 -1
- package/cjs/validators/record-validator.js.map +1 -1
- package/cjs/validators/scalar-validator.d.ts +5 -15
- package/cjs/validators/scalar-validator.d.ts.map +1 -1
- package/cjs/validators/scalar-validator.js +20 -78
- package/cjs/validators/scalar-validator.js.map +1 -1
- package/cjs/validators/string-validator.d.ts +2 -18
- package/cjs/validators/string-validator.d.ts.map +1 -1
- package/cjs/validators/string-validator.js +71 -164
- package/cjs/validators/string-validator.js.map +1 -1
- package/cjs/validators/tuple-validator.d.ts.map +1 -1
- package/cjs/validators/tuple-validator.js +2 -2
- package/cjs/validators/tuple-validator.js.map +1 -1
- package/cjs/validators/union-validator.d.ts.map +1 -1
- package/cjs/validators/union-validator.js +1 -3
- package/cjs/validators/union-validator.js.map +1 -1
- package/esm/factory/validators.d.ts +1 -1
- package/esm/factory/validators.d.ts.map +1 -1
- package/esm/factory/validators.js +2 -2
- package/esm/factory/validators.js.map +1 -1
- package/esm/helpers/validation-helpers.d.ts +22 -0
- package/esm/helpers/validation-helpers.d.ts.map +1 -1
- package/esm/helpers/validation-helpers.js +56 -34
- package/esm/helpers/validation-helpers.js.map +1 -1
- package/esm/index.js +1 -1
- package/esm/mutators/date-mutators.js +1 -1
- package/esm/mutators/date-mutators.js.map +1 -1
- package/esm/rules/array/array-rules.d.ts.map +1 -1
- package/esm/rules/array/array-rules.js +1 -0
- package/esm/rules/array/array-rules.js.map +1 -1
- package/esm/rules/common/enum.d.ts.map +1 -1
- package/esm/rules/common/enum.js +18 -4
- package/esm/rules/common/enum.js.map +1 -1
- package/esm/rules/common/equals-field-rules.d.ts.map +1 -1
- package/esm/rules/common/equals-field-rules.js +1 -0
- package/esm/rules/common/equals-field-rules.js.map +1 -1
- package/esm/rules/common/type-rules.d.ts +4 -0
- package/esm/rules/common/type-rules.d.ts.map +1 -1
- package/esm/rules/common/type-rules.js +15 -2
- package/esm/rules/common/type-rules.js.map +1 -1
- package/esm/rules/common/unknown-key.js +2 -2
- package/esm/rules/common/unknown-key.js.map +1 -1
- package/esm/rules/conditional/forbidden-if-rules.d.ts.map +1 -1
- package/esm/rules/conditional/forbidden-if-rules.js +6 -0
- package/esm/rules/conditional/forbidden-if-rules.js.map +1 -1
- package/esm/rules/conditional/index.d.ts +1 -0
- package/esm/rules/conditional/index.d.ts.map +1 -1
- package/esm/rules/conditional/present-if-rules.d.ts.map +1 -1
- package/esm/rules/conditional/present-if-rules.js +2 -0
- package/esm/rules/conditional/present-if-rules.js.map +1 -1
- package/esm/rules/conditional/present-unless-rules.d.ts.map +1 -1
- package/esm/rules/conditional/present-unless-rules.js +2 -0
- package/esm/rules/conditional/present-unless-rules.js.map +1 -1
- package/esm/rules/conditional/present-with-rules.d.ts.map +1 -1
- package/esm/rules/conditional/present-with-rules.js +9 -2
- package/esm/rules/conditional/present-with-rules.js.map +1 -1
- package/esm/rules/conditional/present-without-rules.d.ts.map +1 -1
- package/esm/rules/conditional/present-without-rules.js +9 -2
- package/esm/rules/conditional/present-without-rules.js.map +1 -1
- package/esm/rules/conditional/required-if-rules.d.ts.map +1 -1
- package/esm/rules/conditional/required-if-rules.js +22 -7
- package/esm/rules/conditional/required-if-rules.js.map +1 -1
- package/esm/rules/conditional/required-unless-rules.d.ts.map +1 -1
- package/esm/rules/conditional/required-unless-rules.js +2 -0
- package/esm/rules/conditional/required-unless-rules.js.map +1 -1
- package/esm/rules/conditional/required-when-rule.d.ts +18 -0
- package/esm/rules/conditional/required-when-rule.d.ts.map +1 -0
- package/esm/rules/conditional/required-when-rule.js +26 -0
- package/esm/rules/conditional/required-when-rule.js.map +1 -0
- package/esm/rules/conditional/required-with-rules.d.ts.map +1 -1
- package/esm/rules/conditional/required-with-rules.js +1 -0
- package/esm/rules/conditional/required-with-rules.js.map +1 -1
- package/esm/rules/conditional/required-without-rules.d.ts.map +1 -1
- package/esm/rules/conditional/required-without-rules.js +1 -0
- package/esm/rules/conditional/required-without-rules.js.map +1 -1
- package/esm/rules/core/equal.d.ts.map +1 -1
- package/esm/rules/core/equal.js +1 -0
- package/esm/rules/core/equal.js.map +1 -1
- package/esm/rules/core/required.d.ts +1 -1
- package/esm/rules/core/required.js +1 -1
- package/esm/rules/date/date-comparison-rules.d.ts.map +1 -1
- package/esm/rules/date/date-comparison-rules.js +2 -0
- package/esm/rules/date/date-comparison-rules.js.map +1 -1
- package/esm/rules/date/date-day-rules.d.ts.map +1 -1
- package/esm/rules/date/date-day-rules.js +4 -1
- package/esm/rules/date/date-day-rules.js.map +1 -1
- package/esm/rules/date/date-field-comparison-rules.d.ts.map +1 -1
- package/esm/rules/date/date-field-comparison-rules.js +4 -0
- package/esm/rules/date/date-field-comparison-rules.js.map +1 -1
- package/esm/rules/date/date-period-rules.d.ts +20 -4
- package/esm/rules/date/date-period-rules.d.ts.map +1 -1
- package/esm/rules/date/date-period-rules.js +44 -5
- package/esm/rules/date/date-period-rules.js.map +1 -1
- package/esm/rules/date/date-relative-rules.d.ts.map +1 -1
- package/esm/rules/date/date-relative-rules.js +3 -0
- package/esm/rules/date/date-relative-rules.js.map +1 -1
- package/esm/rules/date/date-special-rules.d.ts.map +1 -1
- package/esm/rules/date/date-special-rules.js +5 -6
- package/esm/rules/date/date-special-rules.js.map +1 -1
- package/esm/rules/date/date.d.ts.map +1 -1
- package/esm/rules/date/date.js +15 -6
- package/esm/rules/date/date.js.map +1 -1
- package/esm/rules/file/dimensions.d.ts.map +1 -1
- package/esm/rules/file/dimensions.js +4 -0
- package/esm/rules/file/dimensions.js.map +1 -1
- package/esm/rules/file/file-size.d.ts.map +1 -1
- package/esm/rules/file/file-size.js +4 -22
- package/esm/rules/file/file-size.js.map +1 -1
- package/esm/rules/length/length-rules.d.ts.map +1 -1
- package/esm/rules/length/length-rules.js +13 -22
- package/esm/rules/length/length-rules.js.map +1 -1
- package/esm/rules/number/number-rules.d.ts.map +1 -1
- package/esm/rules/number/number-rules.js +13 -2
- package/esm/rules/number/number-rules.js.map +1 -1
- package/esm/rules/scalar/accepted-rule.d.ts.map +1 -1
- package/esm/rules/scalar/accepted-rule.js +12 -5
- package/esm/rules/scalar/accepted-rule.js.map +1 -1
- package/esm/rules/scalar/declined-rule.d.ts.map +1 -1
- package/esm/rules/scalar/declined-rule.js +12 -5
- package/esm/rules/scalar/declined-rule.js.map +1 -1
- package/esm/rules/string/matches.d.ts.map +1 -1
- package/esm/rules/string/matches.js +1 -0
- package/esm/rules/string/matches.js.map +1 -1
- package/esm/rules/string/pattern.d.ts.map +1 -1
- package/esm/rules/string/pattern.js +1 -0
- package/esm/rules/string/pattern.js.map +1 -1
- package/esm/rules/string/string-comparison.d.ts.map +1 -1
- package/esm/rules/string/string-comparison.js +4 -0
- package/esm/rules/string/string-comparison.js.map +1 -1
- package/esm/types/context-types.d.ts +0 -1
- package/esm/types/context-types.d.ts.map +1 -1
- package/esm/types/inference-types.d.ts +10 -5
- package/esm/types/inference-types.d.ts.map +1 -1
- package/esm/types/rule-types.d.ts +4 -0
- package/esm/types/rule-types.d.ts.map +1 -1
- package/esm/validators/array-validator.d.ts +2 -2
- package/esm/validators/array-validator.d.ts.map +1 -1
- package/esm/validators/array-validator.js +13 -23
- package/esm/validators/array-validator.js.map +1 -1
- package/esm/validators/base-validator.d.ts +79 -369
- package/esm/validators/base-validator.d.ts.map +1 -1
- package/esm/validators/base-validator.js +144 -826
- package/esm/validators/base-validator.js.map +1 -1
- package/esm/validators/boolean-validator.d.ts +18 -15
- package/esm/validators/boolean-validator.d.ts.map +1 -1
- package/esm/validators/boolean-validator.js +46 -16
- package/esm/validators/boolean-validator.js.map +1 -1
- package/esm/validators/date-validator.d.ts +8 -3
- package/esm/validators/date-validator.d.ts.map +1 -1
- package/esm/validators/date-validator.js +176 -246
- package/esm/validators/date-validator.js.map +1 -1
- package/esm/validators/float-validator.js +1 -1
- package/esm/validators/float-validator.js.map +1 -1
- package/esm/validators/index.d.ts +5 -0
- package/esm/validators/index.d.ts.map +1 -1
- package/esm/validators/int-validator.js +1 -1
- package/esm/validators/int-validator.js.map +1 -1
- package/esm/validators/methods/equality-conditional-methods.d.ts +88 -0
- package/esm/validators/methods/equality-conditional-methods.d.ts.map +1 -0
- package/esm/validators/methods/equality-conditional-methods.js +118 -0
- package/esm/validators/methods/equality-conditional-methods.js.map +1 -0
- package/esm/validators/methods/forbidden-methods.d.ts +58 -0
- package/esm/validators/methods/forbidden-methods.d.ts.map +1 -0
- package/esm/validators/methods/forbidden-methods.js +122 -0
- package/esm/validators/methods/forbidden-methods.js.map +1 -0
- package/esm/validators/methods/present-methods.d.ts +102 -0
- package/esm/validators/methods/present-methods.d.ts.map +1 -0
- package/esm/validators/methods/present-methods.js +229 -0
- package/esm/validators/methods/present-methods.js.map +1 -0
- package/esm/validators/methods/required-methods.d.ts +174 -0
- package/esm/validators/methods/required-methods.d.ts.map +1 -0
- package/esm/validators/methods/required-methods.js +246 -0
- package/esm/validators/methods/required-methods.js.map +1 -0
- package/esm/validators/number-validator.d.ts +11 -13
- package/esm/validators/number-validator.d.ts.map +1 -1
- package/esm/validators/number-validator.js +60 -78
- package/esm/validators/number-validator.js.map +1 -1
- package/esm/validators/numeric-validator.js +1 -1
- package/esm/validators/numeric-validator.js.map +1 -1
- package/esm/validators/object-validator.d.ts +1 -0
- package/esm/validators/object-validator.d.ts.map +1 -1
- package/esm/validators/object-validator.js +21 -15
- package/esm/validators/object-validator.js.map +1 -1
- package/esm/validators/primitive-validator.d.ts +70 -0
- package/esm/validators/primitive-validator.d.ts.map +1 -0
- package/esm/validators/primitive-validator.js +80 -0
- package/esm/validators/primitive-validator.js.map +1 -0
- package/esm/validators/record-validator.d.ts +4 -0
- package/esm/validators/record-validator.d.ts.map +1 -1
- package/esm/validators/record-validator.js +8 -2
- package/esm/validators/record-validator.js.map +1 -1
- package/esm/validators/scalar-validator.d.ts +5 -15
- package/esm/validators/scalar-validator.d.ts.map +1 -1
- package/esm/validators/scalar-validator.js +20 -78
- package/esm/validators/scalar-validator.js.map +1 -1
- package/esm/validators/string-validator.d.ts +2 -18
- package/esm/validators/string-validator.d.ts.map +1 -1
- package/esm/validators/string-validator.js +71 -164
- package/esm/validators/string-validator.js.map +1 -1
- package/esm/validators/tuple-validator.d.ts.map +1 -1
- package/esm/validators/tuple-validator.js +2 -2
- package/esm/validators/tuple-validator.js.map +1 -1
- package/esm/validators/union-validator.d.ts.map +1 -1
- package/esm/validators/union-validator.js +1 -3
- package/esm/validators/union-validator.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,14 +1,31 @@
|
|
|
1
|
-
import type { ContextualSchemaRule, ContextualizedMutator, ContextualizedTransformer, Mutator, SchemaContext, SchemaRule, SchemaRuleOptions, SimpleTransformerCallback, TransformerCallback, ValidationAttributesList, ValidationResult
|
|
1
|
+
import type { ContextualSchemaRule, ContextualizedMutator, ContextualizedTransformer, Mutator, SchemaContext, SchemaRule, SchemaRuleOptions, SimpleTransformerCallback, TransformerCallback, ValidationAttributesList, ValidationResult } from "../types";
|
|
2
2
|
/**
|
|
3
3
|
* Base validator class - foundation for all validators
|
|
4
4
|
*/
|
|
5
5
|
export declare class BaseValidator {
|
|
6
6
|
rules: ContextualSchemaRule[];
|
|
7
7
|
mutators: ContextualizedMutator[];
|
|
8
|
-
protected defaultValue: any;
|
|
8
|
+
protected defaultValue: any | (() => any);
|
|
9
9
|
protected description?: string;
|
|
10
10
|
protected shouldOmit: boolean;
|
|
11
11
|
protected isNullable: boolean;
|
|
12
|
+
protected isMutable: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Whether the field is optional.
|
|
15
|
+
* - false (default): field is required unless a requiredRule governs the condition.
|
|
16
|
+
* - true: field can be absent or empty — set by calling .optional().
|
|
17
|
+
*
|
|
18
|
+
* Also used as a TypeScript literal brand via the optional() return type.
|
|
19
|
+
*/
|
|
20
|
+
isOptional: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* The single required-condition rule for this field.
|
|
23
|
+
* - null: field uses strict default (always required when not optional).
|
|
24
|
+
* - set: the rule governs when the field is required (e.g., requiredIf).
|
|
25
|
+
*
|
|
26
|
+
* Stored separately from rules[] and prepended at validate() time.
|
|
27
|
+
*/
|
|
28
|
+
requiredRule: ContextualSchemaRule | null;
|
|
12
29
|
/**
|
|
13
30
|
* Pipeline to transform the mutated/original data before returning it
|
|
14
31
|
*/
|
|
@@ -23,6 +40,20 @@ export declare class BaseValidator {
|
|
|
23
40
|
* Attributed that will be always using the attribute translator
|
|
24
41
|
*/
|
|
25
42
|
protected translatedAttributes: Record<string, string>;
|
|
43
|
+
/**
|
|
44
|
+
* Mark the validator as mutable
|
|
45
|
+
*/
|
|
46
|
+
get mutable(): this;
|
|
47
|
+
/**
|
|
48
|
+
* Mark the validator as immutable
|
|
49
|
+
*/
|
|
50
|
+
get immutable(): this;
|
|
51
|
+
/**
|
|
52
|
+
* Get the instance to apply changes to.
|
|
53
|
+
* By default (immutable), returns a clone so the original is unchanged.
|
|
54
|
+
* When `.mutable` is set, returns `this` to mutate in place.
|
|
55
|
+
*/
|
|
56
|
+
protected get instance(): this;
|
|
26
57
|
/**
|
|
27
58
|
* Get the default value
|
|
28
59
|
* Supports lazy evaluation via callbacks
|
|
@@ -55,6 +86,25 @@ export declare class BaseValidator {
|
|
|
55
86
|
* ```
|
|
56
87
|
*/
|
|
57
88
|
addTransformer(transform: TransformerCallback, options?: any): this;
|
|
89
|
+
/**
|
|
90
|
+
* Add transformer with optional options
|
|
91
|
+
*
|
|
92
|
+
* @param transform - The transformer callback function
|
|
93
|
+
* @param options - Optional options to pass to the transformer
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* ```ts
|
|
97
|
+
* // Without options
|
|
98
|
+
* v.date().addTransformer(data => data.toISOString())
|
|
99
|
+
*
|
|
100
|
+
* // With options
|
|
101
|
+
* v.date().addTransformer(
|
|
102
|
+
* (data, { options }) => dayjs(data).format(options.format),
|
|
103
|
+
* { format: 'YYYY-MM-DD' }
|
|
104
|
+
* )
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
107
|
+
addMutableTransformer(transform: TransformerCallback, options?: any): void;
|
|
58
108
|
/**
|
|
59
109
|
* Transform the output value - simple one-time transformation
|
|
60
110
|
*
|
|
@@ -211,29 +261,36 @@ export declare class BaseValidator {
|
|
|
211
261
|
*/
|
|
212
262
|
isOmitted(): boolean;
|
|
213
263
|
/**
|
|
214
|
-
*
|
|
215
|
-
*/
|
|
216
|
-
equal(value: any, errorMessage?: string): this;
|
|
217
|
-
/**
|
|
218
|
-
* Value must be the same as another field's value
|
|
219
|
-
*/
|
|
220
|
-
sameAs(field: string, errorMessage?: string): this;
|
|
221
|
-
/**
|
|
222
|
-
* Value must be the same as another sibling field's value
|
|
264
|
+
* Add rule to the validator
|
|
223
265
|
*/
|
|
224
|
-
|
|
266
|
+
addRule<T extends SchemaRuleOptions = SchemaRuleOptions>(rule: SchemaRule<T>, errorMessage?: string, options?: T): this;
|
|
225
267
|
/**
|
|
226
|
-
*
|
|
268
|
+
* Set the required-condition rule for this field.
|
|
269
|
+
*
|
|
270
|
+
* Unlike addRule(), this does NOT push to rules[]. The rule is stored in the
|
|
271
|
+
* dedicated `requiredRule` slot and is prepended to the validation pipeline
|
|
272
|
+
* at runtime. Only one required rule can be active per field — this replaces
|
|
273
|
+
* any previously set required rule.
|
|
274
|
+
*
|
|
275
|
+
* Also marks the field as not optional (isOptional = false).
|
|
276
|
+
*
|
|
277
|
+
* @example
|
|
278
|
+
* ```ts
|
|
279
|
+
* // Used internally by required(), requiredIf(), requiredWith(), etc.
|
|
280
|
+
* BaseValidator.prototype.required = function(msg) {
|
|
281
|
+
* return this.setRequiredRule(requiredRule, msg);
|
|
282
|
+
* };
|
|
283
|
+
* ```
|
|
227
284
|
*/
|
|
228
|
-
|
|
285
|
+
setRequiredRule<T extends SchemaRuleOptions = SchemaRuleOptions>(rule: SchemaRule<T>, errorMessage?: string, options?: T): this;
|
|
229
286
|
/**
|
|
230
|
-
*
|
|
287
|
+
* Add mutable rule
|
|
231
288
|
*/
|
|
232
|
-
|
|
289
|
+
addMutableRule<T extends SchemaRuleOptions = SchemaRuleOptions>(rule: SchemaRule<T>, errorMessage?: string, options?: T): ContextualSchemaRule<T>;
|
|
233
290
|
/**
|
|
234
|
-
*
|
|
291
|
+
* Create new rule
|
|
235
292
|
*/
|
|
236
|
-
|
|
293
|
+
protected createRule<T extends SchemaRuleOptions = SchemaRuleOptions>(rule: SchemaRule<T>, errorMessage?: string, options?: T): ContextualSchemaRule<T>;
|
|
237
294
|
/**
|
|
238
295
|
* Use a custom or pre-built validation rule
|
|
239
296
|
*
|
|
@@ -268,364 +325,17 @@ export declare class BaseValidator {
|
|
|
268
325
|
*/
|
|
269
326
|
addMutator(mutator: Mutator, options?: any): this;
|
|
270
327
|
/**
|
|
271
|
-
*
|
|
328
|
+
* Add mutable mutator
|
|
272
329
|
*/
|
|
273
|
-
|
|
330
|
+
addMutableMutator(mutator: Mutator, options?: any): void;
|
|
274
331
|
/**
|
|
275
|
-
*
|
|
276
|
-
*/
|
|
277
|
-
required(errorMessage?: string): this;
|
|
278
|
-
/**
|
|
279
|
-
* Value must be present but not necessarily has a value
|
|
280
|
-
*/
|
|
281
|
-
present(errorMessage?: string): this;
|
|
282
|
-
/**
|
|
283
|
-
* Mark the field as optional, so pass it if it has no value or has a value
|
|
284
|
-
* Because this is the default behavior, this method is just syntactic sugar
|
|
285
|
-
*/
|
|
286
|
-
optional(): this;
|
|
287
|
-
/**
|
|
288
|
-
* Value is required if another field exists
|
|
289
|
-
*/
|
|
290
|
-
requiredWith(field: string, errorMessage?: string): this;
|
|
291
|
-
/**
|
|
292
|
-
* Value is required if another sibling field exists
|
|
293
|
-
*/
|
|
294
|
-
requiredWithSibling(field: string, errorMessage?: string): this;
|
|
295
|
-
/**
|
|
296
|
-
* Value is required if another field is missing
|
|
297
|
-
*/
|
|
298
|
-
requiredWithout(field: string, errorMessage?: string): this;
|
|
299
|
-
/**
|
|
300
|
-
* Value is required if another sibling field is missing
|
|
301
|
-
*/
|
|
302
|
-
requiredWithoutSibling(field: string, errorMessage?: string): this;
|
|
303
|
-
/**
|
|
304
|
-
* Value is required if another field equals a specific value
|
|
305
|
-
*/
|
|
306
|
-
requiredIf(field: string, value: any, errorMessage?: string): this;
|
|
307
|
-
/**
|
|
308
|
-
* Value is required if another sibling field equals a specific value
|
|
309
|
-
*/
|
|
310
|
-
requiredIfSibling(field: string, value: any, errorMessage?: string): this;
|
|
311
|
-
/**
|
|
312
|
-
* Value is required unless another field equals a specific value
|
|
313
|
-
*/
|
|
314
|
-
requiredUnless(field: string, value: any, errorMessage?: string): this;
|
|
315
|
-
/**
|
|
316
|
-
* Value is required unless another sibling field equals a specific value
|
|
317
|
-
*/
|
|
318
|
-
requiredUnlessSibling(field: string, value: any, errorMessage?: string): this;
|
|
319
|
-
/**
|
|
320
|
-
* Value is required if another field is empty
|
|
321
|
-
*/
|
|
322
|
-
requiredIfEmpty(field: string, errorMessage?: string): this;
|
|
323
|
-
/**
|
|
324
|
-
* Value is required if another sibling field is empty
|
|
325
|
-
*/
|
|
326
|
-
requiredIfEmptySibling(field: string, errorMessage?: string): this;
|
|
327
|
-
/**
|
|
328
|
-
* Value is required if another field is not empty
|
|
329
|
-
*/
|
|
330
|
-
requiredIfNotEmpty(field: string, errorMessage?: string): this;
|
|
331
|
-
/**
|
|
332
|
-
* Value is required if another sibling field is not empty
|
|
333
|
-
*/
|
|
334
|
-
requiredIfNotEmptySibling(field: string, errorMessage?: string): this;
|
|
335
|
-
/**
|
|
336
|
-
* Value is required if ALL specified fields are empty
|
|
337
|
-
*/
|
|
338
|
-
requiredIfAllEmpty(fields: string[], errorMessage?: string): this;
|
|
339
|
-
/**
|
|
340
|
-
* Value is required if ALL specified sibling fields are empty
|
|
341
|
-
*/
|
|
342
|
-
requiredIfAllEmptySiblings(fields: string[], errorMessage?: string): this;
|
|
343
|
-
/**
|
|
344
|
-
* Value is required if ANY of the specified fields is empty
|
|
345
|
-
*/
|
|
346
|
-
requiredIfAnyEmpty(fields: string[], errorMessage?: string): this;
|
|
347
|
-
/**
|
|
348
|
-
* Value is required if ANY of the specified sibling fields is empty
|
|
349
|
-
*/
|
|
350
|
-
requiredIfAnyEmptySiblings(fields: string[], errorMessage?: string): this;
|
|
351
|
-
/**
|
|
352
|
-
* Value is required if ALL specified fields are NOT empty
|
|
353
|
-
*/
|
|
354
|
-
requiredIfAllNotEmpty(fields: string[], errorMessage?: string): this;
|
|
355
|
-
/**
|
|
356
|
-
* Value is required if ALL specified sibling fields are NOT empty
|
|
357
|
-
*/
|
|
358
|
-
requiredIfAllNotEmptySiblings(fields: string[], errorMessage?: string): this;
|
|
359
|
-
/**
|
|
360
|
-
* Value is required if ANY of the specified fields is NOT empty
|
|
361
|
-
*/
|
|
362
|
-
requiredIfAnyNotEmpty(fields: string[], errorMessage?: string): this;
|
|
363
|
-
/**
|
|
364
|
-
* Value is required if ANY of the specified sibling fields is NOT empty
|
|
365
|
-
*/
|
|
366
|
-
requiredIfAnyNotEmptySiblings(fields: string[], errorMessage?: string): this;
|
|
367
|
-
/**
|
|
368
|
-
* Value is required if another field's value is in the given array
|
|
369
|
-
*/
|
|
370
|
-
requiredIfIn(field: string, values: any[], errorMessage?: string): this;
|
|
371
|
-
/**
|
|
372
|
-
* Value is required if another sibling field's value is in the given array
|
|
373
|
-
*/
|
|
374
|
-
requiredIfInSibling(field: string, values: any[], errorMessage?: string): this;
|
|
375
|
-
/**
|
|
376
|
-
* Value is required if another field's value is NOT in the given array
|
|
377
|
-
*/
|
|
378
|
-
requiredIfNotIn(field: string, values: any[], errorMessage?: string): this;
|
|
379
|
-
/**
|
|
380
|
-
* Value is required if another sibling field's value is NOT in the given array
|
|
381
|
-
*/
|
|
382
|
-
requiredIfNotInSibling(field: string, values: any[], errorMessage?: string): this;
|
|
383
|
-
/**
|
|
384
|
-
* Value is required if all specified fields exist
|
|
385
|
-
*/
|
|
386
|
-
requiredWithAll(fields: string[], errorMessage?: string): this;
|
|
387
|
-
/**
|
|
388
|
-
* Value is required if all specified sibling fields exist
|
|
389
|
-
*/
|
|
390
|
-
requiredWithAllSiblings(fields: string[], errorMessage?: string): this;
|
|
391
|
-
/**
|
|
392
|
-
* Value is required if all specified fields are missing
|
|
393
|
-
*/
|
|
394
|
-
requiredWithoutAll(fields: string[], errorMessage?: string): this;
|
|
395
|
-
/**
|
|
396
|
-
* Value is required if all specified sibling fields are missing
|
|
397
|
-
*/
|
|
398
|
-
requiredWithoutAllSiblings(fields: string[], errorMessage?: string): this;
|
|
399
|
-
/**
|
|
400
|
-
* Value is required if any of the specified fields exists
|
|
401
|
-
*/
|
|
402
|
-
requiredWithAny(fields: string[], errorMessage?: string): this;
|
|
403
|
-
/**
|
|
404
|
-
* Value is required if any of the specified sibling fields exists
|
|
405
|
-
*/
|
|
406
|
-
requiredWithAnySiblings(fields: string[], errorMessage?: string): this;
|
|
407
|
-
/**
|
|
408
|
-
* Value is required if any of the specified fields is missing
|
|
409
|
-
*/
|
|
410
|
-
requiredWithoutAny(fields: string[], errorMessage?: string): this;
|
|
411
|
-
/**
|
|
412
|
-
* Value is required if any of the specified sibling fields is missing
|
|
413
|
-
*/
|
|
414
|
-
requiredWithoutAnySiblings(fields: string[], errorMessage?: string): this;
|
|
415
|
-
/**
|
|
416
|
-
* Field must be present if another field exists
|
|
417
|
-
*/
|
|
418
|
-
presentWith(field: string, errorMessage?: string): this;
|
|
419
|
-
/**
|
|
420
|
-
* Field must be present if another sibling field exists
|
|
421
|
-
*/
|
|
422
|
-
presentWithSibling(field: string, errorMessage?: string): this;
|
|
423
|
-
/**
|
|
424
|
-
* Field must be present if another field is missing
|
|
425
|
-
*/
|
|
426
|
-
presentWithout(field: string, errorMessage?: string): this;
|
|
427
|
-
/**
|
|
428
|
-
* Field must be present if another sibling field is missing
|
|
429
|
-
*/
|
|
430
|
-
presentWithoutSibling(field: string, errorMessage?: string): this;
|
|
431
|
-
/**
|
|
432
|
-
* Field must be present if another field equals a specific value
|
|
433
|
-
*/
|
|
434
|
-
presentIf(field: string, value: any, errorMessage?: string): this;
|
|
435
|
-
/**
|
|
436
|
-
* Field must be present if another sibling field equals a specific value
|
|
437
|
-
*/
|
|
438
|
-
presentIfSibling(field: string, value: any, errorMessage?: string): this;
|
|
439
|
-
/**
|
|
440
|
-
* Field must be present unless another field equals a specific value
|
|
441
|
-
*/
|
|
442
|
-
presentUnless(field: string, value: any, errorMessage?: string): this;
|
|
443
|
-
/**
|
|
444
|
-
* Field must be present unless another sibling field equals a specific value
|
|
445
|
-
*/
|
|
446
|
-
presentUnlessSibling(field: string, value: any, errorMessage?: string): this;
|
|
447
|
-
/**
|
|
448
|
-
* Field must be present if another field is empty
|
|
449
|
-
*/
|
|
450
|
-
presentIfEmpty(field: string, errorMessage?: string): this;
|
|
451
|
-
/**
|
|
452
|
-
* Field must be present if another sibling field is empty
|
|
453
|
-
*/
|
|
454
|
-
presentIfEmptySibling(field: string, errorMessage?: string): this;
|
|
455
|
-
/**
|
|
456
|
-
* Field must be present if another field is not empty
|
|
457
|
-
*/
|
|
458
|
-
presentIfNotEmpty(field: string, errorMessage?: string): this;
|
|
459
|
-
/**
|
|
460
|
-
* Field must be present if another sibling field is not empty
|
|
461
|
-
*/
|
|
462
|
-
presentIfNotEmptySibling(field: string, errorMessage?: string): this;
|
|
463
|
-
/**
|
|
464
|
-
* Field must be present if another field's value is in the given array
|
|
465
|
-
*/
|
|
466
|
-
presentIfIn(field: string, values: any[], errorMessage?: string): this;
|
|
467
|
-
/**
|
|
468
|
-
* Field must be present if another sibling field's value is in the given array
|
|
469
|
-
*/
|
|
470
|
-
presentIfInSibling(field: string, values: any[], errorMessage?: string): this;
|
|
471
|
-
/**
|
|
472
|
-
* Field must be present if another field's value is NOT in the given array
|
|
473
|
-
*/
|
|
474
|
-
presentIfNotIn(field: string, values: any[], errorMessage?: string): this;
|
|
475
|
-
/**
|
|
476
|
-
* Field must be present if another sibling field's value is NOT in the given array
|
|
477
|
-
*/
|
|
478
|
-
presentIfNotInSibling(field: string, values: any[], errorMessage?: string): this;
|
|
479
|
-
/**
|
|
480
|
-
* Field must be present if all specified fields exist
|
|
481
|
-
*/
|
|
482
|
-
presentWithAll(fields: string[], errorMessage?: string): this;
|
|
483
|
-
/**
|
|
484
|
-
* Field must be present if all specified sibling fields exist
|
|
485
|
-
*/
|
|
486
|
-
presentWithAllSiblings(fields: string[], errorMessage?: string): this;
|
|
487
|
-
/**
|
|
488
|
-
* Field must be present if all specified fields are missing
|
|
489
|
-
*/
|
|
490
|
-
presentWithoutAll(fields: string[], errorMessage?: string): this;
|
|
491
|
-
/**
|
|
492
|
-
* Field must be present if all specified sibling fields are missing
|
|
493
|
-
*/
|
|
494
|
-
presentWithoutAllSiblings(fields: string[], errorMessage?: string): this;
|
|
495
|
-
/**
|
|
496
|
-
* Field must be present if any of the specified fields exists
|
|
497
|
-
*/
|
|
498
|
-
presentWithAny(fields: string[], errorMessage?: string): this;
|
|
499
|
-
/**
|
|
500
|
-
* Field must be present if any of the specified sibling fields exists
|
|
501
|
-
*/
|
|
502
|
-
presentWithAnySiblings(fields: string[], errorMessage?: string): this;
|
|
503
|
-
/**
|
|
504
|
-
* Field must be present if any of the specified fields is missing
|
|
505
|
-
*/
|
|
506
|
-
presentWithoutAny(fields: string[], errorMessage?: string): this;
|
|
507
|
-
/**
|
|
508
|
-
* Field must be present if any of the specified sibling fields is missing
|
|
332
|
+
* Set default value for the field
|
|
509
333
|
*/
|
|
510
|
-
|
|
334
|
+
default(value: any): this;
|
|
511
335
|
/**
|
|
512
336
|
* Mutate the data
|
|
513
337
|
*/
|
|
514
338
|
mutate(data: any, context: SchemaContext): Promise<any>;
|
|
515
|
-
/**
|
|
516
|
-
* Value is forbidden to be present
|
|
517
|
-
*/
|
|
518
|
-
forbidden(errorMessage?: string): this;
|
|
519
|
-
/**
|
|
520
|
-
* Value is forbidden if another field equals a specific value (global scope)
|
|
521
|
-
*/
|
|
522
|
-
forbiddenIf(field: string, value: any, errorMessage?: string): this;
|
|
523
|
-
/**
|
|
524
|
-
* Value is forbidden if another field equals a specific value (sibling scope)
|
|
525
|
-
*/
|
|
526
|
-
forbiddenIfSibling(field: string, value: any, errorMessage?: string): this;
|
|
527
|
-
/**
|
|
528
|
-
* Value is forbidden if another field does NOT equal a specific value (global scope)
|
|
529
|
-
*/
|
|
530
|
-
forbiddenIfNot(field: string, value: any, errorMessage?: string): this;
|
|
531
|
-
/**
|
|
532
|
-
* Value is forbidden if another field does NOT equal a specific value (sibling scope)
|
|
533
|
-
*/
|
|
534
|
-
forbiddenIfNotSibling(field: string, value: any, errorMessage?: string): this;
|
|
535
|
-
/**
|
|
536
|
-
* Value is forbidden if another field is empty (global scope)
|
|
537
|
-
*/
|
|
538
|
-
forbiddenIfEmpty(field: string, errorMessage?: string): this;
|
|
539
|
-
/**
|
|
540
|
-
* Value is forbidden if another field is empty (sibling scope)
|
|
541
|
-
*/
|
|
542
|
-
forbiddenIfEmptySibling(field: string, errorMessage?: string): this;
|
|
543
|
-
/**
|
|
544
|
-
* Value is forbidden if another field is not empty (global scope)
|
|
545
|
-
*/
|
|
546
|
-
forbiddenIfNotEmpty(field: string, errorMessage?: string): this;
|
|
547
|
-
/**
|
|
548
|
-
* Value is forbidden if another field is not empty (sibling scope)
|
|
549
|
-
*/
|
|
550
|
-
forbiddenIfNotEmptySibling(field: string, errorMessage?: string): this;
|
|
551
|
-
/**
|
|
552
|
-
* Value is forbidden if another field's value is in the given array (global scope)
|
|
553
|
-
*/
|
|
554
|
-
forbiddenIfIn(field: string, values: any[], errorMessage?: string): this;
|
|
555
|
-
/**
|
|
556
|
-
* Value is forbidden if another field's value is in the given array (sibling scope)
|
|
557
|
-
*/
|
|
558
|
-
forbiddenIfInSibling(field: string, values: any[], errorMessage?: string): this;
|
|
559
|
-
/**
|
|
560
|
-
* Value is forbidden if another field's value is NOT in the given array (global scope)
|
|
561
|
-
*/
|
|
562
|
-
forbiddenIfNotIn(field: string, values: any[], errorMessage?: string): this;
|
|
563
|
-
/**
|
|
564
|
-
* Value is forbidden if another field's value is NOT in the given array (sibling scope)
|
|
565
|
-
*/
|
|
566
|
-
forbiddenIfNotInSibling(field: string, values: any[], errorMessage?: string): this;
|
|
567
|
-
/**
|
|
568
|
-
* Apply different validation rules based on another field's value (global scope)
|
|
569
|
-
*
|
|
570
|
-
* Use this when you need to apply completely different validators
|
|
571
|
-
* based on another field's value (not just required/optional).
|
|
572
|
-
*
|
|
573
|
-
* @param field - Field name to check (can be nested with dot notation)
|
|
574
|
-
* @param options - Validation options per field value
|
|
575
|
-
*
|
|
576
|
-
* @example
|
|
577
|
-
* ```ts
|
|
578
|
-
* // Different allowed values based on user type
|
|
579
|
-
* v.object({
|
|
580
|
-
* userType: v.string().in(['admin', 'user']),
|
|
581
|
-
* role: v.string().when('userType', {
|
|
582
|
-
* is: {
|
|
583
|
-
* admin: v.string().in(['super', 'moderator']),
|
|
584
|
-
* user: v.string().in(['member', 'guest'])
|
|
585
|
-
* },
|
|
586
|
-
* otherwise: v.string().optional()
|
|
587
|
-
* })
|
|
588
|
-
* })
|
|
589
|
-
*
|
|
590
|
-
* // Different validation rules based on type
|
|
591
|
-
* v.object({
|
|
592
|
-
* contactType: v.string().in(['email', 'phone']),
|
|
593
|
-
* contact: v.string().when('contactType', {
|
|
594
|
-
* is: {
|
|
595
|
-
* email: v.string().email(),
|
|
596
|
-
* phone: v.string().pattern(/^\d{10}$/)
|
|
597
|
-
* }
|
|
598
|
-
* })
|
|
599
|
-
* })
|
|
600
|
-
* ```
|
|
601
|
-
* @category Conditional Validation
|
|
602
|
-
*/
|
|
603
|
-
when(field: string, options: Omit<WhenRuleOptions, "field" | "scope">): this;
|
|
604
|
-
/**
|
|
605
|
-
* Apply different validation rules based on sibling field's value
|
|
606
|
-
*
|
|
607
|
-
* Use this for nested objects where you need to check a field
|
|
608
|
-
* within the same parent object.
|
|
609
|
-
*
|
|
610
|
-
* @param siblingField - Sibling field name to check
|
|
611
|
-
* @param options - Validation options per field value
|
|
612
|
-
*
|
|
613
|
-
* @example
|
|
614
|
-
* ```ts
|
|
615
|
-
* // Array of users with role-based permissions
|
|
616
|
-
* v.array(v.object({
|
|
617
|
-
* userType: v.string().in(['admin', 'user']),
|
|
618
|
-
* permissions: v.string().whenSibling('userType', {
|
|
619
|
-
* is: {
|
|
620
|
-
* admin: v.string().in(['read', 'write', 'delete']),
|
|
621
|
-
* user: v.string().in(['read'])
|
|
622
|
-
* }
|
|
623
|
-
* })
|
|
624
|
-
* }))
|
|
625
|
-
* ```
|
|
626
|
-
* @category Conditional Validation
|
|
627
|
-
*/
|
|
628
|
-
whenSibling(siblingField: string, options: Omit<WhenRuleOptions, "field" | "scope">): this;
|
|
629
339
|
/**
|
|
630
340
|
* Set the label for the validator that will be matching the :input attribute
|
|
631
341
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-validator.d.ts","sourceRoot":"","sources":["../../src/validators/base-validator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"base-validator.d.ts","sourceRoot":"","sources":["../../src/validators/base-validator.ts"],"names":[],"mappings":"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"}
|