@warlock.js/seal 5.30.0 → 5.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +46 -7
- package/README.md +57 -9
- package/cjs/index.cjs +41 -29
- package/cjs/index.cjs.map +1 -1
- package/cjs/{object--LXRt5RF.cjs → object-BoVGJ68E.cjs} +43 -24
- package/cjs/object-BoVGJ68E.cjs.map +1 -0
- package/cjs/object.cjs +2 -2
- package/cjs/{required-methods-DYsRO9aZ.cjs → required-methods-BJlnLnwa.cjs} +343 -258
- package/cjs/required-methods-BJlnLnwa.cjs.map +1 -0
- package/cjs/{string-DsqnKoSB.cjs → string-CM8x0u2w.cjs} +46 -44
- package/cjs/string-CM8x0u2w.cjs.map +1 -0
- package/cjs/string.cjs +2 -2
- package/esm/config.d.mts +7 -8
- package/esm/config.d.mts.map +1 -1
- package/esm/config.mjs.map +1 -1
- package/esm/factory/index.d.mts +2 -1
- package/esm/factory/index.mjs +1 -1
- package/esm/factory/validate.d.mts +3 -6
- package/esm/factory/validate.d.mts.map +1 -1
- package/esm/factory/validators.d.mts +16 -13
- package/esm/factory/validators.d.mts.map +1 -1
- package/esm/factory/validators.mjs +7 -1
- package/esm/factory/validators.mjs.map +1 -1
- package/esm/helpers/date-helpers.d.mts +1 -2
- package/esm/helpers/date-helpers.d.mts.map +1 -1
- package/esm/helpers/file.utils.d.mts +2 -4
- package/esm/helpers/file.utils.d.mts.map +1 -1
- package/esm/helpers/get-field-value.d.mts +2 -3
- package/esm/helpers/get-field-value.d.mts.map +1 -1
- package/esm/helpers/get-field-value.mjs +2 -1
- package/esm/helpers/get-field-value.mjs.map +1 -1
- package/esm/helpers/index.d.mts +6 -0
- package/esm/helpers/index.mjs +1 -1
- package/esm/helpers/path-helpers.d.mts +1 -2
- package/esm/helpers/path-helpers.d.mts.map +1 -1
- package/esm/helpers/validation-helpers.d.mts +4 -10
- package/esm/helpers/validation-helpers.d.mts.map +1 -1
- package/esm/index.d.mts +7 -0
- package/esm/mutators/array-mutators.d.mts +6 -7
- package/esm/mutators/array-mutators.d.mts.map +1 -1
- package/esm/mutators/boolean-mutators.d.mts +3 -4
- package/esm/mutators/boolean-mutators.d.mts.map +1 -1
- package/esm/mutators/date-mutators.d.mts +18 -19
- package/esm/mutators/date-mutators.d.mts.map +1 -1
- package/esm/mutators/index.d.mts +8 -0
- package/esm/mutators/index.mjs +1 -1
- package/esm/mutators/number-mutators.d.mts +10 -11
- package/esm/mutators/number-mutators.d.mts.map +1 -1
- package/esm/mutators/object-mutators.d.mts +4 -5
- package/esm/mutators/object-mutators.d.mts.map +1 -1
- package/esm/mutators/object-mutators.mjs +5 -4
- package/esm/mutators/object-mutators.mjs.map +1 -1
- package/esm/mutators/scalar-mutators.d.mts +2 -3
- package/esm/mutators/scalar-mutators.d.mts.map +1 -1
- package/esm/mutators/string-mutators.d.mts +37 -38
- package/esm/mutators/string-mutators.d.mts.map +1 -1
- package/esm/mutators/string-mutators.mjs +5 -3
- package/esm/mutators/string-mutators.mjs.map +1 -1
- package/esm/object.d.mts +3 -5
- package/esm/object.d.mts.map +1 -1
- package/esm/object.mjs.map +1 -1
- package/esm/plugins/plugin-system.d.mts +11 -9
- package/esm/plugins/plugin-system.d.mts.map +1 -1
- package/esm/rules/array/array-rules.d.mts +3 -4
- package/esm/rules/array/array-rules.d.mts.map +1 -1
- package/esm/rules/array/index.d.mts +2 -0
- package/esm/rules/array/index.mjs +1 -1
- package/esm/rules/color/color-rules.d.mts +8 -9
- package/esm/rules/color/color-rules.d.mts.map +1 -1
- package/esm/rules/color/index.d.mts +2 -0
- package/esm/rules/color/index.mjs +1 -1
- package/esm/rules/common/enum.d.mts +5 -6
- package/esm/rules/common/enum.d.mts.map +1 -1
- package/esm/rules/common/equals-field-rules.d.mts +3 -4
- package/esm/rules/common/equals-field-rules.d.mts.map +1 -1
- package/esm/rules/common/index.d.mts +7 -0
- package/esm/rules/common/index.mjs +1 -1
- package/esm/rules/common/instanceof.d.mts +2 -3
- package/esm/rules/common/instanceof.d.mts.map +1 -1
- package/esm/rules/common/literal.d.mts +2 -3
- package/esm/rules/common/literal.d.mts.map +1 -1
- package/esm/rules/common/literal.mjs.map +1 -1
- package/esm/rules/common/type-rules.d.mts +10 -11
- package/esm/rules/common/type-rules.d.mts.map +1 -1
- package/esm/rules/common/unknown-key.d.mts +2 -3
- package/esm/rules/common/unknown-key.d.mts.map +1 -1
- package/esm/rules/conditional/forbidden-if-rules.d.mts +7 -8
- package/esm/rules/conditional/forbidden-if-rules.d.mts.map +1 -1
- package/esm/rules/conditional/index.d.mts +11 -0
- package/esm/rules/conditional/index.mjs +1 -1
- package/esm/rules/conditional/present-if-rules.d.mts +6 -7
- package/esm/rules/conditional/present-if-rules.d.mts.map +1 -1
- package/esm/rules/conditional/present-unless-rules.d.mts +2 -3
- package/esm/rules/conditional/present-unless-rules.d.mts.map +1 -1
- package/esm/rules/conditional/present-with-rules.d.mts +4 -5
- package/esm/rules/conditional/present-with-rules.d.mts.map +1 -1
- package/esm/rules/conditional/present-without-rules.d.mts +4 -5
- package/esm/rules/conditional/present-without-rules.d.mts.map +1 -1
- package/esm/rules/conditional/required-if-rules.d.mts +10 -11
- package/esm/rules/conditional/required-if-rules.d.mts.map +1 -1
- package/esm/rules/conditional/required-unless-rules.d.mts +2 -3
- package/esm/rules/conditional/required-unless-rules.d.mts.map +1 -1
- package/esm/rules/conditional/required-when-rule.d.mts +2 -3
- package/esm/rules/conditional/required-when-rule.d.mts.map +1 -1
- package/esm/rules/conditional/required-with-rules.d.mts +4 -5
- package/esm/rules/conditional/required-with-rules.d.mts.map +1 -1
- package/esm/rules/conditional/required-without-rules.d.mts +4 -5
- package/esm/rules/conditional/required-without-rules.d.mts.map +1 -1
- package/esm/rules/core/equal.d.mts +2 -3
- package/esm/rules/core/equal.d.mts.map +1 -1
- package/esm/rules/core/forbidden.d.mts +2 -3
- package/esm/rules/core/forbidden.d.mts.map +1 -1
- package/esm/rules/core/index.d.mts +6 -0
- package/esm/rules/core/index.mjs +1 -1
- package/esm/rules/core/required.d.mts +3 -4
- package/esm/rules/core/required.d.mts.map +1 -1
- package/esm/rules/core/union.d.mts +10 -4
- package/esm/rules/core/union.d.mts.map +1 -1
- package/esm/rules/core/union.mjs +56 -10
- package/esm/rules/core/union.mjs.map +1 -1
- package/esm/rules/core/when.d.mts +2 -3
- package/esm/rules/core/when.d.mts.map +1 -1
- package/esm/rules/core/when.mjs.map +1 -1
- package/esm/rules/date/date-comparison-rules.d.mts +6 -7
- package/esm/rules/date/date-comparison-rules.d.mts.map +1 -1
- package/esm/rules/date/date-day-rules.d.mts +5 -6
- package/esm/rules/date/date-day-rules.d.mts.map +1 -1
- package/esm/rules/date/date-field-comparison-rules.d.mts +4 -5
- package/esm/rules/date/date-field-comparison-rules.d.mts.map +1 -1
- package/esm/rules/date/date-field-comparison-rules.mjs +6 -3
- package/esm/rules/date/date-field-comparison-rules.mjs.map +1 -1
- package/esm/rules/date/date-period-rules.d.mts +16 -16
- package/esm/rules/date/date-period-rules.d.mts.map +1 -1
- package/esm/rules/date/date-period-rules.mjs +24 -12
- package/esm/rules/date/date-period-rules.mjs.map +1 -1
- package/esm/rules/date/date-relative-rules.d.mts +4 -5
- package/esm/rules/date/date-relative-rules.d.mts.map +1 -1
- package/esm/rules/date/date-relative-rules.mjs +3 -3
- package/esm/rules/date/date-relative-rules.mjs.map +1 -1
- package/esm/rules/date/date-special-rules.d.mts +4 -5
- package/esm/rules/date/date-special-rules.d.mts.map +1 -1
- package/esm/rules/date/date.d.mts +16 -17
- package/esm/rules/date/date.d.mts.map +1 -1
- package/esm/rules/date/date.mjs +4 -2
- package/esm/rules/date/date.mjs.map +1 -1
- package/esm/rules/date/index.d.mts +8 -0
- package/esm/rules/date/index.mjs +1 -1
- package/esm/rules/file/dimensions.d.mts +5 -6
- package/esm/rules/file/dimensions.d.mts.map +1 -1
- package/esm/rules/file/file-size.d.mts +3 -4
- package/esm/rules/file/file-size.d.mts.map +1 -1
- package/esm/rules/file/index.d.mts +3 -0
- package/esm/rules/file/index.mjs +1 -1
- package/esm/rules/index.d.mts +56 -0
- package/esm/rules/index.mjs +1 -1
- package/esm/rules/length/index.d.mts +2 -0
- package/esm/rules/length/index.mjs +1 -1
- package/esm/rules/length/length-rules.d.mts +8 -9
- package/esm/rules/length/length-rules.d.mts.map +1 -1
- package/esm/rules/number/index.d.mts +2 -0
- package/esm/rules/number/index.mjs +1 -1
- package/esm/rules/number/number-rules.d.mts +11 -12
- package/esm/rules/number/number-rules.d.mts.map +1 -1
- package/esm/rules/number/number-rules.mjs +12 -6
- package/esm/rules/number/number-rules.mjs.map +1 -1
- package/esm/rules/scalar/index.mjs +1 -1
- package/esm/rules/string/alpha.d.mts +4 -5
- package/esm/rules/string/alpha.d.mts.map +1 -1
- package/esm/rules/string/credit-card.d.mts +2 -3
- package/esm/rules/string/credit-card.d.mts.map +1 -1
- package/esm/rules/string/email.d.mts +2 -3
- package/esm/rules/string/email.d.mts.map +1 -1
- package/esm/rules/string/id-formats.d.mts +6 -7
- package/esm/rules/string/id-formats.d.mts.map +1 -1
- package/esm/rules/string/index.d.mts +12 -0
- package/esm/rules/string/index.mjs +1 -1
- package/esm/rules/string/ip.d.mts +7 -8
- package/esm/rules/string/ip.d.mts.map +1 -1
- package/esm/rules/string/matches.d.mts +2 -3
- package/esm/rules/string/matches.d.mts.map +1 -1
- package/esm/rules/string/pattern.d.mts +2 -3
- package/esm/rules/string/pattern.d.mts.map +1 -1
- package/esm/rules/string/string-comparison.d.mts +5 -6
- package/esm/rules/string/string-comparison.d.mts.map +1 -1
- package/esm/rules/string/strong-password-rule.d.mts +2 -3
- package/esm/rules/string/strong-password-rule.d.mts.map +1 -1
- package/esm/rules/string/url.d.mts +2 -3
- package/esm/rules/string/url.d.mts.map +1 -1
- package/esm/rules/string/without-whitespace.d.mts +2 -3
- package/esm/rules/string/without-whitespace.d.mts.map +1 -1
- package/esm/standard-schema/index.d.mts +4 -0
- package/esm/standard-schema/json-schema.d.mts +5 -7
- package/esm/standard-schema/json-schema.d.mts.map +1 -1
- package/esm/standard-schema/json-schema.mjs.map +1 -1
- package/esm/standard-schema/map-result.d.mts +2 -3
- package/esm/standard-schema/map-result.d.mts.map +1 -1
- package/esm/standard-schema/map-result.mjs.map +1 -1
- package/esm/standard-schema/types.d.mts +4 -5
- package/esm/standard-schema/types.d.mts.map +1 -1
- package/esm/string.d.mts +2 -3
- package/esm/string.d.mts.map +1 -1
- package/esm/types/conditional-types.d.mts +8 -6
- package/esm/types/conditional-types.d.mts.map +1 -1
- package/esm/types/context-types.d.mts +24 -15
- package/esm/types/context-types.d.mts.map +1 -1
- package/esm/types/data-transformer-types.d.mts +3 -5
- package/esm/types/data-transformer-types.d.mts.map +1 -1
- package/esm/types/date-types.d.mts +2 -3
- package/esm/types/date-types.d.mts.map +1 -1
- package/esm/types/file.types.d.mts +1 -2
- package/esm/types/file.types.d.mts.map +1 -1
- package/esm/types/index.d.mts +11 -0
- package/esm/types/inference-types.d.mts +15 -14
- package/esm/types/inference-types.d.mts.map +1 -1
- package/esm/types/mutator-types.d.mts +9 -7
- package/esm/types/mutator-types.d.mts.map +1 -1
- package/esm/types/result-types.d.mts +12 -7
- package/esm/types/result-types.d.mts.map +1 -1
- package/esm/types/rule-types.d.mts +33 -15
- package/esm/types/rule-types.d.mts.map +1 -1
- package/esm/types/schema-types.d.mts +1 -3
- package/esm/types/schema-types.d.mts.map +1 -1
- package/esm/validators/any-validator.d.mts +1 -3
- package/esm/validators/any-validator.d.mts.map +1 -1
- package/esm/validators/array-validator.d.mts +2 -3
- package/esm/validators/array-validator.d.mts.map +1 -1
- package/esm/validators/array-validator.mjs +3 -3
- package/esm/validators/array-validator.mjs.map +1 -1
- package/esm/validators/base-validator.d.mts +10 -11
- package/esm/validators/base-validator.d.mts.map +1 -1
- package/esm/validators/base-validator.mjs +52 -21
- package/esm/validators/base-validator.mjs.map +1 -1
- package/esm/validators/boolean-validator.d.mts +1 -3
- package/esm/validators/boolean-validator.d.mts.map +1 -1
- package/esm/validators/computed-validator.d.mts +3 -4
- package/esm/validators/computed-validator.d.mts.map +1 -1
- package/esm/validators/computed-validator.mjs +4 -4
- package/esm/validators/computed-validator.mjs.map +1 -1
- package/esm/validators/date-validator.d.mts +2 -3
- package/esm/validators/date-validator.d.mts.map +1 -1
- package/esm/validators/discriminated-union-validator.d.mts +3 -3
- package/esm/validators/discriminated-union-validator.d.mts.map +1 -1
- package/esm/validators/discriminated-union-validator.mjs +1 -1
- package/esm/validators/discriminated-union-validator.mjs.map +1 -1
- package/esm/validators/float-validator.d.mts +1 -3
- package/esm/validators/float-validator.d.mts.map +1 -1
- package/esm/validators/index.d.mts +2 -1
- package/esm/validators/index.mjs +1 -1
- package/esm/validators/instanceof-validator.d.mts +1 -3
- package/esm/validators/instanceof-validator.d.mts.map +1 -1
- package/esm/validators/int-validator.d.mts +1 -3
- package/esm/validators/int-validator.d.mts.map +1 -1
- package/esm/validators/lazy-validator.d.mts +2 -3
- package/esm/validators/lazy-validator.d.mts.map +1 -1
- package/esm/validators/lazy-validator.mjs +1 -1
- package/esm/validators/lazy-validator.mjs.map +1 -1
- package/esm/validators/literal-validator.d.mts +1 -3
- package/esm/validators/literal-validator.d.mts.map +1 -1
- package/esm/validators/managed-validator.d.mts +3 -4
- package/esm/validators/managed-validator.d.mts.map +1 -1
- package/esm/validators/methods/equality-conditional-methods.d.mts +3 -4
- package/esm/validators/methods/equality-conditional-methods.d.mts.map +1 -1
- package/esm/validators/methods/forbidden-methods.d.mts +2 -3
- package/esm/validators/methods/forbidden-methods.d.mts.map +1 -1
- package/esm/validators/methods/present-methods.d.mts +2 -3
- package/esm/validators/methods/present-methods.d.mts.map +1 -1
- package/esm/validators/methods/required-methods.d.mts +3 -4
- package/esm/validators/methods/required-methods.d.mts.map +1 -1
- package/esm/validators/number-validator.d.mts +1 -3
- package/esm/validators/number-validator.d.mts.map +1 -1
- package/esm/validators/number-validator.mjs +12 -8
- package/esm/validators/number-validator.mjs.map +1 -1
- package/esm/validators/numeric-validator.d.mts +1 -3
- package/esm/validators/numeric-validator.d.mts.map +1 -1
- package/esm/validators/object-validator.d.mts +2 -3
- package/esm/validators/object-validator.d.mts.map +1 -1
- package/esm/validators/object-validator.mjs +9 -7
- package/esm/validators/object-validator.mjs.map +1 -1
- package/esm/validators/primitive-validator.d.mts +1 -3
- package/esm/validators/primitive-validator.d.mts.map +1 -1
- package/esm/validators/record-validator.d.mts +2 -3
- package/esm/validators/record-validator.d.mts.map +1 -1
- package/esm/validators/record-validator.mjs +3 -3
- package/esm/validators/record-validator.mjs.map +1 -1
- package/esm/validators/scalar-validator.d.mts +1 -3
- package/esm/validators/scalar-validator.d.mts.map +1 -1
- package/esm/validators/scalar-validator.mjs.map +1 -1
- package/esm/validators/string-validator.d.mts +1 -3
- package/esm/validators/string-validator.d.mts.map +1 -1
- package/esm/validators/tuple-validator.d.mts +2 -3
- package/esm/validators/tuple-validator.d.mts.map +1 -1
- package/esm/validators/tuple-validator.mjs +3 -3
- package/esm/validators/tuple-validator.mjs.map +1 -1
- package/esm/validators/union-validator.d.mts +4 -4
- package/esm/validators/union-validator.d.mts.map +1 -1
- package/esm/validators/union-validator.mjs +3 -1
- package/esm/validators/union-validator.mjs.map +1 -1
- package/llms-full.txt +656 -527
- package/llms.txt +1 -1
- package/package.json +1 -1
- package/skills/bridge-standard-schema/SKILL.md +60 -36
- package/skills/compose-seal-modifiers/SKILL.md +89 -53
- package/skills/define-structural-shape/SKILL.md +41 -27
- package/skills/define-structural-shape/array-methods.md +27 -27
- package/skills/define-structural-shape/object-methods.md +38 -30
- package/skills/extend-seal-with-plugins/SKILL.md +39 -5
- package/skills/generate-json-schema/SKILL.md +13 -13
- package/skills/handle-seal-errors/SKILL.md +23 -23
- package/skills/index.md +4 -1
- package/skills/overview/SKILL.md +10 -2
- package/skills/pick-seal-primitive/SKILL.md +45 -45
- package/skills/pick-seal-primitive/date-methods.md +96 -96
- package/skills/pick-seal-primitive/number-methods.md +55 -55
- package/skills/pick-seal-primitive/string-methods.md +107 -102
- package/skills/seal-basics/SKILL.md +14 -14
- package/cjs/object--LXRt5RF.cjs.map +0 -1
- package/cjs/required-methods-DYsRO9aZ.cjs.map +0 -1
- package/cjs/string-DsqnKoSB.cjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"date-period-rules.mjs","names":[],"sources":["../../../../../../../../../packages/seal/src/rules/date/date-period-rules.ts"],"sourcesContent":["import { get } from \"@mongez/reinforcements\";\nimport { invalidRule, VALID_RULE } from \"../../helpers\";\nimport type { SchemaRule } from \"../../types\";\n\nconst MONTHS = {\n 1: \"january\",\n 2: \"february\",\n 3: \"march\",\n 4: \"april\",\n 5: \"may\",\n 6: \"june\",\n 7: \"july\",\n 8: \"august\",\n 9: \"september\",\n 10: \"october\",\n 11: \"november\",\n 12: \"december\",\n};\n\nexport type Month = keyof typeof MONTHS;\n\n/**\n * Month rule - date must be in specific month (1-12)\n */\nexport const monthRule: SchemaRule<{ month: Month }> = {\n name: \"month\",\n defaultErrorMessage: \"The :input must be in month :month\",\n async validate(value: Date, context) {\n const inputDate = new Date(value);\n const month = inputDate.getMonth() + 1; // getMonth() returns 0-11\n\n if (month === this.context.options.month) {\n return VALID_RULE;\n }\n\n this.context.translatableParams.month =\n MONTHS[this.context.options.month as keyof typeof MONTHS];\n return invalidRule(this, context);\n },\n};\n\n/**\n * Year rule - date must be in specific year\n */\nexport const yearRule: SchemaRule<{ year: number }> = {\n name: \"year\",\n defaultErrorMessage: \"The :input must be in year :year\",\n async validate(value: Date, context) {\n const inputDate = new Date(value);\n const year = inputDate.getFullYear();\n\n if (year === this.context.options.year) {\n return VALID_RULE;\n }\n\n this.context.translationParams.year = this.context.options.year;\n return invalidRule(this, context);\n },\n};\n\n/**\n * Between years rule - date must be between start and end years\n * Supports field names with sibling scope\n */\nexport const betweenYearsRule: SchemaRule<{\n startYear: number | string;\n endYear: number | string;\n scope?: \"global\" | \"sibling\";\n}> = {\n name: \"betweenYears\",\n defaultErrorMessage: \"The :input must be between :startYear and :endYear\",\n async validate(value: Date, context) {\n const { startYear, endYear, scope = \"global\" } = this.context.options;\n const inputDate = new Date(value);\n const inputYear = inputDate.getFullYear();\n\n // Extract start year\n let compareStartYear: number;\n if (typeof startYear === \"number\") {\n compareStartYear = startYear;\n } else {\n const source = scope === \"sibling\" ? context.parent : context.allValues;\n const fieldValue = get(source, startYear);\n\n if (fieldValue === undefined) {\n return VALID_RULE;\n }\n\n if (fieldValue instanceof Date) {\n compareStartYear = fieldValue.getFullYear();\n } else if (typeof fieldValue === \"number\") {\n compareStartYear = fieldValue;\n } else {\n const date = new Date(fieldValue);\n if (!isNaN(date.getTime())) {\n compareStartYear = date.getFullYear();\n } else {\n return VALID_RULE;\n }\n }\n }\n\n // Extract end year\n let compareEndYear: number;\n if (typeof endYear === \"number\") {\n compareEndYear = endYear;\n } else {\n const source = scope === \"sibling\" ? context.parent : context.allValues;\n const fieldValue = get(source, endYear);\n\n if (fieldValue === undefined) {\n return VALID_RULE;\n }\n\n if (fieldValue instanceof Date) {\n compareEndYear = fieldValue.getFullYear();\n } else if (typeof fieldValue === \"number\") {\n compareEndYear = fieldValue;\n } else {\n const date = new Date(fieldValue);\n if (!isNaN(date.getTime())) {\n compareEndYear = date.getFullYear();\n } else {\n return VALID_RULE;\n }\n }\n }\n\n if (inputYear >= compareStartYear && inputYear <= compareEndYear) {\n return VALID_RULE;\n }\n\n this.context.translationParams.startYear = compareStartYear;\n this.context.translationParams.endYear = compareEndYear;\n return invalidRule(this, context);\n },\n};\n\n/**\n * Between months rule - date must be between start and end months (1-12)\n * Supports field names with sibling scope\n */\nexport const betweenMonthsRule: SchemaRule<{\n startMonth: Month | string;\n endMonth: Month | string;\n scope?: \"global\" | \"sibling\";\n}> = {\n name: \"betweenMonths\",\n defaultErrorMessage: \"The :input must be between month :startMonth and :endMonth\",\n async validate(value: Date, context) {\n const { startMonth, endMonth, scope = \"global\" } = this.context.options;\n const inputDate = new Date(value);\n const inputMonth = inputDate.getMonth() + 1; // getMonth() returns 0-11\n\n // Extract start month\n let compareStartMonth: number;\n if (typeof startMonth === \"number\") {\n compareStartMonth = startMonth;\n this.context.translatableParams.startMonth = MONTHS[compareStartMonth as keyof typeof MONTHS];\n } else {\n const source = scope === \"sibling\" ? context.parent : context.allValues;\n const fieldValue = get(source, startMonth);\n\n if (fieldValue === undefined) {\n return VALID_RULE;\n }\n\n this.context.translatableParams.startMonth = startMonth;\n\n if (fieldValue instanceof Date) {\n compareStartMonth = fieldValue.getMonth() + 1;\n } else if (typeof fieldValue === \"number\") {\n compareStartMonth = fieldValue;\n } else {\n const date = new Date(fieldValue);\n if (!isNaN(date.getTime())) {\n compareStartMonth = date.getMonth() + 1;\n } else {\n return VALID_RULE;\n }\n }\n }\n\n // Extract end month\n let compareEndMonth: number;\n if (typeof endMonth === \"number\") {\n compareEndMonth = endMonth;\n this.context.translatableParams.endMonth = MONTHS[compareEndMonth as keyof typeof MONTHS];\n } else {\n const source = scope === \"sibling\" ? context.parent : context.allValues;\n const fieldValue = get(source, endMonth);\n\n if (fieldValue === undefined) {\n return VALID_RULE;\n }\n\n this.context.translatableParams.endMonth = endMonth;\n\n if (fieldValue instanceof Date) {\n compareEndMonth = fieldValue.getMonth() + 1;\n } else if (typeof fieldValue === \"number\") {\n compareEndMonth = fieldValue;\n } else {\n const date = new Date(fieldValue);\n if (!isNaN(date.getTime())) {\n compareEndMonth = date.getMonth() + 1;\n } else {\n return VALID_RULE;\n }\n }\n }\n\n if (inputMonth >= compareStartMonth && inputMonth <= compareEndMonth) {\n return VALID_RULE;\n }\n\n return invalidRule(this, context);\n },\n};\n\n/**\n * Between days rule - date must be between start and end days (1-31)\n * Supports field names with sibling scope\n */\nexport const betweenDaysRule: SchemaRule<{\n startDay: number | string;\n endDay: number | string;\n scope?: \"global\" | \"sibling\";\n}> = {\n name: \"betweenDays\",\n defaultErrorMessage: \"The :input must be between day :startDay and :endDay\",\n async validate(value: Date, context) {\n const { startDay, endDay, scope = \"global\" } = this.context.options;\n const inputDate = new Date(value);\n const inputDay = inputDate.getDate();\n\n // Extract start day\n let compareStartDay: number;\n if (typeof startDay === \"number\") {\n compareStartDay = startDay;\n } else {\n const source = scope === \"sibling\" ? context.parent : context.allValues;\n const fieldValue = get(source, startDay);\n\n if (fieldValue === undefined) {\n return VALID_RULE;\n }\n\n if (fieldValue instanceof Date) {\n compareStartDay = fieldValue.getDate();\n } else if (typeof fieldValue === \"number\") {\n compareStartDay = fieldValue;\n } else {\n const date = new Date(fieldValue);\n if (!isNaN(date.getTime())) {\n compareStartDay = date.getDate();\n } else {\n return VALID_RULE;\n }\n }\n }\n\n // Extract end day\n let compareEndDay: number;\n if (typeof endDay === \"number\") {\n compareEndDay = endDay;\n } else {\n const source = scope === \"sibling\" ? context.parent : context.allValues;\n const fieldValue = get(source, endDay);\n\n if (fieldValue === undefined) {\n return VALID_RULE;\n }\n\n if (fieldValue instanceof Date) {\n compareEndDay = fieldValue.getDate();\n } else if (typeof fieldValue === \"number\") {\n compareEndDay = fieldValue;\n } else {\n const date = new Date(fieldValue);\n if (!isNaN(date.getTime())) {\n compareEndDay = date.getDate();\n } else {\n return VALID_RULE;\n }\n }\n }\n\n if (inputDay >= compareStartDay && inputDay <= compareEndDay) {\n return VALID_RULE;\n }\n\n this.context.translationParams.startDay = compareStartDay;\n this.context.translationParams.endDay = compareEndDay;\n return invalidRule(this, context);\n },\n};\n\n/**\n * Quarter rule - date must be in specific quarter (1-4)\n */\nexport const quarterRule: SchemaRule<{ quarter: 1 | 2 | 3 | 4 }> = {\n name: \"quarter\",\n defaultErrorMessage: \"The :input must be in quarter :quarter\",\n async validate(value: Date, context) {\n const inputDate = new Date(value);\n const month = inputDate.getMonth() + 1;\n const quarter = Math.ceil(month / 3);\n\n if (quarter === this.context.options.quarter) {\n return VALID_RULE;\n }\n\n this.context.translationParams.quarter = this.context.options.quarter;\n return invalidRule(this, context);\n },\n};\n\n/**\n * Between times rule - time must be between start and end times (HH:MM format)\n */\nexport const betweenTimesRule: SchemaRule<{\n startTime: string;\n endTime: string;\n}> = {\n name: \"betweenTimes\",\n defaultErrorMessage: \"The :input must be between :startTime and :endTime\",\n async validate(value: Date, context) {\n const inputDate = new Date(value);\n const inputHour = inputDate.getHours();\n const inputMinute = inputDate.getMinutes();\n const inputTimeInMinutes = inputHour * 60 + inputMinute;\n\n const { startTime, endTime } = this.context.options;\n\n // Parse start time\n const [startHour, startMinute] = startTime.split(\":\").map(Number);\n if (startHour === undefined || startMinute === undefined) {\n return invalidRule(this, context);\n }\n const startTimeInMinutes = startHour * 60 + startMinute;\n\n // Parse end time\n const [endHour, endMinute] = endTime.split(\":\").map(Number);\n if (endHour === undefined || endMinute === undefined) {\n return invalidRule(this, context);\n }\n const endTimeInMinutes = endHour * 60 + endMinute;\n\n if (inputTimeInMinutes >= startTimeInMinutes && inputTimeInMinutes <= endTimeInMinutes) {\n return VALID_RULE;\n }\n\n this.context.translationParams.startTime = startTime;\n this.context.translationParams.endTime = endTime;\n return invalidRule(this, context);\n },\n};\n\n/**\n * Min year rule - year must be >= given year or field\n * Smart detection: number or field name\n * Supports both global and sibling scope\n */\nexport const minYearRule: SchemaRule<{\n yearOrField: number | string;\n scope?: \"global\" | \"sibling\";\n}> = {\n name: \"minYear\",\n description: \"The date year must be at least the given year or field\",\n defaultErrorMessage: \"The :input year must be higher than :yearOrField\",\n async validate(value: Date, context) {\n const { yearOrField, scope = \"global\" } = this.context.options;\n let compareYear: number;\n\n if (typeof yearOrField === \"number\") {\n compareYear = yearOrField;\n this.context.translationParams.yearOrField = yearOrField;\n } else {\n const source = scope === \"sibling\" ? context.parent : context.allValues;\n const fieldValue = get(source, yearOrField);\n\n if (fieldValue === undefined) {\n return VALID_RULE;\n }\n\n this.context.translatableParams.yearOrField = yearOrField;\n\n // If field contains a date, extract the year\n if (fieldValue instanceof Date) {\n compareYear = fieldValue.getFullYear();\n } else if (typeof fieldValue === \"number\") {\n compareYear = fieldValue;\n } else {\n // Try to parse as date and extract year\n const date = new Date(fieldValue);\n if (!isNaN(date.getTime())) {\n compareYear = date.getFullYear();\n } else {\n return VALID_RULE;\n }\n }\n }\n\n const inputDate = new Date(value);\n const inputYear = inputDate.getFullYear();\n\n if (inputYear >= compareYear) {\n return VALID_RULE;\n }\n\n return invalidRule(this, context);\n },\n};\n\n/**\n * Max year rule - year must be <= given year or field\n * Smart detection: number or field name\n * Supports both global and sibling scope\n */\nexport const maxYearRule: SchemaRule<{\n yearOrField: number | string;\n scope?: \"global\" | \"sibling\";\n}> = {\n name: \"maxYear\",\n description: \"The date year must be at most the given year or field\",\n defaultErrorMessage: \"The :input year must be at most :yearOrField\",\n async validate(value: Date, context) {\n const { yearOrField, scope = \"global\" } = this.context.options;\n let compareYear: number;\n\n if (typeof yearOrField === \"number\") {\n compareYear = yearOrField;\n this.context.translationParams.yearOrField = compareYear;\n } else {\n const source = scope === \"sibling\" ? context.parent : context.allValues;\n const fieldValue = get(source, yearOrField);\n\n if (fieldValue === undefined) {\n return VALID_RULE;\n }\n\n this.context.translatableParams.yearOrField = yearOrField;\n\n // If field contains a date, extract the year\n if (fieldValue instanceof Date) {\n compareYear = fieldValue.getFullYear();\n } else if (typeof fieldValue === \"number\") {\n compareYear = fieldValue;\n } else {\n // Try to parse as date and extract year\n const date = new Date(fieldValue);\n if (!isNaN(date.getTime())) {\n compareYear = date.getFullYear();\n } else {\n return VALID_RULE;\n }\n }\n }\n\n const inputDate = new Date(value);\n const inputYear = inputDate.getFullYear();\n\n if (inputYear <= compareYear) {\n return VALID_RULE;\n }\n\n return invalidRule(this, context);\n },\n};\n\n/**\n * Min month rule - month must be >= given month or field (1-12)\n * Smart detection: number or field name\n * Supports both global and sibling scope\n */\nexport const minMonthRule: SchemaRule<{\n monthOrField: number | string;\n scope?: \"global\" | \"sibling\";\n}> = {\n name: \"minMonth\",\n description: \"The date month must be at least the given month or field\",\n defaultErrorMessage: \"The :input month must be at least :monthOrField\",\n async validate(value: Date, context) {\n const { monthOrField, scope = \"global\" } = this.context.options;\n let compareMonth: number;\n\n if (typeof monthOrField === \"number\") {\n compareMonth = monthOrField;\n this.context.translationParams.monthOrField = compareMonth;\n } else {\n const source = scope === \"sibling\" ? context.parent : context.allValues;\n const fieldValue = get(source, monthOrField);\n\n if (fieldValue === undefined) {\n return VALID_RULE;\n }\n\n this.context.translatableParams.monthOrField = monthOrField;\n\n // If field contains a date, extract the month\n if (fieldValue instanceof Date) {\n compareMonth = fieldValue.getMonth() + 1; // getMonth() returns 0-11\n } else if (typeof fieldValue === \"number\") {\n compareMonth = fieldValue;\n } else {\n // Try to parse as date and extract month\n const date = new Date(fieldValue);\n if (!isNaN(date.getTime())) {\n compareMonth = date.getMonth() + 1;\n } else {\n return VALID_RULE;\n }\n }\n }\n\n const inputDate = new Date(value);\n const inputMonth = inputDate.getMonth() + 1; // getMonth() returns 0-11\n\n if (inputMonth >= compareMonth) {\n return VALID_RULE;\n }\n return invalidRule(this, context);\n },\n};\n\n/**\n * Max month rule - month must be <= given month or field (1-12)\n * Smart detection: number or field name\n * Supports both global and sibling scope\n */\nexport const maxMonthRule: SchemaRule<{\n monthOrField: Month | string;\n scope?: \"global\" | \"sibling\";\n}> = {\n name: \"maxMonth\",\n description: \"The date month must be at most the given month or field\",\n defaultErrorMessage: \"The :input month must be at most :monthOrField\",\n async validate(value: Date, context) {\n const { monthOrField, scope = \"global\" } = this.context.options;\n let compareMonth: number;\n\n if (typeof monthOrField === \"number\") {\n compareMonth = monthOrField;\n this.context.translatableParams.monthOrField = MONTHS[monthOrField];\n } else {\n const source = scope === \"sibling\" ? context.parent : context.allValues;\n const fieldValue = get(source, monthOrField);\n\n if (fieldValue === undefined) {\n return VALID_RULE;\n }\n\n this.context.translatableParams.monthOrField = monthOrField;\n\n // If field contains a date, extract the month\n if (fieldValue instanceof Date) {\n compareMonth = fieldValue.getMonth() + 1; // getMonth() returns 0-11\n } else if (typeof fieldValue === \"number\") {\n compareMonth = fieldValue;\n } else {\n // Try to parse as date and extract month\n const date = new Date(fieldValue);\n if (!isNaN(date.getTime())) {\n compareMonth = date.getMonth() + 1;\n } else {\n return VALID_RULE;\n }\n }\n }\n\n const inputDate = new Date(value);\n const inputMonth = inputDate.getMonth() + 1; // getMonth() returns 0-11\n\n if (inputMonth <= compareMonth) {\n return VALID_RULE;\n }\n\n return invalidRule(this, context);\n },\n};\n\n/**\n * Min day rule - day must be >= given day or field (1-31)\n * Smart detection: number or field name\n * Supports both global and sibling scope\n */\nexport const minDayRule: SchemaRule<{\n dayOrField: number | string;\n scope?: \"global\" | \"sibling\";\n}> = {\n name: \"minDay\",\n description: \"The date day must be at least the given day or field\",\n defaultErrorMessage: \"The :input day must be higher than :dayOrField\",\n async validate(value: Date, context) {\n const { dayOrField, scope = \"global\" } = this.context.options;\n let compareDay: number;\n\n if (typeof dayOrField === \"number\") {\n compareDay = dayOrField;\n this.context.translationParams.dayOrField = dayOrField;\n } else {\n const source = scope === \"sibling\" ? context.parent : context.allValues;\n const fieldValue = get(source, dayOrField);\n\n if (fieldValue === undefined) {\n return VALID_RULE;\n }\n\n this.context.translatableParams.dayOrField = dayOrField;\n\n // If field contains a date, extract the day\n if (fieldValue instanceof Date) {\n compareDay = fieldValue.getDate();\n } else if (typeof fieldValue === \"number\") {\n compareDay = fieldValue;\n } else {\n // Try to parse as date and extract day\n const date = new Date(fieldValue);\n if (!isNaN(date.getTime())) {\n compareDay = date.getDate();\n } else {\n return VALID_RULE;\n }\n }\n }\n\n const inputDate = new Date(value);\n const inputDay = inputDate.getDate();\n\n if (inputDay >= compareDay) {\n return VALID_RULE;\n }\n return invalidRule(this, context);\n },\n};\n\n/**\n * Max day rule - day must be <= given day or field (1-31)\n * Smart detection: number or field name\n * Supports both global and sibling scope\n */\nexport const maxDayRule: SchemaRule<{\n dayOrField: number | string;\n scope?: \"global\" | \"sibling\";\n}> = {\n name: \"maxDay\",\n description: \"The date day must be at most the given day or field\",\n defaultErrorMessage: \"The :input day must be at most :dayOrField\",\n async validate(value: Date, context) {\n const { dayOrField, scope = \"global\" } = this.context.options;\n let compareDay: number;\n\n if (typeof dayOrField === \"number\") {\n compareDay = dayOrField;\n this.context.translationParams.dayOrField = dayOrField;\n } else {\n const source = scope === \"sibling\" ? context.parent : context.allValues;\n const fieldValue = get(source, dayOrField);\n\n if (fieldValue === undefined) {\n return VALID_RULE;\n }\n\n this.context.translatableParams.dayOrField = dayOrField;\n\n // If field contains a date, extract the day\n if (fieldValue instanceof Date) {\n compareDay = fieldValue.getDate();\n } else if (typeof fieldValue === \"number\") {\n compareDay = fieldValue;\n } else {\n // Try to parse as date and extract day\n const date = new Date(fieldValue);\n if (!isNaN(date.getTime())) {\n compareDay = date.getDate();\n } else {\n return VALID_RULE;\n }\n }\n }\n\n const inputDate = new Date(value);\n const inputDay = inputDate.getDate();\n\n if (inputDay <= compareDay) {\n return VALID_RULE;\n }\n return invalidRule(this, context);\n },\n};\n"],"mappings":";;;;;AAIA,MAAM,SAAS;CACb,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,IAAI;CACJ,IAAI;CACJ,IAAI;AACN;;;;AAOA,MAAa,YAA0C;CACrD,MAAM;CACN,qBAAqB;CACrB,MAAM,SAAS,OAAa,SAAS;EAInC,IAFc,IADQ,KAAK,KACL,CAAC,CAAC,SAAS,IAAI,MAEvB,KAAK,QAAQ,QAAQ,OACjC,OAAO;EAGT,KAAK,QAAQ,mBAAmB,QAC9B,OAAO,KAAK,QAAQ,QAAQ;EAC9B,OAAO,YAAY,MAAM,OAAO;CAClC;AACF;;;;AAKA,MAAa,WAAyC;CACpD,MAAM;CACN,qBAAqB;CACrB,MAAM,SAAS,OAAa,SAAS;EAInC,IAFa,IADS,KAAK,KACN,CAAC,CAAC,YAEhB,MAAM,KAAK,QAAQ,QAAQ,MAChC,OAAO;EAGT,KAAK,QAAQ,kBAAkB,OAAO,KAAK,QA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Q,CAAC,GACvB,aAAa,KAAK,QAAQ;SAE1B,OAAO;GAEX;EACF;EAKA,IAFiB,IADK,KAAK,KACF,CAAC,CAAC,QAEhB,KAAK,YACd,OAAO;EAET,OAAO,YAAY,MAAM,OAAO;CAClC;AACF"}
|
|
1
|
+
{"version":3,"file":"date-period-rules.mjs","names":[],"sources":["../../../../../../../../../packages/seal/src/rules/date/date-period-rules.ts"],"sourcesContent":["import { get } from \"@mongez/reinforcements\";\nimport { invalidRule, VALID_RULE } from \"../../helpers\";\nimport type { SchemaRule } from \"../../types\";\n\nconst MONTHS = {\n 1: \"january\",\n 2: \"february\",\n 3: \"march\",\n 4: \"april\",\n 5: \"may\",\n 6: \"june\",\n 7: \"july\",\n 8: \"august\",\n 9: \"september\",\n 10: \"october\",\n 11: \"november\",\n 12: \"december\",\n};\n\nexport type Month = keyof typeof MONTHS;\n\n/**\n * Month rule - date must be in specific month (1-12)\n */\nexport const monthRule: SchemaRule<{ month: Month }> = {\n name: \"month\",\n defaultErrorMessage: \"The :input must be in month :month\",\n async validate(value: Date, context) {\n const inputDate = new Date(value);\n const month = inputDate.getMonth() + 1; // getMonth() returns 0-11\n\n if (month === this.context.options.month) {\n return VALID_RULE;\n }\n\n this.context.translatableParams.month =\n MONTHS[this.context.options.month as keyof typeof MONTHS];\n return invalidRule(this, context);\n },\n};\n\n/**\n * Year rule - date must be in specific year\n */\nexport const yearRule: SchemaRule<{ year: number }> = {\n name: \"year\",\n defaultErrorMessage: \"The :input must be in year :year\",\n async validate(value: Date, context) {\n const inputDate = new Date(value);\n const year = inputDate.getFullYear();\n\n if (year === this.context.options.year) {\n return VALID_RULE;\n }\n\n this.context.translationParams.year = this.context.options.year;\n return invalidRule(this, context);\n },\n};\n\n/**\n * Between years rule - date must be between start and end years\n * Supports field names with sibling scope\n */\nexport const betweenYearsRule: SchemaRule<{\n startYear: number | string;\n endYear: number | string;\n scope?: \"global\" | \"sibling\";\n}> = {\n name: \"betweenYears\",\n defaultErrorMessage: \"The :input must be between :startYear and :endYear\",\n async validate(value: Date, context) {\n const { startYear, endYear, scope = \"global\" } = this.context.options;\n const inputDate = new Date(value);\n const inputYear = inputDate.getFullYear();\n\n // Extract start year\n let compareStartYear: number;\n if (typeof startYear === \"number\") {\n compareStartYear = startYear;\n } else {\n const source = scope === \"sibling\" ? context.parent : context.allValues;\n const fieldValue = get(source, startYear);\n\n if (fieldValue === undefined) {\n return VALID_RULE;\n }\n\n if (fieldValue instanceof Date) {\n compareStartYear = fieldValue.getFullYear();\n } else if (typeof fieldValue === \"number\") {\n compareStartYear = fieldValue;\n } else {\n const date = new Date(fieldValue);\n if (!isNaN(date.getTime())) {\n compareStartYear = date.getFullYear();\n } else {\n return VALID_RULE;\n }\n }\n }\n\n // Extract end year\n let compareEndYear: number;\n if (typeof endYear === \"number\") {\n compareEndYear = endYear;\n } else {\n const source = scope === \"sibling\" ? context.parent : context.allValues;\n const fieldValue = get(source, endYear);\n\n if (fieldValue === undefined) {\n return VALID_RULE;\n }\n\n if (fieldValue instanceof Date) {\n compareEndYear = fieldValue.getFullYear();\n } else if (typeof fieldValue === \"number\") {\n compareEndYear = fieldValue;\n } else {\n const date = new Date(fieldValue);\n if (!isNaN(date.getTime())) {\n compareEndYear = date.getFullYear();\n } else {\n return VALID_RULE;\n }\n }\n }\n\n if (inputYear >= compareStartYear && inputYear <= compareEndYear) {\n return VALID_RULE;\n }\n\n this.context.translationParams.startYear = compareStartYear;\n this.context.translationParams.endYear = compareEndYear;\n return invalidRule(this, context);\n },\n};\n\n/**\n * Between months rule - date must be between start and end months (1-12)\n * Supports field names with sibling scope\n */\nexport const betweenMonthsRule: SchemaRule<{\n startMonth: Month | string;\n endMonth: Month | string;\n scope?: \"global\" | \"sibling\";\n}> = {\n name: \"betweenMonths\",\n defaultErrorMessage: \"The :input must be between month :startMonth and :endMonth\",\n async validate(value: Date, context) {\n const { startMonth, endMonth, scope = \"global\" } = this.context.options;\n const inputDate = new Date(value);\n const inputMonth = inputDate.getMonth() + 1; // getMonth() returns 0-11\n\n // Extract start month\n let compareStartMonth: number;\n if (typeof startMonth === \"number\") {\n compareStartMonth = startMonth;\n this.context.translatableParams.startMonth = MONTHS[compareStartMonth as keyof typeof MONTHS];\n } else {\n const source = scope === \"sibling\" ? context.parent : context.allValues;\n const fieldValue = get(source, startMonth);\n\n if (fieldValue === undefined) {\n return VALID_RULE;\n }\n\n this.context.translatableParams.startMonth = startMonth;\n\n if (fieldValue instanceof Date) {\n compareStartMonth = fieldValue.getMonth() + 1;\n } else if (typeof fieldValue === \"number\") {\n compareStartMonth = fieldValue;\n } else {\n const date = new Date(fieldValue);\n if (!isNaN(date.getTime())) {\n compareStartMonth = date.getMonth() + 1;\n } else {\n return VALID_RULE;\n }\n }\n }\n\n // Extract end month\n let compareEndMonth: number;\n if (typeof endMonth === \"number\") {\n compareEndMonth = endMonth;\n this.context.translatableParams.endMonth = MONTHS[compareEndMonth as keyof typeof MONTHS];\n } else {\n const source = scope === \"sibling\" ? context.parent : context.allValues;\n const fieldValue = get(source, endMonth);\n\n if (fieldValue === undefined) {\n return VALID_RULE;\n }\n\n this.context.translatableParams.endMonth = endMonth;\n\n if (fieldValue instanceof Date) {\n compareEndMonth = fieldValue.getMonth() + 1;\n } else if (typeof fieldValue === \"number\") {\n compareEndMonth = fieldValue;\n } else {\n const date = new Date(fieldValue);\n if (!isNaN(date.getTime())) {\n compareEndMonth = date.getMonth() + 1;\n } else {\n return VALID_RULE;\n }\n }\n }\n\n if (inputMonth >= compareStartMonth && inputMonth <= compareEndMonth) {\n return VALID_RULE;\n }\n\n return invalidRule(this, context);\n },\n};\n\n/**\n * Between days rule - date must be between start and end days (1-31)\n * Supports field names with sibling scope\n */\nexport const betweenDaysRule: SchemaRule<{\n startDay: number | string;\n endDay: number | string;\n scope?: \"global\" | \"sibling\";\n}> = {\n name: \"betweenDays\",\n defaultErrorMessage: \"The :input must be between day :startDay and :endDay\",\n async validate(value: Date, context) {\n const { startDay, endDay, scope = \"global\" } = this.context.options;\n const inputDate = new Date(value);\n const inputDay = inputDate.getDate();\n\n // Extract start day\n let compareStartDay: number;\n if (typeof startDay === \"number\") {\n compareStartDay = startDay;\n } else {\n const source = scope === \"sibling\" ? context.parent : context.allValues;\n const fieldValue = get(source, startDay);\n\n if (fieldValue === undefined) {\n return VALID_RULE;\n }\n\n if (fieldValue instanceof Date) {\n compareStartDay = fieldValue.getDate();\n } else if (typeof fieldValue === \"number\") {\n compareStartDay = fieldValue;\n } else {\n const date = new Date(fieldValue);\n if (!isNaN(date.getTime())) {\n compareStartDay = date.getDate();\n } else {\n return VALID_RULE;\n }\n }\n }\n\n // Extract end day\n let compareEndDay: number;\n if (typeof endDay === \"number\") {\n compareEndDay = endDay;\n } else {\n const source = scope === \"sibling\" ? context.parent : context.allValues;\n const fieldValue = get(source, endDay);\n\n if (fieldValue === undefined) {\n return VALID_RULE;\n }\n\n if (fieldValue instanceof Date) {\n compareEndDay = fieldValue.getDate();\n } else if (typeof fieldValue === \"number\") {\n compareEndDay = fieldValue;\n } else {\n const date = new Date(fieldValue);\n if (!isNaN(date.getTime())) {\n compareEndDay = date.getDate();\n } else {\n return VALID_RULE;\n }\n }\n }\n\n if (inputDay >= compareStartDay && inputDay <= compareEndDay) {\n return VALID_RULE;\n }\n\n this.context.translationParams.startDay = compareStartDay;\n this.context.translationParams.endDay = compareEndDay;\n return invalidRule(this, context);\n },\n};\n\n/**\n * Quarter rule - date must be in specific quarter (1-4)\n */\nexport const quarterRule: SchemaRule<{ quarter: 1 | 2 | 3 | 4 }> = {\n name: \"quarter\",\n defaultErrorMessage: \"The :input must be in quarter :quarter\",\n async validate(value: Date, context) {\n const inputDate = new Date(value);\n const month = inputDate.getMonth() + 1;\n const quarter = Math.ceil(month / 3);\n\n if (quarter === this.context.options.quarter) {\n return VALID_RULE;\n }\n\n this.context.translationParams.quarter = this.context.options.quarter;\n return invalidRule(this, context);\n },\n};\n\n/**\n * Between times rule - time must be between start and end times (HH:MM format)\n */\nexport const betweenTimesRule: SchemaRule<{\n startTime: string;\n endTime: string;\n}> = {\n name: \"betweenTimes\",\n defaultErrorMessage: \"The :input must be between :startTime and :endTime\",\n async validate(value: Date, context) {\n const inputDate = new Date(value);\n const inputHour = inputDate.getHours();\n const inputMinute = inputDate.getMinutes();\n const inputTimeInMinutes = inputHour * 60 + inputMinute;\n\n const { startTime, endTime } = this.context.options;\n\n // Parse start time\n const [startHour, startMinute] = startTime.split(\":\").map(Number);\n if (startHour === undefined || startMinute === undefined) {\n return invalidRule(this, context);\n }\n const startTimeInMinutes = startHour * 60 + startMinute;\n\n // Parse end time\n const [endHour, endMinute] = endTime.split(\":\").map(Number);\n if (endHour === undefined || endMinute === undefined) {\n return invalidRule(this, context);\n }\n const endTimeInMinutes = endHour * 60 + endMinute;\n\n if (inputTimeInMinutes >= startTimeInMinutes && inputTimeInMinutes <= endTimeInMinutes) {\n return VALID_RULE;\n }\n\n this.context.translationParams.startTime = startTime;\n this.context.translationParams.endTime = endTime;\n return invalidRule(this, context);\n },\n};\n\n/**\n * Min year rule - year must be >= given year or field\n * Smart detection: number or field name\n * Supports both global and sibling scope\n */\nexport const minYearRule: SchemaRule<{\n yearOrField: number | string;\n scope?: \"global\" | \"sibling\";\n}> = {\n name: \"minYear\",\n description: \"The date year must be at least the given year or field\",\n defaultErrorMessage: \"The :input year must be higher than :yearOrField\",\n async validate(value: Date, context) {\n const { yearOrField, scope = \"global\" } = this.context.options;\n let compareYear: number;\n\n if (typeof yearOrField === \"number\") {\n compareYear = yearOrField;\n this.context.translationParams.yearOrField = yearOrField;\n } else {\n const source = scope === \"sibling\" ? context.parent : context.allValues;\n const fieldValue = get(source, yearOrField);\n\n if (fieldValue === undefined) {\n return VALID_RULE;\n }\n\n this.context.translatableParams.yearOrField = yearOrField;\n\n // If field contains a date, extract the year\n if (fieldValue instanceof Date) {\n compareYear = fieldValue.getFullYear();\n } else if (typeof fieldValue === \"number\") {\n compareYear = fieldValue;\n } else {\n // Try to parse as date and extract year\n const date = new Date(fieldValue);\n if (!isNaN(date.getTime())) {\n compareYear = date.getFullYear();\n } else {\n return VALID_RULE;\n }\n }\n }\n\n const inputDate = new Date(value);\n const inputYear = inputDate.getFullYear();\n\n if (inputYear >= compareYear) {\n return VALID_RULE;\n }\n\n return invalidRule(this, context);\n },\n};\n\n/**\n * Max year rule - year must be <= given year or field\n * Smart detection: number or field name\n * Supports both global and sibling scope\n */\nexport const maxYearRule: SchemaRule<{\n yearOrField: number | string;\n scope?: \"global\" | \"sibling\";\n}> = {\n name: \"maxYear\",\n description: \"The date year must be at most the given year or field\",\n defaultErrorMessage: \"The :input year must be at most :yearOrField\",\n async validate(value: Date, context) {\n const { yearOrField, scope = \"global\" } = this.context.options;\n let compareYear: number;\n\n if (typeof yearOrField === \"number\") {\n compareYear = yearOrField;\n this.context.translationParams.yearOrField = compareYear;\n } else {\n const source = scope === \"sibling\" ? context.parent : context.allValues;\n const fieldValue = get(source, yearOrField);\n\n if (fieldValue === undefined) {\n return VALID_RULE;\n }\n\n this.context.translatableParams.yearOrField = yearOrField;\n\n // If field contains a date, extract the year\n if (fieldValue instanceof Date) {\n compareYear = fieldValue.getFullYear();\n } else if (typeof fieldValue === \"number\") {\n compareYear = fieldValue;\n } else {\n // Try to parse as date and extract year\n const date = new Date(fieldValue);\n if (!isNaN(date.getTime())) {\n compareYear = date.getFullYear();\n } else {\n return VALID_RULE;\n }\n }\n }\n\n const inputDate = new Date(value);\n const inputYear = inputDate.getFullYear();\n\n if (inputYear <= compareYear) {\n return VALID_RULE;\n }\n\n return invalidRule(this, context);\n },\n};\n\n/**\n * Min month rule - month must be >= given month or field (1-12)\n * Smart detection: number or field name\n * Supports both global and sibling scope\n */\nexport const minMonthRule: SchemaRule<{\n monthOrField: number | string;\n scope?: \"global\" | \"sibling\";\n}> = {\n name: \"minMonth\",\n description: \"The date month must be at least the given month or field\",\n defaultErrorMessage: \"The :input month must be at least :monthOrField\",\n async validate(value: Date, context) {\n const { monthOrField, scope = \"global\" } = this.context.options;\n let compareMonth: number;\n\n if (typeof monthOrField === \"number\") {\n compareMonth = monthOrField;\n this.context.translationParams.monthOrField = compareMonth;\n } else {\n const source = scope === \"sibling\" ? context.parent : context.allValues;\n const fieldValue = get(source, monthOrField);\n\n if (fieldValue === undefined) {\n return VALID_RULE;\n }\n\n this.context.translatableParams.monthOrField = monthOrField;\n\n // If field contains a date, extract the month\n if (fieldValue instanceof Date) {\n compareMonth = fieldValue.getMonth() + 1; // getMonth() returns 0-11\n } else if (typeof fieldValue === \"number\") {\n compareMonth = fieldValue;\n } else {\n // Try to parse as date and extract month\n const date = new Date(fieldValue);\n if (!isNaN(date.getTime())) {\n compareMonth = date.getMonth() + 1;\n } else {\n return VALID_RULE;\n }\n }\n }\n\n const inputDate = new Date(value);\n const inputMonth = inputDate.getMonth() + 1; // getMonth() returns 0-11\n\n if (inputMonth >= compareMonth) {\n return VALID_RULE;\n }\n return invalidRule(this, context);\n },\n};\n\n/**\n * Max month rule - month must be <= given month or field (1-12)\n * Smart detection: number or field name\n * Supports both global and sibling scope\n */\nexport const maxMonthRule: SchemaRule<{\n monthOrField: Month | string;\n scope?: \"global\" | \"sibling\";\n}> = {\n name: \"maxMonth\",\n description: \"The date month must be at most the given month or field\",\n defaultErrorMessage: \"The :input month must be at most :monthOrField\",\n async validate(value: Date, context) {\n const { monthOrField, scope = \"global\" } = this.context.options;\n let compareMonth: number;\n\n if (typeof monthOrField === \"number\") {\n compareMonth = monthOrField;\n this.context.translatableParams.monthOrField = MONTHS[monthOrField];\n } else {\n const source = scope === \"sibling\" ? context.parent : context.allValues;\n const fieldValue = get(source, monthOrField);\n\n if (fieldValue === undefined) {\n return VALID_RULE;\n }\n\n this.context.translatableParams.monthOrField = monthOrField;\n\n // If field contains a date, extract the month\n if (fieldValue instanceof Date) {\n compareMonth = fieldValue.getMonth() + 1; // getMonth() returns 0-11\n } else if (typeof fieldValue === \"number\") {\n compareMonth = fieldValue;\n } else {\n // Try to parse as date and extract month\n const date = new Date(fieldValue);\n if (!isNaN(date.getTime())) {\n compareMonth = date.getMonth() + 1;\n } else {\n return VALID_RULE;\n }\n }\n }\n\n const inputDate = new Date(value);\n const inputMonth = inputDate.getMonth() + 1; // getMonth() returns 0-11\n\n if (inputMonth <= compareMonth) {\n return VALID_RULE;\n }\n\n return invalidRule(this, context);\n },\n};\n\n/**\n * Min day rule - day must be >= given day or field (1-31)\n * Smart detection: number or field name\n * Supports both global and sibling scope\n */\nexport const minDayRule: SchemaRule<{\n dayOrField: number | string;\n scope?: \"global\" | \"sibling\";\n}> = {\n name: \"minDay\",\n description: \"The date day must be at least the given day or field\",\n defaultErrorMessage: \"The :input day must be higher than :dayOrField\",\n async validate(value: Date, context) {\n const { dayOrField, scope = \"global\" } = this.context.options;\n let compareDay: number;\n\n if (typeof dayOrField === \"number\") {\n compareDay = dayOrField;\n this.context.translationParams.dayOrField = dayOrField;\n } else {\n const source = scope === \"sibling\" ? context.parent : context.allValues;\n const fieldValue = get(source, dayOrField);\n\n if (fieldValue === undefined) {\n return VALID_RULE;\n }\n\n this.context.translatableParams.dayOrField = dayOrField;\n\n // If field contains a date, extract the day\n if (fieldValue instanceof Date) {\n compareDay = fieldValue.getDate();\n } else if (typeof fieldValue === \"number\") {\n compareDay = fieldValue;\n } else {\n // Try to parse as date and extract day\n const date = new Date(fieldValue);\n if (!isNaN(date.getTime())) {\n compareDay = date.getDate();\n } else {\n return VALID_RULE;\n }\n }\n }\n\n const inputDate = new Date(value);\n const inputDay = inputDate.getDate();\n\n if (inputDay >= compareDay) {\n return VALID_RULE;\n }\n return invalidRule(this, context);\n },\n};\n\n/**\n * Max day rule - day must be <= given day or field (1-31)\n * Smart detection: number or field name\n * Supports both global and sibling scope\n */\nexport const maxDayRule: SchemaRule<{\n dayOrField: number | string;\n scope?: \"global\" | \"sibling\";\n}> = {\n name: \"maxDay\",\n description: \"The date day must be at most the given day or field\",\n defaultErrorMessage: \"The :input day must be at most :dayOrField\",\n async validate(value: Date, context) {\n const { dayOrField, scope = \"global\" } = this.context.options;\n let compareDay: number;\n\n if (typeof dayOrField === \"number\") {\n compareDay = dayOrField;\n this.context.translationParams.dayOrField = dayOrField;\n } else {\n const source = scope === \"sibling\" ? context.parent : context.allValues;\n const fieldValue = get(source, dayOrField);\n\n if (fieldValue === undefined) {\n return VALID_RULE;\n }\n\n this.context.translatableParams.dayOrField = dayOrField;\n\n // If field contains a date, extract the day\n if (fieldValue instanceof Date) {\n compareDay = fieldValue.getDate();\n } else if (typeof fieldValue === \"number\") {\n compareDay = fieldValue;\n } else {\n // Try to parse as date and extract day\n const date = new Date(fieldValue);\n if (!isNaN(date.getTime())) {\n compareDay = date.getDate();\n } else {\n return VALID_RULE;\n }\n }\n }\n\n const inputDate = new Date(value);\n const inputDay = inputDate.getDate();\n\n if (inputDay <= compareDay) {\n return VALID_RULE;\n }\n return invalidRule(this, context);\n },\n};\n"],"mappings":";;;;;AAIA,MAAM,SAAS;CACb,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,IAAI;CACJ,IAAI;CACJ,IAAI;AACN;;;;AAOA,MAAa,YAA0C;CACrD,MAAM;CACN,qBAAqB;CACrB,MAAM,SAAS,OAAa,SAAS;EAInC,IAFc,IADQ,KAAK,KACL,CAAC,CAAC,SAAS,IAAI,MAEvB,KAAK,QAAQ,QAAQ,OACjC,OAAO;EAGT,KAAK,QAAQ,mBAAmB,QAC9B,OAAO,KAAK,QAAQ,QAAQ;EAC9B,OAAO,YAAY,MAAM,OAAO;CAClC;AACF;;;;AAKA,MAAa,WAAyC;CACpD,MAAM;CACN,qBAAqB;CACrB,MAAM,SAAS,OAAa,SAAS;EAInC,IAFa,IADS,KAAK,KACN,CAAC,CAAC,YAEhB,MAAM,KAAK,QAAQ,QAAQ,MAChC,OAAO;EAGT,KAAK,QAAQ,kBAAkB,OAAO,KAAK,QAAQ,QAAQ;EAC3D,OAAO,YAAY,MAAM,OA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,mBAAmB,aAAa;GAG7C,IAAI,sBAAsB,MACxB,aAAa,WAAW,QAAQ;QAC3B,IAAI,OAAO,eAAe,UAC/B,aAAa;QACR;IAEL,MAAM,OAAO,IAAI,KAAK,UAAU;IAChC,IAAI,CAAC,MAAM,KAAK,QAAQ,CAAC,GACvB,aAAa,KAAK,QAAQ;SAE1B,OAAO;GAEX;EACF;EAKA,IAFiB,IADK,KAAK,KACF,CAAC,CAAC,QAEhB,KAAK,YACd,OAAO;EAET,OAAO,YAAY,MAAM,OAAO;CAClC;AACF"}
|
|
@@ -1,24 +1,23 @@
|
|
|
1
1
|
import { SchemaRule } from "../../types/rule-types.mjs";
|
|
2
|
-
|
|
2
|
+
import "../../types/index.mjs";
|
|
3
3
|
//#region ../../packages/seal/src/rules/date/date-relative-rules.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* Within days rule - date must be within X days from now (past or future)
|
|
6
6
|
*/
|
|
7
|
-
declare const withinDaysRule: SchemaRule<{
|
|
7
|
+
export declare const withinDaysRule: SchemaRule<{
|
|
8
8
|
days: number;
|
|
9
9
|
}>;
|
|
10
10
|
/**
|
|
11
11
|
* Within past days rule - date must be within X days in the past
|
|
12
12
|
*/
|
|
13
|
-
declare const withinPastDaysRule: SchemaRule<{
|
|
13
|
+
export declare const withinPastDaysRule: SchemaRule<{
|
|
14
14
|
days: number;
|
|
15
15
|
}>;
|
|
16
16
|
/**
|
|
17
17
|
* Within future days rule - date must be within X days in the future
|
|
18
18
|
*/
|
|
19
|
-
declare const withinFutureDaysRule: SchemaRule<{
|
|
19
|
+
export declare const withinFutureDaysRule: SchemaRule<{
|
|
20
20
|
days: number;
|
|
21
21
|
}>;
|
|
22
22
|
//#endregion
|
|
23
|
-
export { withinDaysRule, withinFutureDaysRule, withinPastDaysRule };
|
|
24
23
|
//# sourceMappingURL=date-relative-rules.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"date-relative-rules.d.mts","names":[],"sources":["../../../../../../../../../packages/seal/src/rules/date/date-relative-rules.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"date-relative-rules.d.mts","names":[],"sources":["../../../../../../../../../packages/seal/src/rules/date/date-relative-rules.ts"],"mappings":";;;;;;qBAMa,gBAAgB;EAAa;;;;;qBAsB7B,oBAAoB;EAAa;;;;;qBA2BjC,sBAAsB;EAAa"}
|
|
@@ -12,7 +12,7 @@ const withinDaysRule = {
|
|
|
12
12
|
const now = /* @__PURE__ */ new Date();
|
|
13
13
|
const inputDate = new Date(value);
|
|
14
14
|
const diffTime = Math.abs(inputDate.getTime() - now.getTime());
|
|
15
|
-
if (Math.ceil(diffTime /
|
|
15
|
+
if (Math.ceil(diffTime / 864e5) <= this.context.options.days) return VALID_RULE;
|
|
16
16
|
this.context.translationParams.days = this.context.options.days;
|
|
17
17
|
return invalidRule(this, context);
|
|
18
18
|
}
|
|
@@ -28,7 +28,7 @@ const withinPastDaysRule = {
|
|
|
28
28
|
const inputDate = new Date(value);
|
|
29
29
|
if (inputDate > now) return invalidRule(this, context);
|
|
30
30
|
const diffTime = now.getTime() - inputDate.getTime();
|
|
31
|
-
if (Math.ceil(diffTime /
|
|
31
|
+
if (Math.ceil(diffTime / 864e5) <= this.context.options.days) return VALID_RULE;
|
|
32
32
|
this.context.translationParams.days = this.context.options.days;
|
|
33
33
|
return invalidRule(this, context);
|
|
34
34
|
}
|
|
@@ -44,7 +44,7 @@ const withinFutureDaysRule = {
|
|
|
44
44
|
const inputDate = new Date(value);
|
|
45
45
|
if (inputDate < now) return invalidRule(this, context);
|
|
46
46
|
const diffTime = inputDate.getTime() - now.getTime();
|
|
47
|
-
if (Math.ceil(diffTime /
|
|
47
|
+
if (Math.ceil(diffTime / 864e5) <= this.context.options.days) return VALID_RULE;
|
|
48
48
|
this.context.translationParams.days = this.context.options.days;
|
|
49
49
|
return invalidRule(this, context);
|
|
50
50
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"date-relative-rules.mjs","names":[],"sources":["../../../../../../../../../packages/seal/src/rules/date/date-relative-rules.ts"],"sourcesContent":["import { invalidRule, VALID_RULE } from \"../../helpers\";\nimport type { SchemaRule } from \"../../types\";\n\n/**\n * Within days rule - date must be within X days from now (past or future)\n */\nexport const withinDaysRule: SchemaRule<{ days: number }> = {\n name: \"withinDays\",\n defaultErrorMessage: \"The :input must be within :days days from now\",\n async validate(value: Date, context) {\n const now = new Date();\n const inputDate = new Date(value);\n const diffTime = Math.abs(inputDate.getTime() - now.getTime());\n const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24));\n\n if (diffDays <= this.context.options.days) {\n return VALID_RULE;\n }\n\n this.context.translationParams.days = this.context.options.days;\n\n return invalidRule(this, context);\n },\n};\n\n/**\n * Within past days rule - date must be within X days in the past\n */\nexport const withinPastDaysRule: SchemaRule<{ days: number }> = {\n name: \"withinPastDays\",\n defaultErrorMessage: \"The :input must be within the past :days days\",\n async validate(value: Date, context) {\n const now = new Date();\n const inputDate = new Date(value);\n\n if (inputDate > now) {\n return invalidRule(this, context); // Must be in past\n }\n\n const diffTime = now.getTime() - inputDate.getTime();\n const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24));\n\n if (diffDays <= this.context.options.days) {\n return VALID_RULE;\n }\n\n this.context.translationParams.days = this.context.options.days;\n\n return invalidRule(this, context);\n },\n};\n\n/**\n * Within future days rule - date must be within X days in the future\n */\nexport const withinFutureDaysRule: SchemaRule<{ days: number }> = {\n name: \"withinFutureDays\",\n defaultErrorMessage: \"The :input must be within the next :days days\",\n async validate(value: Date, context) {\n const now = new Date();\n const inputDate = new Date(value);\n\n if (inputDate < now) {\n return invalidRule(this, context); // Must be in future\n }\n\n const diffTime = inputDate.getTime() - now.getTime();\n const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24));\n\n if (diffDays <= this.context.options.days) {\n return VALID_RULE;\n }\n\n this.context.translationParams.days = this.context.options.days;\n\n return invalidRule(this, context);\n },\n};\n"],"mappings":";;;;;;;AAMA,MAAa,iBAA+C;CAC1D,MAAM;CACN,qBAAqB;CACrB,MAAM,SAAS,OAAa,SAAS;EACnC,MAAM,sBAAM,IAAI,KAAK;EACrB,MAAM,YAAY,IAAI,KAAK,KAAK;EAChC,MAAM,WAAW,KAAK,IAAI,UAAU,QAAQ,IAAI,IAAI,QAAQ,CAAC;EAG7D,IAFiB,KAAK,KAAK,
|
|
1
|
+
{"version":3,"file":"date-relative-rules.mjs","names":[],"sources":["../../../../../../../../../packages/seal/src/rules/date/date-relative-rules.ts"],"sourcesContent":["import { invalidRule, VALID_RULE } from \"../../helpers\";\nimport type { SchemaRule } from \"../../types\";\n\n/**\n * Within days rule - date must be within X days from now (past or future)\n */\nexport const withinDaysRule: SchemaRule<{ days: number }> = {\n name: \"withinDays\",\n defaultErrorMessage: \"The :input must be within :days days from now\",\n async validate(value: Date, context) {\n const now = new Date();\n const inputDate = new Date(value);\n const diffTime = Math.abs(inputDate.getTime() - now.getTime());\n const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24));\n\n if (diffDays <= this.context.options.days) {\n return VALID_RULE;\n }\n\n this.context.translationParams.days = this.context.options.days;\n\n return invalidRule(this, context);\n },\n};\n\n/**\n * Within past days rule - date must be within X days in the past\n */\nexport const withinPastDaysRule: SchemaRule<{ days: number }> = {\n name: \"withinPastDays\",\n defaultErrorMessage: \"The :input must be within the past :days days\",\n async validate(value: Date, context) {\n const now = new Date();\n const inputDate = new Date(value);\n\n if (inputDate > now) {\n return invalidRule(this, context); // Must be in past\n }\n\n const diffTime = now.getTime() - inputDate.getTime();\n const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24));\n\n if (diffDays <= this.context.options.days) {\n return VALID_RULE;\n }\n\n this.context.translationParams.days = this.context.options.days;\n\n return invalidRule(this, context);\n },\n};\n\n/**\n * Within future days rule - date must be within X days in the future\n */\nexport const withinFutureDaysRule: SchemaRule<{ days: number }> = {\n name: \"withinFutureDays\",\n defaultErrorMessage: \"The :input must be within the next :days days\",\n async validate(value: Date, context) {\n const now = new Date();\n const inputDate = new Date(value);\n\n if (inputDate < now) {\n return invalidRule(this, context); // Must be in future\n }\n\n const diffTime = inputDate.getTime() - now.getTime();\n const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24));\n\n if (diffDays <= this.context.options.days) {\n return VALID_RULE;\n }\n\n this.context.translationParams.days = this.context.options.days;\n\n return invalidRule(this, context);\n },\n};\n"],"mappings":";;;;;;;AAMA,MAAa,iBAA+C;CAC1D,MAAM;CACN,qBAAqB;CACrB,MAAM,SAAS,OAAa,SAAS;EACnC,MAAM,sBAAM,IAAI,KAAK;EACrB,MAAM,YAAY,IAAI,KAAK,KAAK;EAChC,MAAM,WAAW,KAAK,IAAI,UAAU,QAAQ,IAAI,IAAI,QAAQ,CAAC;EAG7D,IAFiB,KAAK,KAAK,WAAY,KAE5B,KAAK,KAAK,QAAQ,QAAQ,MACnC,OAAO;EAGT,KAAK,QAAQ,kBAAkB,OAAO,KAAK,QAAQ,QAAQ;EAE3D,OAAO,YAAY,MAAM,OAAO;CAClC;AACF;;;;AAKA,MAAa,qBAAmD;CAC9D,MAAM;CACN,qBAAqB;CACrB,MAAM,SAAS,OAAa,SAAS;EACnC,MAAM,sBAAM,IAAI,KAAK;EACrB,MAAM,YAAY,IAAI,KAAK,KAAK;EAEhC,IAAI,YAAY,KACd,OAAO,YAAY,MAAM,OAAO;EAGlC,MAAM,WAAW,IAAI,QAAQ,IAAI,UAAU,QAAQ;EAGnD,IAFiB,KAAK,KAAK,WAAY,KAE5B,KAAK,KAAK,QAAQ,QAAQ,MACnC,OAAO;EAGT,KAAK,QAAQ,kBAAkB,OAAO,KAAK,QAAQ,QAAQ;EAE3D,OAAO,YAAY,MAAM,OAAO;CAClC;AACF;;;;AAKA,MAAa,uBAAqD;CAChE,MAAM;CACN,qBAAqB;CACrB,MAAM,SAAS,OAAa,SAAS;EACnC,MAAM,sBAAM,IAAI,KAAK;EACrB,MAAM,YAAY,IAAI,KAAK,KAAK;EAEhC,IAAI,YAAY,KACd,OAAO,YAAY,MAAM,OAAO;EAGlC,MAAM,WAAW,UAAU,QAAQ,IAAI,IAAI,QAAQ;EAGnD,IAFiB,KAAK,KAAK,WAAY,KAE5B,KAAK,KAAK,QAAQ,QAAQ,MACnC,OAAO;EAGT,KAAK,QAAQ,kBAAkB,OAAO,KAAK,QAAQ,QAAQ;EAE3D,OAAO,YAAY,MAAM,OAAO;CAClC;AACF"}
|
|
@@ -1,24 +1,23 @@
|
|
|
1
1
|
import { SchemaRule } from "../../types/rule-types.mjs";
|
|
2
|
-
|
|
2
|
+
import "../../types/index.mjs";
|
|
3
3
|
//#region ../../packages/seal/src/rules/date/date-special-rules.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* Birthday rule - valid birthday (not in future, reasonable age)
|
|
6
6
|
*/
|
|
7
|
-
declare const birthdayRule: SchemaRule<{
|
|
7
|
+
export declare const birthdayRule: SchemaRule<{
|
|
8
8
|
minAge?: number;
|
|
9
9
|
maxAge?: number;
|
|
10
10
|
}>;
|
|
11
11
|
/**
|
|
12
12
|
* Between age rule - age must be between min and max years
|
|
13
13
|
*/
|
|
14
|
-
declare const betweenAgeRule: SchemaRule<{
|
|
14
|
+
export declare const betweenAgeRule: SchemaRule<{
|
|
15
15
|
minAge: number;
|
|
16
16
|
maxAge: number;
|
|
17
17
|
}>;
|
|
18
18
|
/**
|
|
19
19
|
* Leap year rule - date must be in a leap year
|
|
20
20
|
*/
|
|
21
|
-
declare const leapYearRule: SchemaRule;
|
|
21
|
+
export declare const leapYearRule: SchemaRule;
|
|
22
22
|
//#endregion
|
|
23
|
-
export { betweenAgeRule, birthdayRule, leapYearRule };
|
|
24
23
|
//# sourceMappingURL=date-special-rules.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"date-special-rules.d.mts","names":[],"sources":["../../../../../../../../../packages/seal/src/rules/date/date-special-rules.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"date-special-rules.d.mts","names":[],"sources":["../../../../../../../../../packages/seal/src/rules/date/date-special-rules.ts"],"mappings":";;;;;;qBAMa,cAAc;EAAa;EAAiB;;;;;qBAsC5C,gBAAgB;EAAa;EAAgB;;;;;qBA6B7C,cAAc"}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { SchemaRule } from "../../types/rule-types.mjs";
|
|
2
2
|
import { WeekDay } from "../../types/date-types.mjs";
|
|
3
|
-
|
|
3
|
+
import "../../types/index.mjs";
|
|
4
4
|
//#region ../../packages/seal/src/rules/date/date.d.ts
|
|
5
5
|
/**
|
|
6
6
|
* Date rule - validates date format
|
|
7
7
|
*/
|
|
8
|
-
declare const dateRule: SchemaRule;
|
|
8
|
+
export declare const dateRule: SchemaRule;
|
|
9
9
|
/**
|
|
10
10
|
* Min date rule - date must be >= given date or field
|
|
11
11
|
* Smart detection: date value or field name
|
|
12
12
|
*/
|
|
13
|
-
declare const minDateRule: SchemaRule<{
|
|
13
|
+
export declare const minDateRule: SchemaRule<{
|
|
14
14
|
dateOrField: Date | string | number;
|
|
15
15
|
scope?: "global" | "sibling";
|
|
16
16
|
}>;
|
|
@@ -18,80 +18,79 @@ declare const minDateRule: SchemaRule<{
|
|
|
18
18
|
* Max date rule - date must be <= given date or field
|
|
19
19
|
* Smart detection: date value or field name
|
|
20
20
|
*/
|
|
21
|
-
declare const maxDateRule: SchemaRule<{
|
|
21
|
+
export declare const maxDateRule: SchemaRule<{
|
|
22
22
|
dateOrField: Date | string | number;
|
|
23
23
|
scope?: "global" | "sibling";
|
|
24
24
|
}>;
|
|
25
25
|
/**
|
|
26
26
|
* From today rule - date must be today or in the future
|
|
27
27
|
*/
|
|
28
|
-
declare const fromTodayRule: SchemaRule;
|
|
28
|
+
export declare const fromTodayRule: SchemaRule;
|
|
29
29
|
/**
|
|
30
30
|
* Before today rule - date must be before today
|
|
31
31
|
*/
|
|
32
|
-
declare const beforeTodayRule: SchemaRule;
|
|
32
|
+
export declare const beforeTodayRule: SchemaRule;
|
|
33
33
|
/**
|
|
34
34
|
* From hour rule - time must be from specific hour onwards
|
|
35
35
|
*/
|
|
36
|
-
declare const fromHourRule: SchemaRule<{
|
|
36
|
+
export declare const fromHourRule: SchemaRule<{
|
|
37
37
|
hour: number;
|
|
38
38
|
}>;
|
|
39
39
|
/**
|
|
40
40
|
* Before hour rule - time must be before specific hour
|
|
41
41
|
*/
|
|
42
|
-
declare const beforeHourRule: SchemaRule<{
|
|
42
|
+
export declare const beforeHourRule: SchemaRule<{
|
|
43
43
|
hour: number;
|
|
44
44
|
}>;
|
|
45
45
|
/**
|
|
46
46
|
* Between hours rule - time must be between start and end hours
|
|
47
47
|
*/
|
|
48
|
-
declare const betweenHoursRule: SchemaRule<{
|
|
48
|
+
export declare const betweenHoursRule: SchemaRule<{
|
|
49
49
|
startHour: number;
|
|
50
50
|
endHour: number;
|
|
51
51
|
}>;
|
|
52
52
|
/**
|
|
53
53
|
* From minute rule - time must be from specific minute onwards
|
|
54
54
|
*/
|
|
55
|
-
declare const fromMinuteRule: SchemaRule<{
|
|
55
|
+
export declare const fromMinuteRule: SchemaRule<{
|
|
56
56
|
minute: number;
|
|
57
57
|
}>;
|
|
58
58
|
/**
|
|
59
59
|
* Before minute rule - time must be before specific minute
|
|
60
60
|
*/
|
|
61
|
-
declare const beforeMinuteRule: SchemaRule<{
|
|
61
|
+
export declare const beforeMinuteRule: SchemaRule<{
|
|
62
62
|
minute: number;
|
|
63
63
|
}>;
|
|
64
64
|
/**
|
|
65
65
|
* Between minutes rule - time must be between start and end minutes
|
|
66
66
|
*/
|
|
67
|
-
declare const betweenMinutesRule: SchemaRule<{
|
|
67
|
+
export declare const betweenMinutesRule: SchemaRule<{
|
|
68
68
|
startMinute: number;
|
|
69
69
|
endMinute: number;
|
|
70
70
|
}>;
|
|
71
71
|
/**
|
|
72
72
|
* Age rule - calculate age from date
|
|
73
73
|
*/
|
|
74
|
-
declare const ageRule: SchemaRule<{
|
|
74
|
+
export declare const ageRule: SchemaRule<{
|
|
75
75
|
years: number;
|
|
76
76
|
}>;
|
|
77
77
|
/**
|
|
78
78
|
* Min age rule - minimum age requirement
|
|
79
79
|
*/
|
|
80
|
-
declare const minAgeRule: SchemaRule<{
|
|
80
|
+
export declare const minAgeRule: SchemaRule<{
|
|
81
81
|
years: number;
|
|
82
82
|
}>;
|
|
83
83
|
/**
|
|
84
84
|
* Max age rule - maximum age requirement
|
|
85
85
|
*/
|
|
86
|
-
declare const maxAgeRule: SchemaRule<{
|
|
86
|
+
export declare const maxAgeRule: SchemaRule<{
|
|
87
87
|
years: number;
|
|
88
88
|
}>;
|
|
89
89
|
/**
|
|
90
90
|
* Week day rule - date must be specific weekday
|
|
91
91
|
*/
|
|
92
|
-
declare const weekDayRule: SchemaRule<{
|
|
92
|
+
export declare const weekDayRule: SchemaRule<{
|
|
93
93
|
day: WeekDay;
|
|
94
94
|
}>;
|
|
95
95
|
//#endregion
|
|
96
|
-
export { ageRule, beforeHourRule, beforeMinuteRule, beforeTodayRule, betweenHoursRule, betweenMinutesRule, dateRule, fromHourRule, fromMinuteRule, fromTodayRule, maxAgeRule, maxDateRule, minAgeRule, minDateRule, weekDayRule };
|
|
97
96
|
//# sourceMappingURL=date.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"date.d.mts","names":[],"sources":["../../../../../../../../../packages/seal/src/rules/date/date.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"date.d.mts","names":[],"sources":["../../../../../../../../../packages/seal/src/rules/date/date.ts"],"mappings":";;;;;;;qBAUa,UAAU;;;;;qBAgBV,aAAa;EACxB,aAAa;EACb;;;;;;qBAqCW,aAAa;EACxB,aAAa;EACb;;;;;qBAmCW,eAAe;;;;qBAmBf,iBAAiB;;;;qBAmBjB,cAAc;EAAa;;;;;qBAmB3B,gBAAgB;EAAa;;;;;qBAmB7B,kBAAkB;EAC7B;EACA;;;;;qBAsBW,gBAAgB;EAAa;;;;;qBAoB7B,kBAAkB;EAAa;;;;;qBAoB/B,oBAAoB;EAC/B;EACA;;;;;qBAuBW,SAAS;EAAa;;;;;qBA0BtB,YAAY;EAAa;;;;;qBA0BzB,YAAY;EAAa;;;;;qBA0BzB,aAAa;EAAa,KAAK"}
|
package/esm/rules/date/date.mjs
CHANGED
|
@@ -29,7 +29,8 @@ const minDateRule = {
|
|
|
29
29
|
let compareDate;
|
|
30
30
|
if (isDateValue(dateOrField)) compareDate = new Date(dateOrField);
|
|
31
31
|
else {
|
|
32
|
-
const
|
|
32
|
+
const source = scope === "sibling" ? context.parent : context.allValues;
|
|
33
|
+
const fieldValue = get(source, dateOrField);
|
|
33
34
|
if (fieldValue === void 0) return VALID_RULE;
|
|
34
35
|
compareDate = new Date(fieldValue);
|
|
35
36
|
}
|
|
@@ -49,7 +50,8 @@ const maxDateRule = {
|
|
|
49
50
|
let compareDate;
|
|
50
51
|
if (isDateValue(dateOrField)) compareDate = new Date(dateOrField);
|
|
51
52
|
else {
|
|
52
|
-
const
|
|
53
|
+
const source = scope === "sibling" ? context.parent : context.allValues;
|
|
54
|
+
const fieldValue = get(source, dateOrField);
|
|
53
55
|
if (fieldValue === void 0) return VALID_RULE;
|
|
54
56
|
compareDate = new Date(fieldValue);
|
|
55
57
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"date.mjs","names":[],"sources":["../../../../../../../../../packages/seal/src/rules/date/date.ts"],"sourcesContent":["import { get } from \"@mongez/reinforcements\";\nimport { invalidRule, VALID_RULE } from \"../../helpers\";\nimport { isDateValue } from \"../../helpers/date-helpers\";\nimport type { SchemaRule } from \"../../types\";\nimport type { WeekDay } from \"../../types/date-types\";\nimport { WEEK_DAYS } from \"../../types/date-types\";\n\n/**\n * Date rule - validates date format\n */\nexport const dateRule: SchemaRule = {\n name: \"date\",\n defaultErrorMessage: \"The :input must be a valid date\",\n async validate(value: any, context) {\n if (value instanceof Date && !isNaN(value.getTime())) {\n return VALID_RULE;\n }\n\n return invalidRule(this, context);\n },\n};\n\n/**\n * Min date rule - date must be >= given date or field\n * Smart detection: date value or field name\n */\nexport const minDateRule: SchemaRule<{\n dateOrField: Date | string | number;\n scope?: \"global\" | \"sibling\";\n}> = {\n name: \"minDate\",\n description: \"The field must be at least the given date or field\",\n defaultErrorMessage: \"The :input must be at least :dateOrField\",\n async validate(value: Date, context) {\n const { dateOrField, scope = \"global\" } = this.context.options;\n let compareDate: Date;\n\n if (isDateValue(dateOrField)) {\n // Value comparison\n compareDate = new Date(dateOrField);\n } else {\n // Field comparison\n const source = scope === \"sibling\" ? context.parent : context.allValues;\n const fieldValue = get(source, dateOrField as string);\n\n if (fieldValue === undefined) {\n return VALID_RULE;\n }\n\n compareDate = new Date(fieldValue);\n }\n\n const inputDate = new Date(value);\n\n if (inputDate >= compareDate) {\n return VALID_RULE;\n }\n return invalidRule(this, context);\n },\n};\n\n/**\n * Max date rule - date must be <= given date or field\n * Smart detection: date value or field name\n */\nexport const maxDateRule: SchemaRule<{\n dateOrField: Date | string | number;\n scope?: \"global\" | \"sibling\";\n}> = {\n name: \"maxDate\",\n defaultErrorMessage: \"The :input must be at most :dateOrField\",\n async validate(value: Date, context) {\n const { dateOrField, scope = \"global\" } = this.context.options;\n let compareDate: Date;\n\n if (isDateValue(dateOrField)) {\n // Value comparison\n compareDate = new Date(dateOrField);\n } else {\n // Field comparison\n const source = scope === \"sibling\" ? context.parent : context.allValues;\n const fieldValue = get(source, dateOrField as string);\n\n if (fieldValue === undefined) {\n return VALID_RULE;\n }\n\n compareDate = new Date(fieldValue);\n }\n\n const inputDate = new Date(value);\n\n if (inputDate <= compareDate) {\n return VALID_RULE;\n }\n return invalidRule(this, context);\n },\n};\n\n/**\n * From today rule - date must be today or in the future\n */\nexport const fromTodayRule: SchemaRule = {\n name: \"fromToday\",\n defaultErrorMessage: \"The :input must be today or in the future\",\n async validate(value: Date, context) {\n const today = new Date();\n today.setHours(0, 0, 0, 0);\n const inputDate = new Date(value);\n inputDate.setHours(0, 0, 0, 0);\n\n if (inputDate >= today) {\n return VALID_RULE;\n }\n return invalidRule(this, context);\n },\n};\n\n/**\n * Before today rule - date must be before today\n */\nexport const beforeTodayRule: SchemaRule = {\n name: \"beforeToday\",\n defaultErrorMessage: \"The :input must be before today\",\n async validate(value: Date, context) {\n const today = new Date();\n today.setHours(0, 0, 0, 0);\n const inputDate = new Date(value);\n inputDate.setHours(0, 0, 0, 0);\n\n if (inputDate < today) {\n return VALID_RULE;\n }\n return invalidRule(this, context);\n },\n};\n\n/**\n * From hour rule - time must be from specific hour onwards\n */\nexport const fromHourRule: SchemaRule<{ hour: number }> = {\n name: \"fromHour\",\n defaultErrorMessage: \"The :input must be from :hour:00 onwards\",\n async validate(value: Date, context) {\n const inputDate = new Date(value);\n const hour = inputDate.getHours();\n\n if (hour >= this.context.options.hour) {\n return VALID_RULE;\n }\n\n this.context.translationParams.hour = this.context.options.hour;\n return invalidRule(this, context);\n },\n};\n\n/**\n * Before hour rule - time must be before specific hour\n */\nexport const beforeHourRule: SchemaRule<{ hour: number }> = {\n name: \"beforeHour\",\n defaultErrorMessage: \"The :input must be before :hour:00\",\n async validate(value: Date, context) {\n const inputDate = new Date(value);\n const hour = inputDate.getHours();\n\n if (hour < this.context.options.hour) {\n return VALID_RULE;\n }\n\n this.context.translationParams.hour = this.context.options.hour;\n return invalidRule(this, context);\n },\n};\n\n/**\n * Between hours rule - time must be between start and end hours\n */\nexport const betweenHoursRule: SchemaRule<{\n startHour: number;\n endHour: number;\n}> = {\n name: \"betweenHours\",\n defaultErrorMessage: \"The :input must be between :startHour:00 and :endHour:00\",\n async validate(value: Date, context) {\n const inputDate = new Date(value);\n const hour = inputDate.getHours();\n const { startHour, endHour } = this.context.options;\n\n if (hour >= startHour && hour <= endHour) {\n return VALID_RULE;\n }\n\n this.context.translationParams.startHour = startHour;\n this.context.translationParams.endHour = endHour;\n return invalidRule(this, context);\n },\n};\n\n/**\n * From minute rule - time must be from specific minute onwards\n */\nexport const fromMinuteRule: SchemaRule<{ minute: number }> = {\n name: \"fromMinute\",\n defaultErrorMessage: \"The :input must be from minute :minute onwards\",\n async validate(value: Date, context) {\n const inputDate = new Date(value);\n const minute = inputDate.getMinutes();\n\n if (minute >= this.context.options.minute) {\n return VALID_RULE;\n }\n\n this.context.translationParams.minute = this.context.options.minute;\n\n return invalidRule(this, context);\n },\n};\n\n/**\n * Before minute rule - time must be before specific minute\n */\nexport const beforeMinuteRule: SchemaRule<{ minute: number }> = {\n name: \"beforeMinute\",\n defaultErrorMessage: \"The :input must be before minute :minute\",\n async validate(value: Date, context) {\n const inputDate = new Date(value);\n const minute = inputDate.getMinutes();\n\n if (minute < this.context.options.minute) {\n return VALID_RULE;\n }\n\n this.context.translationParams.minute = this.context.options.minute;\n\n return invalidRule(this, context);\n },\n};\n\n/**\n * Between minutes rule - time must be between start and end minutes\n */\nexport const betweenMinutesRule: SchemaRule<{\n startMinute: number;\n endMinute: number;\n}> = {\n name: \"betweenMinutes\",\n defaultErrorMessage: \"The :input must be between minute :startMinute and :endMinute\",\n async validate(value: Date, context) {\n const inputDate = new Date(value);\n const minute = inputDate.getMinutes();\n const { startMinute, endMinute } = this.context.options;\n\n if (minute >= startMinute && minute <= endMinute) {\n return VALID_RULE;\n }\n\n this.context.translationParams.startMinute = startMinute;\n this.context.translationParams.endMinute = endMinute;\n\n return invalidRule(this, context);\n },\n};\n\n/**\n * Age rule - calculate age from date\n */\nexport const ageRule: SchemaRule<{ years: number }> = {\n name: \"age\",\n defaultErrorMessage: \"The :input must be exactly :years years old\",\n async validate(value: Date, context) {\n const birthDate = new Date(value);\n const today = new Date();\n let age = today.getFullYear() - birthDate.getFullYear();\n const monthDiff = today.getMonth() - birthDate.getMonth();\n\n if (monthDiff < 0 || (monthDiff === 0 && today.getDate() < birthDate.getDate())) {\n age--;\n }\n\n if (age === this.context.options.years) {\n return VALID_RULE;\n }\n\n this.context.translationParams.years = this.context.options.years;\n\n return invalidRule(this, context);\n },\n};\n\n/**\n * Min age rule - minimum age requirement\n */\nexport const minAgeRule: SchemaRule<{ years: number }> = {\n name: \"minAge\",\n defaultErrorMessage: \"The :input must be at least :years years old\",\n async validate(value: Date, context) {\n const birthDate = new Date(value);\n const today = new Date();\n let age = today.getFullYear() - birthDate.getFullYear();\n const monthDiff = today.getMonth() - birthDate.getMonth();\n\n if (monthDiff < 0 || (monthDiff === 0 && today.getDate() < birthDate.getDate())) {\n age--;\n }\n\n if (age >= this.context.options.years) {\n return VALID_RULE;\n }\n\n this.context.translationParams.years = this.context.options.years;\n\n return invalidRule(this, context);\n },\n};\n\n/**\n * Max age rule - maximum age requirement\n */\nexport const maxAgeRule: SchemaRule<{ years: number }> = {\n name: \"maxAge\",\n defaultErrorMessage: \"The :input must be at most :years years old\",\n async validate(value: Date, context) {\n const birthDate = new Date(value);\n const today = new Date();\n let age = today.getFullYear() - birthDate.getFullYear();\n const monthDiff = today.getMonth() - birthDate.getMonth();\n\n if (monthDiff < 0 || (monthDiff === 0 && today.getDate() < birthDate.getDate())) {\n age--;\n }\n\n if (age <= this.context.options.years) {\n return VALID_RULE;\n }\n\n this.context.translationParams.years = this.context.options.years;\n\n return invalidRule(this, context);\n },\n};\n\n/**\n * Week day rule - date must be specific weekday\n */\nexport const weekDayRule: SchemaRule<{ day: WeekDay }> = {\n name: \"weekDay\",\n defaultErrorMessage: \"The :input must be a :day\",\n async validate(value: Date, context) {\n const inputDate = new Date(value);\n const dayOfWeek = inputDate.getDay();\n const expectedDay = WEEK_DAYS[this.context.options.day];\n\n if (dayOfWeek === expectedDay) {\n return VALID_RULE;\n }\n\n this.context.translatableParams.day = this.context.options.day;\n\n return invalidRule(this, context);\n },\n};\n"],"mappings":";;;;;;;;;;AAUA,MAAa,WAAuB;CAClC,MAAM;CACN,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAClC,IAAI,iBAAiB,QAAQ,CAAC,MAAM,MAAM,QAAQ,CAAC,GACjD,OAAO;EAGT,OAAO,YAAY,MAAM,OAAO;CAClC;AACF;;;;;AAMA,MAAa,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ent":["import { get } from \"@mongez/reinforcements\";\nimport { invalidRule, VALID_RULE } from \"../../helpers\";\nimport { isDateValue } from \"../../helpers/date-helpers\";\nimport type { SchemaRule } from \"../../types\";\nimport type { WeekDay } from \"../../types/date-types\";\nimport { WEEK_DAYS } from \"../../types/date-types\";\n\n/**\n * Date rule - validates date format\n */\nexport const dateRule: SchemaRule = {\n name: \"date\",\n defaultErrorMessage: \"The :input must be a valid date\",\n async validate(value: any, context) {\n if (value instanceof Date && !isNaN(value.getTime())) {\n return VALID_RULE;\n }\n\n return invalidRule(this, context);\n },\n};\n\n/**\n * Min date rule - date must be >= given date or field\n * Smart detection: date value or field name\n */\nexport const minDateRule: SchemaRule<{\n dateOrField: Date | string | number;\n scope?: \"global\" | \"sibling\";\n}> = {\n name: \"minDate\",\n description: \"The field must be at least the given date or field\",\n defaultErrorMessage: \"The :input must be at least :dateOrField\",\n async validate(value: Date, context) {\n const { dateOrField, scope = \"global\" } = this.context.options;\n let compareDate: Date;\n\n if (isDateValue(dateOrField)) {\n // Value comparison\n compareDate = new Date(dateOrField);\n } else {\n // Field comparison\n const source = scope === \"sibling\" ? context.parent : context.allValues;\n const fieldValue = get(source, dateOrField as string);\n\n if (fieldValue === undefined) {\n return VALID_RULE;\n }\n\n compareDate = new Date(fieldValue);\n }\n\n const inputDate = new Date(value);\n\n if (inputDate >= compareDate) {\n return VALID_RULE;\n }\n return invalidRule(this, context);\n },\n};\n\n/**\n * Max date rule - date must be <= given date or field\n * Smart detection: date value or field name\n */\nexport const maxDateRule: SchemaRule<{\n dateOrField: Date | string | number;\n scope?: \"global\" | \"sibling\";\n}> = {\n name: \"maxDate\",\n defaultErrorMessage: \"The :input must be at most :dateOrField\",\n async validate(value: Date, context) {\n const { dateOrField, scope = \"global\" } = this.context.options;\n let compareDate: Date;\n\n if (isDateValue(dateOrField)) {\n // Value comparison\n compareDate = new Date(dateOrField);\n } else {\n // Field comparison\n const source = scope === \"sibling\" ? context.parent : context.allValues;\n const fieldValue = get(source, dateOrField as string);\n\n if (fieldValue === undefined) {\n return VALID_RULE;\n }\n\n compareDate = new Date(fieldValue);\n }\n\n const inputDate = new Date(value);\n\n if (inputDate <= compareDate) {\n return VALID_RULE;\n }\n return invalidRule(this, context);\n },\n};\n\n/**\n * From today rule - date must be today or in the future\n */\nexport const fromTodayRule: SchemaRule = {\n name: \"fromToday\",\n defaultErrorMessage: \"The :input must be today or in the future\",\n async validate(value: Date, context) {\n const today = new Date();\n today.setHours(0, 0, 0, 0);\n const inputDate = new Date(value);\n inputDate.setHours(0, 0, 0, 0);\n\n if (inputDate >= today) {\n return VALID_RULE;\n }\n return invalidRule(this, context);\n },\n};\n\n/**\n * Before today rule - date must be before today\n */\nexport const beforeTodayRule: SchemaRule = {\n name: \"beforeToday\",\n defaultErrorMessage: \"The :input must be before today\",\n async validate(value: Date, context) {\n const today = new Date();\n today.setHours(0, 0, 0, 0);\n const inputDate = new Date(value);\n inputDate.setHours(0, 0, 0, 0);\n\n if (inputDate < today) {\n return VALID_RULE;\n }\n return invalidRule(this, context);\n },\n};\n\n/**\n * From hour rule - time must be from specific hour onwards\n */\nexport const fromHourRule: SchemaRule<{ hour: number }> = {\n name: \"fromHour\",\n defaultErrorMessage: \"The :input must be from :hour:00 onwards\",\n async validate(value: Date, context) {\n const inputDate = new Date(value);\n const hour = inputDate.getHours();\n\n if (hour >= this.context.options.hour) {\n return VALID_RULE;\n }\n\n this.context.translationParams.hour = this.context.options.hour;\n return invalidRule(this, context);\n },\n};\n\n/**\n * Before hour rule - time must be before specific hour\n */\nexport const beforeHourRule: SchemaRule<{ hour: number }> = {\n name: \"beforeHour\",\n defaultErrorMessage: \"The :input must be before :hour:00\",\n async validate(value: Date, context) {\n const inputDate = new Date(value);\n const hour = inputDate.getHours();\n\n if (hour < this.context.options.hour) {\n return VALID_RULE;\n }\n\n this.context.translationParams.hour = this.context.options.hour;\n return invalidRule(this, context);\n },\n};\n\n/**\n * Between hours rule - time must be between start and end hours\n */\nexport const betweenHoursRule: SchemaRule<{\n startHour: number;\n endHour: number;\n}> = {\n name: \"betweenHours\",\n defaultErrorMessage: \"The :input must be between :startHour:00 and :endHour:00\",\n async validate(value: Date, context) {\n const inputDate = new Date(value);\n const hour = inputDate.getHours();\n const { startHour, endHour } = this.context.options;\n\n if (hour >= startHour && hour <= endHour) {\n return VALID_RULE;\n }\n\n this.context.translationParams.startHour = startHour;\n this.context.translationParams.endHour = endHour;\n return invalidRule(this, context);\n },\n};\n\n/**\n * From minute rule - time must be from specific minute onwards\n */\nexport const fromMinuteRule: SchemaRule<{ minute: number }> = {\n name: \"fromMinute\",\n defaultErrorMessage: \"The :input must be from minute :minute onwards\",\n async validate(value: Date, context) {\n const inputDate = new Date(value);\n const minute = inputDate.getMinutes();\n\n if (minute >= this.context.options.minute) {\n return VALID_RULE;\n }\n\n this.context.translationParams.minute = this.context.options.minute;\n\n return invalidRule(this, context);\n },\n};\n\n/**\n * Before minute rule - time must be before specific minute\n */\nexport const beforeMinuteRule: SchemaRule<{ minute: number }> = {\n name: \"beforeMinute\",\n defaultErrorMessage: \"The :input must be before minute :minute\",\n async validate(value: Date, context) {\n const inputDate = new Date(value);\n const minute = inputDate.getMinutes();\n\n if (minute < this.context.options.minute) {\n return VALID_RULE;\n }\n\n this.context.translationParams.minute = this.context.options.minute;\n\n return invalidRule(this, context);\n },\n};\n\n/**\n * Between minutes rule - time must be between start and end minutes\n */\nexport const betweenMinutesRule: SchemaRule<{\n startMinute: number;\n endMinute: number;\n}> = {\n name: \"betweenMinutes\",\n defaultErrorMessage: \"The :input must be between minute :startMinute and :endMinute\",\n async validate(value: Date, context) {\n const inputDate = new Date(value);\n const minute = inputDate.getMinutes();\n const { startMinute, endMinute } = this.context.options;\n\n if (minute >= startMinute && minute <= endMinute) {\n return VALID_RULE;\n }\n\n this.context.translationParams.startMinute = startMinute;\n this.context.translationParams.endMinute = endMinute;\n\n return invalidRule(this, context);\n },\n};\n\n/**\n * Age rule - calculate age from date\n */\nexport const ageRule: SchemaRule<{ years: number }> = {\n name: \"age\",\n defaultErrorMessage: \"The :input must be exactly :years years old\",\n async validate(value: Date, context) {\n const birthDate = new Date(value);\n const today = new Date();\n let age = today.getFullYear() - birthDate.getFullYear();\n const monthDiff = today.getMonth() - birthDate.getMonth();\n\n if (monthDiff < 0 || (monthDiff === 0 && today.getDate() < birthDate.getDate())) {\n age--;\n }\n\n if (age === this.context.options.years) {\n return VALID_RULE;\n }\n\n this.context.translationParams.years = this.context.options.years;\n\n return invalidRule(this, context);\n },\n};\n\n/**\n * Min age rule - minimum age requirement\n */\nexport const minAgeRule: SchemaRule<{ years: number }> = {\n name: \"minAge\",\n defaultErrorMessage: \"The :input must be at least :years years old\",\n async validate(value: Date, context) {\n const birthDate = new Date(value);\n const today = new Date();\n let age = today.getFullYear() - birthDate.getFullYear();\n const monthDiff = today.getMonth() - birthDate.getMonth();\n\n if (monthDiff < 0 || (monthDiff === 0 && today.getDate() < birthDate.getDate())) {\n age--;\n }\n\n if (age >= this.context.options.years) {\n return VALID_RULE;\n }\n\n this.context.translationParams.years = this.context.options.years;\n\n return invalidRule(this, context);\n },\n};\n\n/**\n * Max age rule - maximum age requirement\n */\nexport const maxAgeRule: SchemaRule<{ years: number }> = {\n name: \"maxAge\",\n defaultErrorMessage: \"The :input must be at most :years years old\",\n async validate(value: Date, context) {\n const birthDate = new Date(value);\n const today = new Date();\n let age = today.getFullYear() - birthDate.getFullYear();\n const monthDiff = today.getMonth() - birthDate.getMonth();\n\n if (monthDiff < 0 || (monthDiff === 0 && today.getDate() < birthDate.getDate())) {\n age--;\n }\n\n if (age <= this.context.options.years) {\n return VALID_RULE;\n }\n\n this.context.translationParams.years = this.context.options.years;\n\n return invalidRule(this, context);\n },\n};\n\n/**\n * Week day rule - date must be specific weekday\n */\nexport const weekDayRule: SchemaRule<{ day: WeekDay }> = {\n name: \"weekDay\",\n defaultErrorMessage: \"The :input must be a :day\",\n async validate(value: Date, context) {\n const inputDate = new Date(value);\n const dayOfWeek = inputDate.getDay();\n const expectedDay = WEEK_DAYS[this.context.options.day];\n\n if (dayOfWeek === expectedDay) {\n return VALID_RULE;\n }\n\n this.context.translatableParams.day = this.context.options.day;\n\n return invalidRule(this, context);\n },\n};\n"],"mappings":";;;;;;;;;;AAUA,MAAa,WAAuB;CAClC,MAAM;CACN,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAClC,IAAI,iBAAiB,QAAQ,CAAC,MAAM,MAAM,QAAQ,CAAC,GACjD,OAAO;EAGT,OAAO,YAAY,MAAM,OAAO;CAClC;AACF;;;;;AAMA,MAAa,cAGR;CACH,MAAM;CACN,aAAa;CACb,qBAAqB;CACrB,MAAM,SAAS,OAAa,SAAS;EACnC,MAAM,EAAE,aAAa,QAAQ,aAAa,KAAK,QAAQ;EACvD,IAAI;EAEJ,IAAI,YAAY,WAAW,GAEzB,cAAc,IAAI,KAAK,WAAW;OAC7B;GAEL,MAAM,SAAS,UAAU,YAAY,QAAQ,SAAS,QAAQ;GAC9D,MAAM,aAAa,IAAI,QAAQ,WAAqB;GAEpD,IAAI,eAAe,QACjB,OAAO;GAGT,cAAc,IAAI,KAAK,UAAU;EACnC;EAIA,IAAI,IAFkB,KAAK,KAEf,KAAK,aACf,OAAO;EAET,OAAO,YAAY,MAAM,OAAO;CAClC;AACF;;;;;AAMA,MAAa,cAGR;CACH,MAAM;CACN,qBAAqB;CACrB,MAAM,SAAS,OAAa,SAAS;EACnC,MAAM,EAAE,aAAa,QAAQ,aAAa,KAAK,QAAQ;EACvD,IAAI;EAEJ,IAAI,YAAY,WAAW,GAEzB,cAAc,IAAI,KAAK,WAAW;OAC7B;GAEL,MAAM,SAAS,UAAU,YAAY,QAAQ,SAAS,QAAQ;GAC9D,MAAM,aAAa,IAAI,QAAQ,WAAqB;GAEpD,IAAI,eAAe,QACjB,OAAO;GAGT,cAAc,IAAI,KAAK,UAAU;EACnC;EAIA,IAAI,IAFkB,KAAK,KAEf,KAAK,aACf,OAAO;EAET,OAAO,YAAY,M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;EAE5D,OAAO,YAAY,MAAM,OAAO;CAClC;AACF;;;;AAKA,MAAa,cAA4C;CACvD,MAAM;CACN,qBAAqB;CACrB,MAAM,SAAS,OAAa,SAAS;EAKnC,IAHkB,IADI,KAAK,KACD,CAAC,CAAC,OAGhB,MAFQ,UAAU,KAAK,QAAQ,QAAQ,MAGjD,OAAO;EAGT,KAAK,QAAQ,mBAAmB,MAAM,KAAK,QAAQ,QAAQ;EAE3D,OAAO,YAAY,MAAM,OAAO;CAClC;AACF"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ageRule, beforeHourRule, beforeMinuteRule, beforeTodayRule, betweenHoursRule, betweenMinutesRule, dateRule, fromHourRule, fromMinuteRule, fromTodayRule, maxAgeRule, maxDateRule, minAgeRule, minDateRule, weekDayRule } from "./date.mjs";
|
|
2
|
+
import { afterTodayRule, betweenDatesRule, futureRule, pastRule, todayRule } from "./date-comparison-rules.mjs";
|
|
3
|
+
import { businessDayRule, weekdayRule, weekdaysRule, weekendRule } from "./date-day-rules.mjs";
|
|
4
|
+
import { afterFieldRule, beforeFieldRule, sameAsFieldDateRule } from "./date-field-comparison-rules.mjs";
|
|
5
|
+
import { Month, betweenDaysRule, betweenMonthsRule, betweenTimesRule, betweenYearsRule, maxDayRule, maxMonthRule, maxYearRule, minDayRule, minMonthRule, minYearRule, monthRule, quarterRule, yearRule } from "./date-period-rules.mjs";
|
|
6
|
+
import { withinDaysRule, withinFutureDaysRule, withinPastDaysRule } from "./date-relative-rules.mjs";
|
|
7
|
+
import { betweenAgeRule, birthdayRule, leapYearRule } from "./date-special-rules.mjs";
|
|
8
|
+
export { Month, afterFieldRule, afterTodayRule, ageRule, beforeFieldRule, beforeHourRule, beforeMinuteRule, beforeTodayRule, betweenAgeRule, betweenDatesRule, betweenDaysRule, betweenHoursRule, betweenMinutesRule, betweenMonthsRule, betweenTimesRule, betweenYearsRule, birthdayRule, businessDayRule, dateRule, fromHourRule, fromMinuteRule, fromTodayRule, futureRule, leapYearRule, maxAgeRule, maxDateRule, maxDayRule, maxMonthRule, maxYearRule, minAgeRule, minDateRule, minDayRule, minMonthRule, minYearRule, monthRule, pastRule, quarterRule, sameAsFieldDateRule, todayRule, weekDayRule, weekdayRule, weekdaysRule, weekendRule, withinDaysRule, withinFutureDaysRule, withinPastDaysRule, yearRule };
|
package/esm/rules/date/index.mjs
CHANGED
|
@@ -6,4 +6,4 @@ import { betweenDaysRule, betweenMonthsRule, betweenTimesRule, betweenYearsRule,
|
|
|
6
6
|
import { withinDaysRule, withinFutureDaysRule, withinPastDaysRule } from "./date-relative-rules.mjs";
|
|
7
7
|
import { betweenAgeRule, birthdayRule, leapYearRule } from "./date-special-rules.mjs";
|
|
8
8
|
|
|
9
|
-
export {
|
|
9
|
+
export { afterFieldRule, afterTodayRule, ageRule, beforeFieldRule, beforeHourRule, beforeMinuteRule, beforeTodayRule, betweenAgeRule, betweenDatesRule, betweenDaysRule, betweenHoursRule, betweenMinutesRule, betweenMonthsRule, betweenTimesRule, betweenYearsRule, birthdayRule, businessDayRule, dateRule, fromHourRule, fromMinuteRule, fromTodayRule, futureRule, leapYearRule, maxAgeRule, maxDateRule, maxDayRule, maxMonthRule, maxYearRule, minAgeRule, minDateRule, minDayRule, minMonthRule, minYearRule, monthRule, pastRule, quarterRule, sameAsFieldDateRule, todayRule, weekDayRule, weekdayRule, weekdaysRule, weekendRule, withinDaysRule, withinFutureDaysRule, withinPastDaysRule, yearRule };
|
|
@@ -1,30 +1,29 @@
|
|
|
1
1
|
import { SchemaRule } from "../../types/rule-types.mjs";
|
|
2
|
-
|
|
2
|
+
import "../../types/index.mjs";
|
|
3
3
|
//#region ../../packages/seal/src/rules/file/dimensions.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* Min width rule - image width validation
|
|
6
6
|
*/
|
|
7
|
-
declare const minWidthRule: SchemaRule<{
|
|
7
|
+
export declare const minWidthRule: SchemaRule<{
|
|
8
8
|
minWidth: number;
|
|
9
9
|
}>;
|
|
10
10
|
/**
|
|
11
11
|
* Max width rule - image width validation
|
|
12
12
|
*/
|
|
13
|
-
declare const maxWidthRule: SchemaRule<{
|
|
13
|
+
export declare const maxWidthRule: SchemaRule<{
|
|
14
14
|
maxWidth: number;
|
|
15
15
|
}>;
|
|
16
16
|
/**
|
|
17
17
|
* Min height rule - image height validation
|
|
18
18
|
*/
|
|
19
|
-
declare const minHeightRule: SchemaRule<{
|
|
19
|
+
export declare const minHeightRule: SchemaRule<{
|
|
20
20
|
minHeight: number;
|
|
21
21
|
}>;
|
|
22
22
|
/**
|
|
23
23
|
* Max height rule - image height validation
|
|
24
24
|
*/
|
|
25
|
-
declare const maxHeightRule: SchemaRule<{
|
|
25
|
+
export declare const maxHeightRule: SchemaRule<{
|
|
26
26
|
maxHeight: number;
|
|
27
27
|
}>;
|
|
28
28
|
//#endregion
|
|
29
|
-
export { maxHeightRule, maxWidthRule, minHeightRule, minWidthRule };
|
|
30
29
|
//# sourceMappingURL=dimensions.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dimensions.d.mts","names":[],"sources":["../../../../../../../../../packages/seal/src/rules/file/dimensions.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"dimensions.d.mts","names":[],"sources":["../../../../../../../../../packages/seal/src/rules/file/dimensions.ts"],"mappings":";;;;;;qBAMa,cAAc;EAAa;;;;;qBAmB3B,cAAc;EAAa;;;;;qBAmB3B,eAAe;EAAa;;;;;qBAmB5B,eAAe;EAAa"}
|
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
import { SchemaRule } from "../../types/rule-types.mjs";
|
|
2
|
-
|
|
2
|
+
import "../../types/index.mjs";
|
|
3
3
|
//#region ../../packages/seal/src/rules/file/file-size.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* Max file size rule
|
|
6
6
|
*/
|
|
7
|
-
declare const maxFileSizeRule: SchemaRule<{
|
|
7
|
+
export declare const maxFileSizeRule: SchemaRule<{
|
|
8
8
|
maxSize: number;
|
|
9
9
|
}>;
|
|
10
10
|
/**
|
|
11
11
|
* Min file size rule
|
|
12
12
|
*/
|
|
13
|
-
declare const minFileSizeRule: SchemaRule<{
|
|
13
|
+
export declare const minFileSizeRule: SchemaRule<{
|
|
14
14
|
minSize: number;
|
|
15
15
|
}>;
|
|
16
16
|
//#endregion
|
|
17
|
-
export { maxFileSizeRule, minFileSizeRule };
|
|
18
17
|
//# sourceMappingURL=file-size.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-size.d.mts","names":[],"sources":["../../../../../../../../../packages/seal/src/rules/file/file-size.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"file-size.d.mts","names":[],"sources":["../../../../../../../../../packages/seal/src/rules/file/file-size.ts"],"mappings":";;;;;;qBAMa,iBAAiB;EAAa;;;;;qBAmB9B,iBAAiB;EAAa"}
|
package/esm/rules/file/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { maxHeightRule, maxWidthRule, minHeightRule, minWidthRule } from "./dimensions.mjs";
|
|
2
2
|
import { maxFileSizeRule, minFileSizeRule } from "./file-size.mjs";
|
|
3
3
|
|
|
4
|
-
export {
|
|
4
|
+
export { maxFileSizeRule, maxHeightRule, maxWidthRule, minFileSizeRule, minHeightRule, minWidthRule };
|