@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
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
'use strict';var presentIfRules=require('../../rules/conditional/present-if-rules.js'),presentUnlessRules=require('../../rules/conditional/present-unless-rules.js'),presentWithRules=require('../../rules/conditional/present-with-rules.js'),presentWithoutRules=require('../../rules/conditional/present-without-rules.js'),baseValidator=require('../base-validator.js');// ==================== PRESENT: BASED ON FIELD PRESENCE ====================
|
|
2
|
+
/**
|
|
3
|
+
* Field must be present if another field exists
|
|
4
|
+
*/
|
|
5
|
+
baseValidator.BaseValidator.prototype.presentWith = function (field, errorMessage) {
|
|
6
|
+
return this.addRule(presentWithRules.presentWithRule, errorMessage, {
|
|
7
|
+
field,
|
|
8
|
+
scope: "global",
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Field must be present if another sibling field exists
|
|
13
|
+
*/
|
|
14
|
+
baseValidator.BaseValidator.prototype.presentWithSibling = function (field, errorMessage) {
|
|
15
|
+
return this.addRule(presentWithRules.presentWithRule, errorMessage, {
|
|
16
|
+
field,
|
|
17
|
+
scope: "sibling",
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Field must be present if another field is missing
|
|
22
|
+
*/
|
|
23
|
+
baseValidator.BaseValidator.prototype.presentWithout = function (field, errorMessage) {
|
|
24
|
+
return this.addRule(presentWithoutRules.presentWithoutRule, errorMessage, {
|
|
25
|
+
field,
|
|
26
|
+
scope: "global",
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Field must be present if another sibling field is missing
|
|
31
|
+
*/
|
|
32
|
+
baseValidator.BaseValidator.prototype.presentWithoutSibling = function (field, errorMessage) {
|
|
33
|
+
return this.addRule(presentWithoutRules.presentWithoutRule, errorMessage, {
|
|
34
|
+
field,
|
|
35
|
+
scope: "sibling",
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
// ==================== PRESENT: BASED ON FIELD VALUE ====================
|
|
39
|
+
/**
|
|
40
|
+
* Field must be present if another field equals a specific value
|
|
41
|
+
*/
|
|
42
|
+
baseValidator.BaseValidator.prototype.presentIf = function (field, value, errorMessage) {
|
|
43
|
+
return this.addRule(presentIfRules.presentIfRule, errorMessage, {
|
|
44
|
+
field,
|
|
45
|
+
value,
|
|
46
|
+
scope: "global",
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Field must be present if another sibling field equals a specific value
|
|
51
|
+
*/
|
|
52
|
+
baseValidator.BaseValidator.prototype.presentIfSibling = function (field, value, errorMessage) {
|
|
53
|
+
return this.addRule(presentIfRules.presentIfRule, errorMessage, {
|
|
54
|
+
field,
|
|
55
|
+
value,
|
|
56
|
+
scope: "sibling",
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Field must be present unless another field equals a specific value
|
|
61
|
+
*/
|
|
62
|
+
baseValidator.BaseValidator.prototype.presentUnless = function (field, value, errorMessage) {
|
|
63
|
+
return this.addRule(presentUnlessRules.presentUnlessRule, errorMessage, {
|
|
64
|
+
field,
|
|
65
|
+
value,
|
|
66
|
+
scope: "global",
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* Field must be present unless another sibling field equals a specific value
|
|
71
|
+
*/
|
|
72
|
+
baseValidator.BaseValidator.prototype.presentUnlessSibling = function (field, value, errorMessage) {
|
|
73
|
+
return this.addRule(presentUnlessRules.presentUnlessRule, errorMessage, {
|
|
74
|
+
field,
|
|
75
|
+
value,
|
|
76
|
+
scope: "sibling",
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
// ==================== PRESENT: BASED ON FIELD EMPTY STATE ====================
|
|
80
|
+
/**
|
|
81
|
+
* Field must be present if another field is empty
|
|
82
|
+
*/
|
|
83
|
+
baseValidator.BaseValidator.prototype.presentIfEmpty = function (field, errorMessage) {
|
|
84
|
+
return this.addRule(presentIfRules.presentIfEmptyRule, errorMessage, {
|
|
85
|
+
field,
|
|
86
|
+
scope: "global",
|
|
87
|
+
});
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* Field must be present if another sibling field is empty
|
|
91
|
+
*/
|
|
92
|
+
baseValidator.BaseValidator.prototype.presentIfEmptySibling = function (field, errorMessage) {
|
|
93
|
+
return this.addRule(presentIfRules.presentIfEmptyRule, errorMessage, {
|
|
94
|
+
field,
|
|
95
|
+
scope: "sibling",
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* Field must be present if another field is not empty
|
|
100
|
+
*/
|
|
101
|
+
baseValidator.BaseValidator.prototype.presentIfNotEmpty = function (field, errorMessage) {
|
|
102
|
+
return this.addRule(presentIfRules.presentIfNotEmptyRule, errorMessage, {
|
|
103
|
+
field,
|
|
104
|
+
scope: "global",
|
|
105
|
+
});
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* Field must be present if another sibling field is not empty
|
|
109
|
+
*/
|
|
110
|
+
baseValidator.BaseValidator.prototype.presentIfNotEmptySibling = function (field, errorMessage) {
|
|
111
|
+
return this.addRule(presentIfRules.presentIfNotEmptyRule, errorMessage, {
|
|
112
|
+
field,
|
|
113
|
+
scope: "sibling",
|
|
114
|
+
});
|
|
115
|
+
};
|
|
116
|
+
/**
|
|
117
|
+
* Field must be present if another field's value is in the given array
|
|
118
|
+
*/
|
|
119
|
+
baseValidator.BaseValidator.prototype.presentIfIn = function (field, values, errorMessage) {
|
|
120
|
+
return this.addRule(presentIfRules.presentIfInRule, errorMessage, {
|
|
121
|
+
field,
|
|
122
|
+
values,
|
|
123
|
+
scope: "global",
|
|
124
|
+
});
|
|
125
|
+
};
|
|
126
|
+
/**
|
|
127
|
+
* Field must be present if another sibling field's value is in the given array
|
|
128
|
+
*/
|
|
129
|
+
baseValidator.BaseValidator.prototype.presentIfInSibling = function (field, values, errorMessage) {
|
|
130
|
+
return this.addRule(presentIfRules.presentIfInRule, errorMessage, {
|
|
131
|
+
field,
|
|
132
|
+
values,
|
|
133
|
+
scope: "sibling",
|
|
134
|
+
});
|
|
135
|
+
};
|
|
136
|
+
/**
|
|
137
|
+
* Field must be present if another field's value is NOT in the given array
|
|
138
|
+
*/
|
|
139
|
+
baseValidator.BaseValidator.prototype.presentIfNotIn = function (field, values, errorMessage) {
|
|
140
|
+
return this.addRule(presentIfRules.presentIfNotInRule, errorMessage, {
|
|
141
|
+
field,
|
|
142
|
+
values,
|
|
143
|
+
scope: "global",
|
|
144
|
+
});
|
|
145
|
+
};
|
|
146
|
+
/**
|
|
147
|
+
* Field must be present if another sibling field's value is NOT in the given array
|
|
148
|
+
*/
|
|
149
|
+
baseValidator.BaseValidator.prototype.presentIfNotInSibling = function (field, values, errorMessage) {
|
|
150
|
+
return this.addRule(presentIfRules.presentIfNotInRule, errorMessage, {
|
|
151
|
+
field,
|
|
152
|
+
values,
|
|
153
|
+
scope: "sibling",
|
|
154
|
+
});
|
|
155
|
+
};
|
|
156
|
+
// ==================== PRESENT: BASED ON MULTIPLE FIELDS (ALL) ====================
|
|
157
|
+
/**
|
|
158
|
+
* Field must be present if all specified fields exist
|
|
159
|
+
*/
|
|
160
|
+
baseValidator.BaseValidator.prototype.presentWithAll = function (fields, errorMessage) {
|
|
161
|
+
return this.addRule(presentWithRules.presentWithAllRule, errorMessage, {
|
|
162
|
+
fields,
|
|
163
|
+
scope: "global",
|
|
164
|
+
});
|
|
165
|
+
};
|
|
166
|
+
/**
|
|
167
|
+
* Field must be present if all specified sibling fields exist
|
|
168
|
+
*/
|
|
169
|
+
baseValidator.BaseValidator.prototype.presentWithAllSiblings = function (fields, errorMessage) {
|
|
170
|
+
return this.addRule(presentWithRules.presentWithAllRule, errorMessage, {
|
|
171
|
+
fields,
|
|
172
|
+
scope: "sibling",
|
|
173
|
+
});
|
|
174
|
+
};
|
|
175
|
+
/**
|
|
176
|
+
* Field must be present if all specified fields are missing
|
|
177
|
+
*/
|
|
178
|
+
baseValidator.BaseValidator.prototype.presentWithoutAll = function (fields, errorMessage) {
|
|
179
|
+
return this.addRule(presentWithoutRules.presentWithoutAllRule, errorMessage, {
|
|
180
|
+
fields,
|
|
181
|
+
scope: "global",
|
|
182
|
+
});
|
|
183
|
+
};
|
|
184
|
+
/**
|
|
185
|
+
* Field must be present if all specified sibling fields are missing
|
|
186
|
+
*/
|
|
187
|
+
baseValidator.BaseValidator.prototype.presentWithoutAllSiblings = function (fields, errorMessage) {
|
|
188
|
+
return this.addRule(presentWithoutRules.presentWithoutAllRule, errorMessage, {
|
|
189
|
+
fields,
|
|
190
|
+
scope: "sibling",
|
|
191
|
+
});
|
|
192
|
+
};
|
|
193
|
+
// ==================== PRESENT: BASED ON MULTIPLE FIELDS (ANY) ====================
|
|
194
|
+
/**
|
|
195
|
+
* Field must be present if any of the specified fields exists
|
|
196
|
+
*/
|
|
197
|
+
baseValidator.BaseValidator.prototype.presentWithAny = function (fields, errorMessage) {
|
|
198
|
+
return this.addRule(presentWithRules.presentWithAnyRule, errorMessage, {
|
|
199
|
+
fields,
|
|
200
|
+
scope: "global",
|
|
201
|
+
});
|
|
202
|
+
};
|
|
203
|
+
/**
|
|
204
|
+
* Field must be present if any of the specified sibling fields exists
|
|
205
|
+
*/
|
|
206
|
+
baseValidator.BaseValidator.prototype.presentWithAnySiblings = function (fields, errorMessage) {
|
|
207
|
+
return this.addRule(presentWithRules.presentWithAnyRule, errorMessage, {
|
|
208
|
+
fields,
|
|
209
|
+
scope: "sibling",
|
|
210
|
+
});
|
|
211
|
+
};
|
|
212
|
+
/**
|
|
213
|
+
* Field must be present if any of the specified fields is missing
|
|
214
|
+
*/
|
|
215
|
+
baseValidator.BaseValidator.prototype.presentWithoutAny = function (fields, errorMessage) {
|
|
216
|
+
return this.addRule(presentWithoutRules.presentWithoutAnyRule, errorMessage, {
|
|
217
|
+
fields,
|
|
218
|
+
scope: "global",
|
|
219
|
+
});
|
|
220
|
+
};
|
|
221
|
+
/**
|
|
222
|
+
* Field must be present if any of the specified sibling fields is missing
|
|
223
|
+
*/
|
|
224
|
+
baseValidator.BaseValidator.prototype.presentWithoutAnySiblings = function (fields, errorMessage) {
|
|
225
|
+
return this.addRule(presentWithoutRules.presentWithoutAnyRule, errorMessage, {
|
|
226
|
+
fields,
|
|
227
|
+
scope: "sibling",
|
|
228
|
+
});
|
|
229
|
+
};//# sourceMappingURL=present-methods.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"present-methods.js","sources":["../../../src/validators/methods/present-methods.ts"],"sourcesContent":[null],"names":["BaseValidator","presentWithRule","presentWithoutRule","presentIfRule","presentUnlessRule","presentIfEmptyRule","presentIfNotEmptyRule","presentIfInRule","presentIfNotInRule","presentWithAllRule","presentWithoutAllRule","presentWithAnyRule","presentWithoutAnyRule"],"mappings":"6WAgJA;AAEA;;AAEG;AACHA,2BAAa,CAAC,SAAS,CAAC,WAAW,GAAG,UAAU,KAAa,EAAE,YAAqB,EAAA;AAClF,IAAA,OAAO,IAAI,CAAC,OAAO,CAACC,gCAAe,EAAE,YAAY,EAAE;QACjD,KAAK;AACL,QAAA,KAAK,EAAE,QAAQ;AAChB,KAAA,CAAC,CAAC;AACL,CAAC,CAAC;AAEF;;AAEG;AACHD,2BAAa,CAAC,SAAS,CAAC,kBAAkB,GAAG,UAAU,KAAa,EAAE,YAAqB,EAAA;AACzF,IAAA,OAAO,IAAI,CAAC,OAAO,CAACC,gCAAe,EAAE,YAAY,EAAE;QACjD,KAAK;AACL,QAAA,KAAK,EAAE,SAAS;AACjB,KAAA,CAAC,CAAC;AACL,CAAC,CAAC;AAEF;;AAEG;AACHD,2BAAa,CAAC,SAAS,CAAC,cAAc,GAAG,UAAU,KAAa,EAAE,YAAqB,EAAA;AACrF,IAAA,OAAO,IAAI,CAAC,OAAO,CAACE,sCAAkB,EAAE,YAAY,EAAE;QACpD,KAAK;AACL,QAAA,KAAK,EAAE,QAAQ;AAChB,KAAA,CAAC,CAAC;AACL,CAAC,CAAC;AAEF;;AAEG;AACHF,2BAAa,CAAC,SAAS,CAAC,qBAAqB,GAAG,UAAU,KAAa,EAAE,YAAqB,EAAA;AAC5F,IAAA,OAAO,IAAI,CAAC,OAAO,CAACE,sCAAkB,EAAE,YAAY,EAAE;QACpD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B,EAChB,YAAqB,EAAA;AAErB,IAAA,OAAO,IAAI,CAAC,OAAO,CAACY,yCAAqB,EAAE,YAAY,EAAE;QACvD,MAAM;AACN,QAAA,KAAK,EAAE,SAAS;AACjB,KAAA,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import type { SchemaContext } from "../../types";
|
|
2
|
+
declare module "../base-validator" {
|
|
3
|
+
interface BaseValidator {
|
|
4
|
+
/**
|
|
5
|
+
* This value must be present and has a value
|
|
6
|
+
*/
|
|
7
|
+
required(errorMessage?: string): this;
|
|
8
|
+
/**
|
|
9
|
+
* Value must be present but not necessarily has a value
|
|
10
|
+
*/
|
|
11
|
+
present(errorMessage?: string): this;
|
|
12
|
+
/**
|
|
13
|
+
* Mark the field as optional, so pass it if it has no value or has a value
|
|
14
|
+
* Because this is the default behavior, this method is just syntactic sugar
|
|
15
|
+
*/
|
|
16
|
+
optional(): this & {
|
|
17
|
+
isOptional: true;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Value is required if another field exists
|
|
21
|
+
*/
|
|
22
|
+
requiredWith(field: string, errorMessage?: string): this;
|
|
23
|
+
/**
|
|
24
|
+
* Value is required if another sibling field exists
|
|
25
|
+
*/
|
|
26
|
+
requiredWithSibling(field: string, errorMessage?: string): this;
|
|
27
|
+
/**
|
|
28
|
+
* Value is required if another field is missing
|
|
29
|
+
*/
|
|
30
|
+
requiredWithout(field: string, errorMessage?: string): this;
|
|
31
|
+
/**
|
|
32
|
+
* Value is required if another sibling field is missing
|
|
33
|
+
*/
|
|
34
|
+
requiredWithoutSibling(field: string, errorMessage?: string): this;
|
|
35
|
+
/**
|
|
36
|
+
* Value is required if another field equals a specific value
|
|
37
|
+
*/
|
|
38
|
+
requiredIf(field: string, value: any, errorMessage?: string): this;
|
|
39
|
+
/**
|
|
40
|
+
* Value is required if another sibling field equals a specific value
|
|
41
|
+
*/
|
|
42
|
+
requiredIfSibling(field: string, value: any, errorMessage?: string): this;
|
|
43
|
+
/**
|
|
44
|
+
* Value is required unless another field equals a specific value
|
|
45
|
+
*/
|
|
46
|
+
requiredUnless(field: string, value: any, errorMessage?: string): this;
|
|
47
|
+
/**
|
|
48
|
+
* Value is required unless another sibling field equals a specific value
|
|
49
|
+
*/
|
|
50
|
+
requiredUnlessSibling(field: string, value: any, errorMessage?: string): this;
|
|
51
|
+
/**
|
|
52
|
+
* Value is required if another field is empty
|
|
53
|
+
*/
|
|
54
|
+
requiredIfEmpty(field: string, errorMessage?: string): this;
|
|
55
|
+
/**
|
|
56
|
+
* Value is required if another sibling field is empty
|
|
57
|
+
*/
|
|
58
|
+
requiredIfEmptySibling(field: string, errorMessage?: string): this;
|
|
59
|
+
/**
|
|
60
|
+
* Value is required if another field is not empty
|
|
61
|
+
*/
|
|
62
|
+
requiredIfNotEmpty(field: string, errorMessage?: string): this;
|
|
63
|
+
/**
|
|
64
|
+
* Value is required if another sibling field is not empty
|
|
65
|
+
*/
|
|
66
|
+
requiredIfNotEmptySibling(field: string, errorMessage?: string): this;
|
|
67
|
+
/**
|
|
68
|
+
* Value is required if ALL specified fields are empty
|
|
69
|
+
*/
|
|
70
|
+
requiredIfAllEmpty(fields: string[], errorMessage?: string): this;
|
|
71
|
+
/**
|
|
72
|
+
* Value is required if ALL specified sibling fields are empty
|
|
73
|
+
*/
|
|
74
|
+
requiredIfAllEmptySiblings(fields: string[], errorMessage?: string): this;
|
|
75
|
+
/**
|
|
76
|
+
* Value is required if ANY of the specified fields is empty
|
|
77
|
+
*/
|
|
78
|
+
requiredIfAnyEmpty(fields: string[], errorMessage?: string): this;
|
|
79
|
+
/**
|
|
80
|
+
* Value is required if ANY of the specified sibling fields is empty
|
|
81
|
+
*/
|
|
82
|
+
requiredIfAnyEmptySiblings(fields: string[], errorMessage?: string): this;
|
|
83
|
+
/**
|
|
84
|
+
* Value is required if ALL specified fields are NOT empty
|
|
85
|
+
*/
|
|
86
|
+
requiredIfAllNotEmpty(fields: string[], errorMessage?: string): this;
|
|
87
|
+
/**
|
|
88
|
+
* Value is required if ALL specified sibling fields are NOT empty
|
|
89
|
+
*/
|
|
90
|
+
requiredIfAllNotEmptySiblings(fields: string[], errorMessage?: string): this;
|
|
91
|
+
/**
|
|
92
|
+
* Value is required if ANY of the specified fields is NOT empty
|
|
93
|
+
*/
|
|
94
|
+
requiredIfAnyNotEmpty(fields: string[], errorMessage?: string): this;
|
|
95
|
+
/**
|
|
96
|
+
* Value is required if ANY of the specified sibling fields is NOT empty
|
|
97
|
+
*/
|
|
98
|
+
requiredIfAnyNotEmptySiblings(fields: string[], errorMessage?: string): this;
|
|
99
|
+
/**
|
|
100
|
+
* Value is required if another field's value is in the given array
|
|
101
|
+
*/
|
|
102
|
+
requiredIfIn(field: string, values: any[], errorMessage?: string): this;
|
|
103
|
+
/**
|
|
104
|
+
* Value is required if another sibling field's value is in the given array
|
|
105
|
+
*/
|
|
106
|
+
requiredIfInSibling(field: string, values: any[], errorMessage?: string): this;
|
|
107
|
+
/**
|
|
108
|
+
* Value is required if another field's value is NOT in the given array
|
|
109
|
+
*/
|
|
110
|
+
requiredIfNotIn(field: string, values: any[], errorMessage?: string): this;
|
|
111
|
+
/**
|
|
112
|
+
* Value is required if another sibling field's value is NOT in the given array
|
|
113
|
+
*/
|
|
114
|
+
requiredIfNotInSibling(field: string, values: any[], errorMessage?: string): this;
|
|
115
|
+
/**
|
|
116
|
+
* Value is required if all specified fields exist
|
|
117
|
+
*/
|
|
118
|
+
requiredWithAll(fields: string[], errorMessage?: string): this;
|
|
119
|
+
/**
|
|
120
|
+
* Value is required if all specified sibling fields exist
|
|
121
|
+
*/
|
|
122
|
+
requiredWithAllSiblings(fields: string[], errorMessage?: string): this;
|
|
123
|
+
/**
|
|
124
|
+
* Value is required if all specified fields are missing
|
|
125
|
+
*/
|
|
126
|
+
requiredWithoutAll(fields: string[], errorMessage?: string): this;
|
|
127
|
+
/**
|
|
128
|
+
* Value is required if all specified sibling fields are missing
|
|
129
|
+
*/
|
|
130
|
+
requiredWithoutAllSiblings(fields: string[], errorMessage?: string): this;
|
|
131
|
+
/**
|
|
132
|
+
* Value is required if any of the specified fields exists
|
|
133
|
+
*/
|
|
134
|
+
requiredWithAny(fields: string[], errorMessage?: string): this;
|
|
135
|
+
/**
|
|
136
|
+
* Value is required if any of the specified sibling fields exists
|
|
137
|
+
*/
|
|
138
|
+
requiredWithAnySiblings(fields: string[], errorMessage?: string): this;
|
|
139
|
+
/**
|
|
140
|
+
* Value is required if any of the specified fields is missing
|
|
141
|
+
*/
|
|
142
|
+
requiredWithoutAny(fields: string[], errorMessage?: string): this;
|
|
143
|
+
/**
|
|
144
|
+
* Value is required if any of the specified sibling fields is missing
|
|
145
|
+
*/
|
|
146
|
+
requiredWithoutAnySiblings(fields: string[], errorMessage?: string): this;
|
|
147
|
+
/**
|
|
148
|
+
* Make this field required based on a custom callback.
|
|
149
|
+
*
|
|
150
|
+
* The callback receives only the `SchemaContext` (not the value),
|
|
151
|
+
* because "required" is about surrounding conditions, not the field itself.
|
|
152
|
+
* Return `true` if the field should be required.
|
|
153
|
+
*
|
|
154
|
+
* @param callback - Receives SchemaContext, returns boolean
|
|
155
|
+
* @param errorMessage - Optional custom error message
|
|
156
|
+
*
|
|
157
|
+
* @example
|
|
158
|
+
* ```ts
|
|
159
|
+
* // Required when email notification is enabled
|
|
160
|
+
* v.string().requiredWhen((context) => {
|
|
161
|
+
* return context.allData.notificationMethod === 'email';
|
|
162
|
+
* })
|
|
163
|
+
*
|
|
164
|
+
* // Required based on multiple conditions
|
|
165
|
+
* v.string().requiredWhen((context) => {
|
|
166
|
+
* const { role, department } = context.allData;
|
|
167
|
+
* return role === 'manager' && department === 'finance';
|
|
168
|
+
* })
|
|
169
|
+
* ```
|
|
170
|
+
*/
|
|
171
|
+
requiredWhen(callback: (context: SchemaContext) => boolean | Promise<boolean>, errorMessage?: string): this;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
//# sourceMappingURL=required-methods.d.ts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AE,MAAM,GAAG,IAAI,CAAC;QAEvE;;WAEG;QACH,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAElE;;WAEG;QACH,0BAA0B,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAE1E;;;;;;;;;;;;;;;;;;;;;;;WAuBG;QACH,YAAY,CACV,QAAQ,EAAE,CAAC,OAAO,EAAE,aAAa,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,EAChE,YAAY,CAAC,EAAE,MAAM,GACpB,IAAI,CAAC;KACT;CACF"}
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
'use strict';var requiredIfRules=require('../../rules/conditional/required-if-rules.js'),requiredUnlessRules=require('../../rules/conditional/required-unless-rules.js'),requiredWhenRule=require('../../rules/conditional/required-when-rule.js'),requiredWithRules=require('../../rules/conditional/required-with-rules.js'),requiredWithoutRules=require('../../rules/conditional/required-without-rules.js'),required=require('../../rules/core/required.js'),baseValidator=require('../base-validator.js');// ==================== UNCONDITIONAL STATES ====================
|
|
2
|
+
/**
|
|
3
|
+
* This value must be present and has a value
|
|
4
|
+
*/
|
|
5
|
+
baseValidator.BaseValidator.prototype.required = function (errorMessage) {
|
|
6
|
+
return this.addRule(required.requiredRule, errorMessage);
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Value must be present but not necessarily has a value
|
|
10
|
+
*/
|
|
11
|
+
baseValidator.BaseValidator.prototype.present = function (errorMessage) {
|
|
12
|
+
return this.setRequiredRule(required.presentRule, errorMessage);
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Mark the field as optional — it may be absent or empty without validation errors.
|
|
16
|
+
* Clears any previously set required rule.
|
|
17
|
+
*
|
|
18
|
+
* The return type is branded with `{ isOptional: true }` so schema inference
|
|
19
|
+
* can mark this key as optional in the inferred TypeScript type.
|
|
20
|
+
*/
|
|
21
|
+
baseValidator.BaseValidator.prototype.optional = function () {
|
|
22
|
+
const instance = this.instance;
|
|
23
|
+
instance.isOptional = true;
|
|
24
|
+
instance.requiredRule = null;
|
|
25
|
+
return instance;
|
|
26
|
+
};
|
|
27
|
+
// ==================== REQUIRED: BASED ON FIELD PRESENCE ====================
|
|
28
|
+
/**
|
|
29
|
+
* Value is required if another field exists
|
|
30
|
+
*/
|
|
31
|
+
baseValidator.BaseValidator.prototype.requiredWith = function (field, errorMessage) {
|
|
32
|
+
return this.setRequiredRule(requiredWithRules.requiredWithRule, errorMessage, { field, scope: "global" });
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Value is required if another sibling field exists
|
|
36
|
+
*/
|
|
37
|
+
baseValidator.BaseValidator.prototype.requiredWithSibling = function (field, errorMessage) {
|
|
38
|
+
return this.setRequiredRule(requiredWithRules.requiredWithRule, errorMessage, { field, scope: "sibling" });
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Value is required if another field is missing
|
|
42
|
+
*/
|
|
43
|
+
baseValidator.BaseValidator.prototype.requiredWithout = function (field, errorMessage) {
|
|
44
|
+
return this.setRequiredRule(requiredWithoutRules.requiredWithoutRule, errorMessage, { field, scope: "global" });
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Value is required if another sibling field is missing
|
|
48
|
+
*/
|
|
49
|
+
baseValidator.BaseValidator.prototype.requiredWithoutSibling = function (field, errorMessage) {
|
|
50
|
+
return this.setRequiredRule(requiredWithoutRules.requiredWithoutRule, errorMessage, { field, scope: "sibling" });
|
|
51
|
+
};
|
|
52
|
+
// ==================== REQUIRED: BASED ON FIELD VALUE ====================
|
|
53
|
+
/**
|
|
54
|
+
* Value is required if another field equals a specific value
|
|
55
|
+
*/
|
|
56
|
+
baseValidator.BaseValidator.prototype.requiredIf = function (field, value, errorMessage) {
|
|
57
|
+
return this.setRequiredRule(requiredIfRules.requiredIfRule, errorMessage, { field, value, scope: "global" });
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Value is required if another sibling field equals a specific value
|
|
61
|
+
*/
|
|
62
|
+
baseValidator.BaseValidator.prototype.requiredIfSibling = function (field, value, errorMessage) {
|
|
63
|
+
return this.setRequiredRule(requiredIfRules.requiredIfRule, errorMessage, { field, value, scope: "sibling" });
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Value is required unless another field equals a specific value
|
|
67
|
+
*/
|
|
68
|
+
baseValidator.BaseValidator.prototype.requiredUnless = function (field, value, errorMessage) {
|
|
69
|
+
return this.setRequiredRule(requiredUnlessRules.requiredUnlessRule, errorMessage, { field, value, scope: "global" });
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Value is required unless another sibling field equals a specific value
|
|
73
|
+
*/
|
|
74
|
+
baseValidator.BaseValidator.prototype.requiredUnlessSibling = function (field, value, errorMessage) {
|
|
75
|
+
return this.setRequiredRule(requiredUnlessRules.requiredUnlessRule, errorMessage, { field, value, scope: "sibling" });
|
|
76
|
+
};
|
|
77
|
+
// ==================== REQUIRED: BASED ON FIELD EMPTY STATE ====================
|
|
78
|
+
/**
|
|
79
|
+
* Value is required if another field is empty
|
|
80
|
+
*/
|
|
81
|
+
baseValidator.BaseValidator.prototype.requiredIfEmpty = function (field, errorMessage) {
|
|
82
|
+
return this.setRequiredRule(requiredIfRules.requiredIfEmptyRule, errorMessage, { field, scope: "global" });
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* Value is required if another sibling field is empty
|
|
86
|
+
*/
|
|
87
|
+
baseValidator.BaseValidator.prototype.requiredIfEmptySibling = function (field, errorMessage) {
|
|
88
|
+
return this.setRequiredRule(requiredIfRules.requiredIfEmptyRule, errorMessage, { field, scope: "sibling" });
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Value is required if another field is not empty
|
|
92
|
+
*/
|
|
93
|
+
baseValidator.BaseValidator.prototype.requiredIfNotEmpty = function (field, errorMessage) {
|
|
94
|
+
return this.setRequiredRule(requiredIfRules.requiredIfNotEmptyRule, errorMessage, { field, scope: "global" });
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* Value is required if another sibling field is not empty
|
|
98
|
+
*/
|
|
99
|
+
baseValidator.BaseValidator.prototype.requiredIfNotEmptySibling = function (field, errorMessage) {
|
|
100
|
+
return this.setRequiredRule(requiredIfRules.requiredIfNotEmptyRule, errorMessage, { field, scope: "sibling" });
|
|
101
|
+
};
|
|
102
|
+
// ==================== REQUIRED: BASED ON MULTIPLE FIELDS EMPTY STATE ====================
|
|
103
|
+
/**
|
|
104
|
+
* Value is required if ALL specified fields are empty
|
|
105
|
+
*/
|
|
106
|
+
baseValidator.BaseValidator.prototype.requiredIfAllEmpty = function (fields, errorMessage) {
|
|
107
|
+
return this.setRequiredRule(requiredIfRules.requiredIfAllEmptyRule, errorMessage, { fields, scope: "global" });
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* Value is required if ALL specified sibling fields are empty
|
|
111
|
+
*/
|
|
112
|
+
baseValidator.BaseValidator.prototype.requiredIfAllEmptySiblings = function (fields, errorMessage) {
|
|
113
|
+
return this.setRequiredRule(requiredIfRules.requiredIfAllEmptyRule, errorMessage, { fields, scope: "sibling" });
|
|
114
|
+
};
|
|
115
|
+
/**
|
|
116
|
+
* Value is required if ANY of the specified fields is empty
|
|
117
|
+
*/
|
|
118
|
+
baseValidator.BaseValidator.prototype.requiredIfAnyEmpty = function (fields, errorMessage) {
|
|
119
|
+
return this.setRequiredRule(requiredIfRules.requiredIfAnyEmptyRule, errorMessage, { fields, scope: "global" });
|
|
120
|
+
};
|
|
121
|
+
/**
|
|
122
|
+
* Value is required if ANY of the specified sibling fields is empty
|
|
123
|
+
*/
|
|
124
|
+
baseValidator.BaseValidator.prototype.requiredIfAnyEmptySiblings = function (fields, errorMessage) {
|
|
125
|
+
return this.setRequiredRule(requiredIfRules.requiredIfAnyEmptyRule, errorMessage, { fields, scope: "sibling" });
|
|
126
|
+
};
|
|
127
|
+
/**
|
|
128
|
+
* Value is required if ALL specified fields are NOT empty
|
|
129
|
+
*/
|
|
130
|
+
baseValidator.BaseValidator.prototype.requiredIfAllNotEmpty = function (fields, errorMessage) {
|
|
131
|
+
return this.setRequiredRule(requiredIfRules.requiredIfAllNotEmptyRule, errorMessage, { fields, scope: "global" });
|
|
132
|
+
};
|
|
133
|
+
/**
|
|
134
|
+
* Value is required if ALL specified sibling fields are NOT empty
|
|
135
|
+
*/
|
|
136
|
+
baseValidator.BaseValidator.prototype.requiredIfAllNotEmptySiblings = function (fields, errorMessage) {
|
|
137
|
+
return this.setRequiredRule(requiredIfRules.requiredIfAllNotEmptyRule, errorMessage, {
|
|
138
|
+
fields,
|
|
139
|
+
scope: "sibling",
|
|
140
|
+
});
|
|
141
|
+
};
|
|
142
|
+
/**
|
|
143
|
+
* Value is required if ANY of the specified fields is NOT empty
|
|
144
|
+
*/
|
|
145
|
+
baseValidator.BaseValidator.prototype.requiredIfAnyNotEmpty = function (fields, errorMessage) {
|
|
146
|
+
return this.setRequiredRule(requiredIfRules.requiredIfAnyNotEmptyRule, errorMessage, { fields, scope: "global" });
|
|
147
|
+
};
|
|
148
|
+
/**
|
|
149
|
+
* Value is required if ANY of the specified sibling fields is NOT empty
|
|
150
|
+
*/
|
|
151
|
+
baseValidator.BaseValidator.prototype.requiredIfAnyNotEmptySiblings = function (fields, errorMessage) {
|
|
152
|
+
return this.setRequiredRule(requiredIfRules.requiredIfAnyNotEmptyRule, errorMessage, {
|
|
153
|
+
fields,
|
|
154
|
+
scope: "sibling",
|
|
155
|
+
});
|
|
156
|
+
};
|
|
157
|
+
/**
|
|
158
|
+
* Value is required if another field's value is in the given array
|
|
159
|
+
*/
|
|
160
|
+
baseValidator.BaseValidator.prototype.requiredIfIn = function (field, values, errorMessage) {
|
|
161
|
+
return this.setRequiredRule(requiredIfRules.requiredIfInRule, errorMessage, { field, values, scope: "global" });
|
|
162
|
+
};
|
|
163
|
+
/**
|
|
164
|
+
* Value is required if another sibling field's value is in the given array
|
|
165
|
+
*/
|
|
166
|
+
baseValidator.BaseValidator.prototype.requiredIfInSibling = function (field, values, errorMessage) {
|
|
167
|
+
return this.setRequiredRule(requiredIfRules.requiredIfInRule, errorMessage, { field, values, scope: "sibling" });
|
|
168
|
+
};
|
|
169
|
+
/**
|
|
170
|
+
* Value is required if another field's value is NOT in the given array
|
|
171
|
+
*/
|
|
172
|
+
baseValidator.BaseValidator.prototype.requiredIfNotIn = function (field, values, errorMessage) {
|
|
173
|
+
return this.setRequiredRule(requiredIfRules.requiredIfNotInRule, errorMessage, {
|
|
174
|
+
field,
|
|
175
|
+
values,
|
|
176
|
+
scope: "global",
|
|
177
|
+
});
|
|
178
|
+
};
|
|
179
|
+
/**
|
|
180
|
+
* Value is required if another sibling field's value is NOT in the given array
|
|
181
|
+
*/
|
|
182
|
+
baseValidator.BaseValidator.prototype.requiredIfNotInSibling = function (field, values, errorMessage) {
|
|
183
|
+
return this.setRequiredRule(requiredIfRules.requiredIfNotInRule, errorMessage, {
|
|
184
|
+
field,
|
|
185
|
+
values,
|
|
186
|
+
scope: "sibling",
|
|
187
|
+
});
|
|
188
|
+
};
|
|
189
|
+
// ==================== REQUIRED: BASED ON MULTIPLE FIELDS (ALL) ====================
|
|
190
|
+
/**
|
|
191
|
+
* Value is required if all specified fields exist
|
|
192
|
+
*/
|
|
193
|
+
baseValidator.BaseValidator.prototype.requiredWithAll = function (fields, errorMessage) {
|
|
194
|
+
return this.setRequiredRule(requiredWithRules.requiredWithAllRule, errorMessage, { fields, scope: "global" });
|
|
195
|
+
};
|
|
196
|
+
/**
|
|
197
|
+
* Value is required if all specified sibling fields exist
|
|
198
|
+
*/
|
|
199
|
+
baseValidator.BaseValidator.prototype.requiredWithAllSiblings = function (fields, errorMessage) {
|
|
200
|
+
return this.setRequiredRule(requiredWithRules.requiredWithAllRule, errorMessage, { fields, scope: "sibling" });
|
|
201
|
+
};
|
|
202
|
+
/**
|
|
203
|
+
* Value is required if all specified fields are missing
|
|
204
|
+
*/
|
|
205
|
+
baseValidator.BaseValidator.prototype.requiredWithoutAll = function (fields, errorMessage) {
|
|
206
|
+
return this.setRequiredRule(requiredWithoutRules.requiredWithoutAllRule, errorMessage, { fields, scope: "global" });
|
|
207
|
+
};
|
|
208
|
+
/**
|
|
209
|
+
* Value is required if all specified sibling fields are missing
|
|
210
|
+
*/
|
|
211
|
+
baseValidator.BaseValidator.prototype.requiredWithoutAllSiblings = function (fields, errorMessage) {
|
|
212
|
+
return this.setRequiredRule(requiredWithoutRules.requiredWithoutAllRule, errorMessage, { fields, scope: "sibling" });
|
|
213
|
+
};
|
|
214
|
+
// ==================== REQUIRED: BASED ON MULTIPLE FIELDS (ANY) ====================
|
|
215
|
+
/**
|
|
216
|
+
* Value is required if any of the specified fields exists
|
|
217
|
+
*/
|
|
218
|
+
baseValidator.BaseValidator.prototype.requiredWithAny = function (fields, errorMessage) {
|
|
219
|
+
return this.setRequiredRule(requiredWithRules.requiredWithAnyRule, errorMessage, { fields, scope: "global" });
|
|
220
|
+
};
|
|
221
|
+
/**
|
|
222
|
+
* Value is required if any of the specified sibling fields exists
|
|
223
|
+
*/
|
|
224
|
+
baseValidator.BaseValidator.prototype.requiredWithAnySiblings = function (fields, errorMessage) {
|
|
225
|
+
return this.setRequiredRule(requiredWithRules.requiredWithAnyRule, errorMessage, { fields, scope: "sibling" });
|
|
226
|
+
};
|
|
227
|
+
/**
|
|
228
|
+
* Value is required if any of the specified fields is missing
|
|
229
|
+
*/
|
|
230
|
+
baseValidator.BaseValidator.prototype.requiredWithoutAny = function (fields, errorMessage) {
|
|
231
|
+
return this.setRequiredRule(requiredWithoutRules.requiredWithoutAnyRule, errorMessage, { fields, scope: "global" });
|
|
232
|
+
};
|
|
233
|
+
/**
|
|
234
|
+
* Value is required if any of the specified sibling fields is missing
|
|
235
|
+
*/
|
|
236
|
+
baseValidator.BaseValidator.prototype.requiredWithoutAnySiblings = function (fields, errorMessage) {
|
|
237
|
+
return this.setRequiredRule(requiredWithoutRules.requiredWithoutAnyRule, errorMessage, { fields, scope: "sibling" });
|
|
238
|
+
};
|
|
239
|
+
// ==================== REQUIRED: BASED ON CUSTOM CALLBACK ====================
|
|
240
|
+
/**
|
|
241
|
+
* Make this field required based on a custom callback.
|
|
242
|
+
* Callback receives only SchemaContext — the framework handles empty-value checking.
|
|
243
|
+
*/
|
|
244
|
+
baseValidator.BaseValidator.prototype.requiredWhen = function (callback, errorMessage) {
|
|
245
|
+
return this.setRequiredRule(requiredWhenRule.requiredWhenRule, errorMessage, { callback });
|
|
246
|
+
};//# sourceMappingURL=required-methods.js.map
|