@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
|
@@ -4,8 +4,8 @@ import dayjs from'dayjs';import'@mongez/reinforcements';import'@mongez/supportiv
|
|
|
4
4
|
class DateValidator extends BaseValidator {
|
|
5
5
|
constructor(errorMessage) {
|
|
6
6
|
super();
|
|
7
|
-
this.
|
|
8
|
-
this.
|
|
7
|
+
this.addMutableMutator(dateMutator); // Normalize to Date object first
|
|
8
|
+
this.addMutableRule(dateRule, errorMessage);
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
11
|
* Check if value is a Date type
|
|
@@ -20,30 +20,25 @@ class DateValidator extends BaseValidator {
|
|
|
20
20
|
* @category transformer
|
|
21
21
|
*/
|
|
22
22
|
toISOString() {
|
|
23
|
-
this.addTransformer(data => data instanceof Date ? data.toISOString() : data);
|
|
24
|
-
return this;
|
|
23
|
+
return this.addTransformer((data) => (data instanceof Date ? data.toISOString() : data));
|
|
25
24
|
}
|
|
26
25
|
/** Convert date to Unix timestamp (milliseconds) */
|
|
27
26
|
toTimestamp() {
|
|
28
|
-
this.addTransformer(data => (data instanceof Date ? data.getTime() : data));
|
|
29
|
-
return this;
|
|
27
|
+
return this.addTransformer((data) => (data instanceof Date ? data.getTime() : data));
|
|
30
28
|
}
|
|
31
29
|
// ==================== String Format Transformers ====================
|
|
32
30
|
// These convert Date to formatted strings after validation
|
|
33
31
|
/** Convert date to specific format using dayjs */
|
|
34
32
|
toFormat(format) {
|
|
35
|
-
this.addTransformer((data, { options }) => data instanceof Date ? dayjs(data).format(options.format) : data, { format });
|
|
36
|
-
return this;
|
|
33
|
+
return this.addTransformer((data, { options }) => (data instanceof Date ? dayjs(data).format(options.format) : data), { format });
|
|
37
34
|
}
|
|
38
35
|
/** Convert to date only (remove time, returns YYYY-MM-DD) */
|
|
39
36
|
toDateOnly() {
|
|
40
|
-
this.addTransformer(data => data instanceof Date ? dayjs(data).format("YYYY-MM-DD") : data);
|
|
41
|
-
return this;
|
|
37
|
+
return this.addTransformer((data) => data instanceof Date ? dayjs(data).format("YYYY-MM-DD") : data);
|
|
42
38
|
}
|
|
43
39
|
/** Convert to time only (returns HH:MM:SS) */
|
|
44
40
|
toTimeOnly() {
|
|
45
|
-
this.addTransformer(data => data instanceof Date ? dayjs(data).format("HH:mm:ss") : data);
|
|
46
|
-
return this;
|
|
41
|
+
return this.addTransformer((data) => data instanceof Date ? dayjs(data).format("HH:mm:ss") : data);
|
|
47
42
|
}
|
|
48
43
|
// ==================== Date Mutators ====================
|
|
49
44
|
// These modify the Date object before validation
|
|
@@ -52,59 +47,48 @@ class DateValidator extends BaseValidator {
|
|
|
52
47
|
* @category mutator
|
|
53
48
|
*/
|
|
54
49
|
toStartOfDay() {
|
|
55
|
-
this.addMutator(toStartOfDayMutator);
|
|
56
|
-
return this;
|
|
50
|
+
return this.addMutator(toStartOfDayMutator);
|
|
57
51
|
}
|
|
58
52
|
/** Convert date to end of day (23:59:59.999) */
|
|
59
53
|
toEndOfDay() {
|
|
60
|
-
this.addMutator(toEndOfDayMutator);
|
|
61
|
-
return this;
|
|
54
|
+
return this.addMutator(toEndOfDayMutator);
|
|
62
55
|
}
|
|
63
56
|
/** Add or subtract days from date */
|
|
64
57
|
addDays(days) {
|
|
65
|
-
this.addMutator(addDaysMutator, { days });
|
|
66
|
-
return this;
|
|
58
|
+
return this.addMutator(addDaysMutator, { days });
|
|
67
59
|
}
|
|
68
60
|
/** Add or subtract months from date */
|
|
69
61
|
addMonths(months) {
|
|
70
|
-
this.addMutator(addMonthsMutator, { months });
|
|
71
|
-
return this;
|
|
62
|
+
return this.addMutator(addMonthsMutator, { months });
|
|
72
63
|
}
|
|
73
64
|
/** Add or subtract years from date */
|
|
74
65
|
addYears(years) {
|
|
75
|
-
this.addMutator(addYearsMutator, { years });
|
|
76
|
-
return this;
|
|
66
|
+
return this.addMutator(addYearsMutator, { years });
|
|
77
67
|
}
|
|
78
68
|
/** Add or subtract hours from date */
|
|
79
69
|
addHours(hours) {
|
|
80
|
-
this.addMutator(addHoursMutator, { hours });
|
|
81
|
-
return this;
|
|
70
|
+
return this.addMutator(addHoursMutator, { hours });
|
|
82
71
|
}
|
|
83
72
|
/** Convert date to UTC */
|
|
84
73
|
toUTC() {
|
|
85
|
-
this.addMutator(toUTCMutator);
|
|
86
|
-
return this;
|
|
74
|
+
return this.addMutator(toUTCMutator);
|
|
87
75
|
}
|
|
88
76
|
// ==================== Date Range Mutators ====================
|
|
89
77
|
/** Set to start of month */
|
|
90
78
|
toStartOfMonth() {
|
|
91
|
-
this.addMutator(toStartOfMonthMutator);
|
|
92
|
-
return this;
|
|
79
|
+
return this.addMutator(toStartOfMonthMutator);
|
|
93
80
|
}
|
|
94
81
|
/** Set to end of month */
|
|
95
82
|
toEndOfMonth() {
|
|
96
|
-
this.addMutator(toEndOfMonthMutator);
|
|
97
|
-
return this;
|
|
83
|
+
return this.addMutator(toEndOfMonthMutator);
|
|
98
84
|
}
|
|
99
85
|
/** Set to start of year */
|
|
100
86
|
toStartOfYear() {
|
|
101
|
-
this.addMutator(toStartOfYearMutator);
|
|
102
|
-
return this;
|
|
87
|
+
return this.addMutator(toStartOfYearMutator);
|
|
103
88
|
}
|
|
104
89
|
/** Set to end of year */
|
|
105
90
|
toEndOfYear() {
|
|
106
|
-
this.addMutator(toEndOfYearMutator);
|
|
107
|
-
return this;
|
|
91
|
+
return this.addMutator(toEndOfYearMutator);
|
|
108
92
|
}
|
|
109
93
|
// ==================== Date Comparison ====================
|
|
110
94
|
/**
|
|
@@ -130,10 +114,10 @@ class DateValidator extends BaseValidator {
|
|
|
130
114
|
* @category Validation Rule
|
|
131
115
|
*/
|
|
132
116
|
min(dateOrField, errorMessage) {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
117
|
+
return this.addRule(minDateRule, errorMessage, {
|
|
118
|
+
dateOrField,
|
|
119
|
+
scope: "global",
|
|
120
|
+
});
|
|
137
121
|
}
|
|
138
122
|
/**
|
|
139
123
|
* Date must be less than or equal to the given date or field (inclusive)
|
|
@@ -145,10 +129,10 @@ class DateValidator extends BaseValidator {
|
|
|
145
129
|
* @category Validation Rule
|
|
146
130
|
*/
|
|
147
131
|
max(dateOrField, errorMessage) {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
132
|
+
return this.addRule(maxDateRule, errorMessage, {
|
|
133
|
+
dateOrField,
|
|
134
|
+
scope: "global",
|
|
135
|
+
});
|
|
152
136
|
}
|
|
153
137
|
/**
|
|
154
138
|
* Date must be strictly less than the given date or field (exclusive)
|
|
@@ -160,10 +144,10 @@ class DateValidator extends BaseValidator {
|
|
|
160
144
|
* @category Validation Rule
|
|
161
145
|
*/
|
|
162
146
|
before(dateOrField, errorMessage) {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
147
|
+
return this.addRule(beforeFieldRule, errorMessage, {
|
|
148
|
+
dateOrField,
|
|
149
|
+
scope: "global",
|
|
150
|
+
});
|
|
167
151
|
}
|
|
168
152
|
/**
|
|
169
153
|
* Date must be strictly greater than the given date or field (exclusive)
|
|
@@ -175,47 +159,38 @@ class DateValidator extends BaseValidator {
|
|
|
175
159
|
* @category Validation Rule
|
|
176
160
|
*/
|
|
177
161
|
after(dateOrField, errorMessage) {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
162
|
+
return this.addRule(afterFieldRule, errorMessage, {
|
|
163
|
+
dateOrField,
|
|
164
|
+
scope: "global",
|
|
165
|
+
});
|
|
182
166
|
}
|
|
183
167
|
/** Date must be between start and end dates */
|
|
184
168
|
between(startDate, endDate, errorMessage) {
|
|
185
|
-
|
|
186
|
-
rule.context.options.startDate = startDate;
|
|
187
|
-
rule.context.options.endDate = endDate;
|
|
188
|
-
return this;
|
|
169
|
+
return this.addRule(betweenDatesRule, errorMessage, { startDate, endDate });
|
|
189
170
|
}
|
|
190
171
|
/** Date must be exactly today */
|
|
191
172
|
today(errorMessage) {
|
|
192
|
-
this.addRule(todayRule, errorMessage);
|
|
193
|
-
return this;
|
|
173
|
+
return this.addRule(todayRule, errorMessage);
|
|
194
174
|
}
|
|
195
175
|
/** Date must be today or in the future */
|
|
196
176
|
fromToday(errorMessage) {
|
|
197
|
-
this.addRule(fromTodayRule, errorMessage);
|
|
198
|
-
return this;
|
|
177
|
+
return this.addRule(fromTodayRule, errorMessage);
|
|
199
178
|
}
|
|
200
179
|
/** Date must be before today */
|
|
201
180
|
beforeToday(errorMessage) {
|
|
202
|
-
this.addRule(beforeTodayRule, errorMessage);
|
|
203
|
-
return this;
|
|
181
|
+
return this.addRule(beforeTodayRule, errorMessage);
|
|
204
182
|
}
|
|
205
183
|
/** Date must be after today (not including today) */
|
|
206
184
|
afterToday(errorMessage) {
|
|
207
|
-
this.addRule(afterTodayRule, errorMessage);
|
|
208
|
-
return this;
|
|
185
|
+
return this.addRule(afterTodayRule, errorMessage);
|
|
209
186
|
}
|
|
210
187
|
/** Date must be in the past */
|
|
211
188
|
past(errorMessage) {
|
|
212
|
-
this.addRule(pastRule, errorMessage);
|
|
213
|
-
return this;
|
|
189
|
+
return this.addRule(pastRule, errorMessage);
|
|
214
190
|
}
|
|
215
191
|
/** Date must be in the future */
|
|
216
192
|
future(errorMessage) {
|
|
217
|
-
this.addRule(futureRule, errorMessage);
|
|
218
|
-
return this;
|
|
193
|
+
return this.addRule(futureRule, errorMessage);
|
|
219
194
|
}
|
|
220
195
|
// ==================== Sibling Field Comparison ====================
|
|
221
196
|
// Explicit sibling scope methods
|
|
@@ -224,187 +199,146 @@ class DateValidator extends BaseValidator {
|
|
|
224
199
|
* @category Validation Rule
|
|
225
200
|
*/
|
|
226
201
|
minSibling(field, errorMessage) {
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
202
|
+
return this.addRule(minDateRule, errorMessage, {
|
|
203
|
+
dateOrField: field,
|
|
204
|
+
scope: "sibling",
|
|
205
|
+
});
|
|
231
206
|
}
|
|
232
207
|
/**
|
|
233
208
|
* Date must be <= sibling field value (inclusive)
|
|
234
209
|
* @category Validation Rule
|
|
235
210
|
*/
|
|
236
211
|
maxSibling(field, errorMessage) {
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
212
|
+
return this.addRule(maxDateRule, errorMessage, {
|
|
213
|
+
dateOrField: field,
|
|
214
|
+
scope: "sibling",
|
|
215
|
+
});
|
|
241
216
|
}
|
|
242
217
|
/**
|
|
243
218
|
* Date must be < sibling field value (exclusive)
|
|
244
219
|
* @category Validation Rule
|
|
245
220
|
*/
|
|
246
221
|
beforeSibling(field, errorMessage) {
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
222
|
+
return this.addRule(beforeFieldRule, errorMessage, {
|
|
223
|
+
dateOrField: field,
|
|
224
|
+
scope: "sibling",
|
|
225
|
+
});
|
|
251
226
|
}
|
|
252
227
|
/**
|
|
253
228
|
* Date must be > sibling field value (exclusive)
|
|
254
229
|
* @category Validation Rule
|
|
255
230
|
*/
|
|
256
231
|
afterSibling(field, errorMessage) {
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
232
|
+
return this.addRule(afterFieldRule, errorMessage, {
|
|
233
|
+
dateOrField: field,
|
|
234
|
+
scope: "sibling",
|
|
235
|
+
});
|
|
261
236
|
}
|
|
262
237
|
/** Date must be the same as another field's date */
|
|
263
238
|
sameAsField(field, errorMessage) {
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
239
|
+
return this.addRule(sameAsFieldDateRule, errorMessage, {
|
|
240
|
+
field,
|
|
241
|
+
scope: "global",
|
|
242
|
+
});
|
|
268
243
|
}
|
|
269
244
|
/** Date must be the same as another sibling field's date */
|
|
270
245
|
sameAsFieldSibling(field, errorMessage) {
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
246
|
+
return this.addRule(sameAsFieldDateRule, errorMessage, {
|
|
247
|
+
field,
|
|
248
|
+
scope: "sibling",
|
|
249
|
+
});
|
|
275
250
|
}
|
|
276
251
|
// ==================== Time Validation ====================
|
|
277
252
|
/** Time must be from specific hour onwards (0-23) */
|
|
278
253
|
fromHour(hour, errorMessage) {
|
|
279
|
-
|
|
280
|
-
rule.context.options.hour = hour;
|
|
281
|
-
return this;
|
|
254
|
+
return this.addRule(fromHourRule, errorMessage, { hour });
|
|
282
255
|
}
|
|
283
256
|
/** Time must be before specific hour (0-23) */
|
|
284
257
|
beforeHour(hour, errorMessage) {
|
|
285
|
-
|
|
286
|
-
rule.context.options.hour = hour;
|
|
287
|
-
return this;
|
|
258
|
+
return this.addRule(beforeHourRule, errorMessage, { hour });
|
|
288
259
|
}
|
|
289
260
|
/** Time must be between start and end hours (0-23) */
|
|
290
261
|
betweenHours(startHour, endHour, errorMessage) {
|
|
291
|
-
|
|
292
|
-
rule.context.options.startHour = startHour;
|
|
293
|
-
rule.context.options.endHour = endHour;
|
|
294
|
-
return this;
|
|
262
|
+
return this.addRule(betweenHoursRule, errorMessage, { startHour, endHour });
|
|
295
263
|
}
|
|
296
264
|
/** Time must be from specific minute onwards (0-59) */
|
|
297
265
|
fromMinute(minute, errorMessage) {
|
|
298
|
-
|
|
299
|
-
rule.context.options.minute = minute;
|
|
300
|
-
return this;
|
|
266
|
+
return this.addRule(fromMinuteRule, errorMessage, { minute });
|
|
301
267
|
}
|
|
302
268
|
/** Time must be before specific minute (0-59) */
|
|
303
269
|
beforeMinute(minute, errorMessage) {
|
|
304
|
-
|
|
305
|
-
rule.context.options.minute = minute;
|
|
306
|
-
return this;
|
|
270
|
+
return this.addRule(beforeMinuteRule, errorMessage, { minute });
|
|
307
271
|
}
|
|
308
272
|
/** Time must be between start and end minutes (0-59) */
|
|
309
273
|
betweenMinutes(startMinute, endMinute, errorMessage) {
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
274
|
+
return this.addRule(betweenMinutesRule, errorMessage, {
|
|
275
|
+
startMinute,
|
|
276
|
+
endMinute,
|
|
277
|
+
});
|
|
314
278
|
}
|
|
315
279
|
/** Time must be between start and end times (HH:MM format) */
|
|
316
280
|
betweenTimes(startTime, endTime, errorMessage) {
|
|
317
|
-
|
|
318
|
-
rule.context.options.startTime = startTime;
|
|
319
|
-
rule.context.options.endTime = endTime;
|
|
320
|
-
return this;
|
|
281
|
+
return this.addRule(betweenTimesRule, errorMessage, { startTime, endTime });
|
|
321
282
|
}
|
|
322
283
|
// ==================== Age Validation ====================
|
|
323
284
|
/** Age must be exactly the given years */
|
|
324
285
|
age(years, errorMessage) {
|
|
325
|
-
|
|
326
|
-
rule.context.options.years = years;
|
|
327
|
-
return this;
|
|
286
|
+
return this.addRule(ageRule, errorMessage, { years });
|
|
328
287
|
}
|
|
329
288
|
/** Minimum age requirement */
|
|
330
289
|
minAge(years, errorMessage) {
|
|
331
|
-
|
|
332
|
-
rule.context.options.years = years;
|
|
333
|
-
return this;
|
|
290
|
+
return this.addRule(minAgeRule, errorMessage, { years });
|
|
334
291
|
}
|
|
335
292
|
/** Maximum age requirement */
|
|
336
293
|
maxAge(years, errorMessage) {
|
|
337
|
-
|
|
338
|
-
rule.context.options.years = years;
|
|
339
|
-
return this;
|
|
294
|
+
return this.addRule(maxAgeRule, errorMessage, { years });
|
|
340
295
|
}
|
|
341
296
|
/** Age must be between min and max years */
|
|
342
297
|
betweenAge(minAge, maxAge, errorMessage) {
|
|
343
|
-
|
|
344
|
-
rule.context.options.minAge = minAge;
|
|
345
|
-
rule.context.options.maxAge = maxAge;
|
|
346
|
-
return this;
|
|
298
|
+
return this.addRule(betweenAgeRule, errorMessage, { minAge, maxAge });
|
|
347
299
|
}
|
|
348
300
|
// ==================== Day Validation ====================
|
|
349
301
|
/** Date must be specific weekday */
|
|
350
302
|
weekDay(day, errorMessage) {
|
|
351
|
-
|
|
352
|
-
rule.context.options.day = day;
|
|
353
|
-
return this;
|
|
303
|
+
return this.addRule(weekDayRule, errorMessage, { day });
|
|
354
304
|
}
|
|
355
305
|
/** Date must be one of specified weekdays */
|
|
356
306
|
weekdays(days, errorMessage) {
|
|
357
|
-
|
|
358
|
-
rule.context.options.days = days;
|
|
359
|
-
return this;
|
|
307
|
+
return this.addRule(weekdaysRule, errorMessage, { days });
|
|
360
308
|
}
|
|
361
309
|
/** Date must be a weekend (Saturday or Sunday) */
|
|
362
310
|
weekend(errorMessage) {
|
|
363
|
-
this.addRule(weekendRule, errorMessage);
|
|
364
|
-
return this;
|
|
311
|
+
return this.addRule(weekendRule, errorMessage);
|
|
365
312
|
}
|
|
366
313
|
/** Date must be a business day (Monday-Friday) */
|
|
367
314
|
businessDay(errorMessage) {
|
|
368
|
-
this.addRule(businessDayRule, errorMessage);
|
|
369
|
-
return this;
|
|
315
|
+
return this.addRule(businessDayRule, errorMessage);
|
|
370
316
|
}
|
|
371
317
|
/** Date must match specific format */
|
|
372
318
|
format(format, errorMessage) {
|
|
373
|
-
|
|
374
|
-
rule.context.options.format = format;
|
|
375
|
-
return this;
|
|
319
|
+
return this.addRule(dateRule, errorMessage, { format });
|
|
376
320
|
}
|
|
377
321
|
// ==================== Relative Date Validation ====================
|
|
378
322
|
/** Date must be within X days from now (past or future) */
|
|
379
323
|
withinDays(days, errorMessage) {
|
|
380
|
-
|
|
381
|
-
rule.context.options.days = days;
|
|
382
|
-
return this;
|
|
324
|
+
return this.addRule(withinDaysRule, errorMessage, { days });
|
|
383
325
|
}
|
|
384
326
|
/** Date must be within X days in the past */
|
|
385
327
|
withinPastDays(days, errorMessage) {
|
|
386
|
-
|
|
387
|
-
rule.context.options.days = days;
|
|
388
|
-
return this;
|
|
328
|
+
return this.addRule(withinPastDaysRule, errorMessage, { days });
|
|
389
329
|
}
|
|
390
330
|
/** Date must be within X days in the future */
|
|
391
331
|
withinFutureDays(days, errorMessage) {
|
|
392
|
-
|
|
393
|
-
rule.context.options.days = days;
|
|
394
|
-
return this;
|
|
332
|
+
return this.addRule(withinFutureDaysRule, errorMessage, { days });
|
|
395
333
|
}
|
|
396
334
|
// ==================== Period Validation ====================
|
|
397
335
|
/** Date must be in specific month (1-12) */
|
|
398
336
|
month(month, errorMessage) {
|
|
399
|
-
|
|
400
|
-
rule.context.options.month = month;
|
|
401
|
-
return this;
|
|
337
|
+
return this.addRule(monthRule, errorMessage, { month });
|
|
402
338
|
}
|
|
403
339
|
/** Date must be in specific year */
|
|
404
340
|
year(year, errorMessage) {
|
|
405
|
-
|
|
406
|
-
rule.context.options.year = year;
|
|
407
|
-
return this;
|
|
341
|
+
return this.addRule(yearRule, errorMessage, { year });
|
|
408
342
|
}
|
|
409
343
|
/**
|
|
410
344
|
* Date must be between start and end years
|
|
@@ -413,11 +347,11 @@ class DateValidator extends BaseValidator {
|
|
|
413
347
|
* @category Validation Rule
|
|
414
348
|
*/
|
|
415
349
|
betweenYears(startYear, endYear, errorMessage) {
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
350
|
+
return this.addRule(betweenYearsRule, errorMessage, {
|
|
351
|
+
startYear,
|
|
352
|
+
endYear,
|
|
353
|
+
scope: "global",
|
|
354
|
+
});
|
|
421
355
|
}
|
|
422
356
|
/**
|
|
423
357
|
* Date must be between start and end months (1-12)
|
|
@@ -426,11 +360,11 @@ class DateValidator extends BaseValidator {
|
|
|
426
360
|
* @category Validation Rule
|
|
427
361
|
*/
|
|
428
362
|
betweenMonths(startMonth, endMonth, errorMessage) {
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
363
|
+
return this.addRule(betweenMonthsRule, errorMessage, {
|
|
364
|
+
startMonth,
|
|
365
|
+
endMonth,
|
|
366
|
+
scope: "global",
|
|
367
|
+
});
|
|
434
368
|
}
|
|
435
369
|
/**
|
|
436
370
|
* Date must be between start and end days (1-31)
|
|
@@ -439,44 +373,44 @@ class DateValidator extends BaseValidator {
|
|
|
439
373
|
* @category Validation Rule
|
|
440
374
|
*/
|
|
441
375
|
betweenDays(startDay, endDay, errorMessage) {
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
376
|
+
return this.addRule(betweenDaysRule, errorMessage, {
|
|
377
|
+
startDay,
|
|
378
|
+
endDay,
|
|
379
|
+
scope: "global",
|
|
380
|
+
});
|
|
447
381
|
}
|
|
448
382
|
/**
|
|
449
383
|
* Date must be between sibling field years
|
|
450
384
|
* @category Validation Rule
|
|
451
385
|
*/
|
|
452
386
|
betweenYearsSibling(startYearField, endYearField, errorMessage) {
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
387
|
+
return this.addRule(betweenYearsRule, errorMessage, {
|
|
388
|
+
startYear: startYearField,
|
|
389
|
+
endYear: endYearField,
|
|
390
|
+
scope: "sibling",
|
|
391
|
+
});
|
|
458
392
|
}
|
|
459
393
|
/**
|
|
460
394
|
* Date must be between sibling field months
|
|
461
395
|
* @category Validation Rule
|
|
462
396
|
*/
|
|
463
397
|
betweenMonthsSibling(startMonthField, endMonthField, errorMessage) {
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
398
|
+
return this.addRule(betweenMonthsRule, errorMessage, {
|
|
399
|
+
startMonth: startMonthField,
|
|
400
|
+
endMonth: endMonthField,
|
|
401
|
+
scope: "sibling",
|
|
402
|
+
});
|
|
469
403
|
}
|
|
470
404
|
/**
|
|
471
405
|
* Date must be between sibling field days
|
|
472
406
|
* @category Validation Rule
|
|
473
407
|
*/
|
|
474
408
|
betweenDaysSibling(startDayField, endDayField, errorMessage) {
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
409
|
+
return this.addRule(betweenDaysRule, errorMessage, {
|
|
410
|
+
startDay: startDayField,
|
|
411
|
+
endDay: endDayField,
|
|
412
|
+
scope: "sibling",
|
|
413
|
+
});
|
|
480
414
|
}
|
|
481
415
|
/**
|
|
482
416
|
* Year must be >= given year or field
|
|
@@ -494,10 +428,10 @@ class DateValidator extends BaseValidator {
|
|
|
494
428
|
* @category Validation Rule
|
|
495
429
|
*/
|
|
496
430
|
minYear(yearOrField, errorMessage) {
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
431
|
+
return this.addRule(minYearRule, errorMessage, {
|
|
432
|
+
yearOrField,
|
|
433
|
+
scope: "global",
|
|
434
|
+
});
|
|
501
435
|
}
|
|
502
436
|
/**
|
|
503
437
|
* Year must be <= given year or field
|
|
@@ -506,10 +440,10 @@ class DateValidator extends BaseValidator {
|
|
|
506
440
|
* @category Validation Rule
|
|
507
441
|
*/
|
|
508
442
|
maxYear(yearOrField, errorMessage) {
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
443
|
+
return this.addRule(maxYearRule, errorMessage, {
|
|
444
|
+
yearOrField,
|
|
445
|
+
scope: "global",
|
|
446
|
+
});
|
|
513
447
|
}
|
|
514
448
|
/**
|
|
515
449
|
* Month must be >= given month or field (1-12)
|
|
@@ -518,10 +452,10 @@ class DateValidator extends BaseValidator {
|
|
|
518
452
|
* @category Validation Rule
|
|
519
453
|
*/
|
|
520
454
|
minMonth(monthOrField, errorMessage) {
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
455
|
+
return this.addRule(minMonthRule, errorMessage, {
|
|
456
|
+
monthOrField,
|
|
457
|
+
scope: "global",
|
|
458
|
+
});
|
|
525
459
|
}
|
|
526
460
|
/**
|
|
527
461
|
* Month must be <= given month or field (1-12)
|
|
@@ -530,10 +464,10 @@ class DateValidator extends BaseValidator {
|
|
|
530
464
|
* @category Validation Rule
|
|
531
465
|
*/
|
|
532
466
|
maxMonth(monthOrField, errorMessage) {
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
467
|
+
return this.addRule(maxMonthRule, errorMessage, {
|
|
468
|
+
monthOrField,
|
|
469
|
+
scope: "global",
|
|
470
|
+
});
|
|
537
471
|
}
|
|
538
472
|
/**
|
|
539
473
|
* Day must be >= given day or field (1-31)
|
|
@@ -542,10 +476,10 @@ class DateValidator extends BaseValidator {
|
|
|
542
476
|
* @category Validation Rule
|
|
543
477
|
*/
|
|
544
478
|
minDay(dayOrField, errorMessage) {
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
479
|
+
return this.addRule(minDayRule, errorMessage, {
|
|
480
|
+
dayOrField,
|
|
481
|
+
scope: "global",
|
|
482
|
+
});
|
|
549
483
|
}
|
|
550
484
|
/**
|
|
551
485
|
* Day must be <= given day or field (1-31)
|
|
@@ -554,92 +488,88 @@ class DateValidator extends BaseValidator {
|
|
|
554
488
|
* @category Validation Rule
|
|
555
489
|
*/
|
|
556
490
|
maxDay(dayOrField, errorMessage) {
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
491
|
+
return this.addRule(maxDayRule, errorMessage, {
|
|
492
|
+
dayOrField,
|
|
493
|
+
scope: "global",
|
|
494
|
+
});
|
|
561
495
|
}
|
|
562
496
|
/**
|
|
563
497
|
* Year must be >= sibling field year
|
|
564
498
|
* @category Validation Rule
|
|
565
499
|
*/
|
|
566
500
|
minYearSibling(field, errorMessage) {
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
501
|
+
return this.addRule(minYearRule, errorMessage, {
|
|
502
|
+
yearOrField: field,
|
|
503
|
+
scope: "sibling",
|
|
504
|
+
});
|
|
571
505
|
}
|
|
572
506
|
/**
|
|
573
507
|
* Year must be <= sibling field year
|
|
574
508
|
* @category Validation Rule
|
|
575
509
|
*/
|
|
576
510
|
maxYearSibling(field, errorMessage) {
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
511
|
+
return this.addRule(maxYearRule, errorMessage, {
|
|
512
|
+
yearOrField: field,
|
|
513
|
+
scope: "sibling",
|
|
514
|
+
});
|
|
581
515
|
}
|
|
582
516
|
/**
|
|
583
517
|
* Month must be >= sibling field month
|
|
584
518
|
* @category Validation Rule
|
|
585
519
|
*/
|
|
586
520
|
minMonthSibling(field, errorMessage) {
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
521
|
+
return this.addRule(minMonthRule, errorMessage, {
|
|
522
|
+
monthOrField: field,
|
|
523
|
+
scope: "sibling",
|
|
524
|
+
});
|
|
591
525
|
}
|
|
592
526
|
/**
|
|
593
527
|
* Month must be <= sibling field month
|
|
594
528
|
* @category Validation Rule
|
|
595
529
|
*/
|
|
596
530
|
maxMonthSibling(field, errorMessage) {
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
531
|
+
return this.addRule(maxMonthRule, errorMessage, {
|
|
532
|
+
monthOrField: field,
|
|
533
|
+
scope: "sibling",
|
|
534
|
+
});
|
|
601
535
|
}
|
|
602
536
|
/**
|
|
603
537
|
* Day must be >= sibling field day
|
|
604
538
|
* @category Validation Rule
|
|
605
539
|
*/
|
|
606
540
|
minDaySibling(field, errorMessage) {
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
541
|
+
return this.addRule(minDayRule, errorMessage, {
|
|
542
|
+
dayOrField: field,
|
|
543
|
+
scope: "sibling",
|
|
544
|
+
});
|
|
611
545
|
}
|
|
612
546
|
/**
|
|
613
547
|
* Day must be <= sibling field day
|
|
614
548
|
* @category Validation Rule
|
|
615
549
|
*/
|
|
616
550
|
maxDaySibling(field, errorMessage) {
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
551
|
+
return this.addRule(maxDayRule, errorMessage, {
|
|
552
|
+
dayOrField: field,
|
|
553
|
+
scope: "sibling",
|
|
554
|
+
});
|
|
621
555
|
}
|
|
622
556
|
/** Date must be in specific quarter (1-4) */
|
|
623
557
|
quarter(quarter, errorMessage) {
|
|
624
|
-
|
|
625
|
-
rule.context.options.quarter = quarter;
|
|
626
|
-
return this;
|
|
558
|
+
return this.addRule(quarterRule, errorMessage, { quarter });
|
|
627
559
|
}
|
|
628
560
|
// ==================== Special Validation ====================
|
|
629
561
|
/** Valid birthday (not in future, reasonable age) */
|
|
630
562
|
birthday(minAge, maxAge, errorMessage) {
|
|
631
|
-
|
|
632
|
-
if (minAge !== undefined) {
|
|
633
|
-
rule.context.options.minAge = minAge;
|
|
634
|
-
}
|
|
635
|
-
if (maxAge !== undefined) {
|
|
636
|
-
rule.context.options.maxAge = maxAge;
|
|
637
|
-
}
|
|
638
|
-
return this;
|
|
563
|
+
return this.addRule(birthdayRule, errorMessage, { minAge, maxAge });
|
|
639
564
|
}
|
|
640
565
|
/** Date must be in a leap year */
|
|
641
566
|
leapYear(errorMessage) {
|
|
642
|
-
this.addRule(leapYearRule, errorMessage);
|
|
643
|
-
|
|
567
|
+
return this.addRule(leapYearRule, errorMessage);
|
|
568
|
+
}
|
|
569
|
+
/**
|
|
570
|
+
* Set default value as current time of exeuction
|
|
571
|
+
*/
|
|
572
|
+
defaultNow() {
|
|
573
|
+
return this.default(() => new Date());
|
|
644
574
|
}
|
|
645
575
|
}export{DateValidator};//# sourceMappingURL=date-validator.js.map
|