@warlock.js/seal 5.2.0 → 5.2.2
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 +6 -0
- package/cjs/index.cjs +92 -92
- package/cjs/index.cjs.map +1 -1
- package/esm/config.d.mts +1 -1
- package/esm/config.d.mts.map +1 -1
- package/esm/config.mjs +1 -1
- package/esm/config.mjs.map +1 -1
- package/esm/factory/validate.d.mts +1 -1
- package/esm/factory/validate.d.mts.map +1 -1
- package/esm/factory/validate.mjs +1 -1
- package/esm/factory/validate.mjs.map +1 -1
- package/esm/factory/validators.d.mts +1 -1
- package/esm/factory/validators.d.mts.map +1 -1
- package/esm/factory/validators.mjs +1 -1
- package/esm/factory/validators.mjs.map +1 -1
- package/esm/helpers/date-helpers.d.mts +1 -1
- package/esm/helpers/date-helpers.d.mts.map +1 -1
- package/esm/helpers/date-helpers.mjs +1 -1
- package/esm/helpers/date-helpers.mjs.map +1 -1
- package/esm/helpers/file.utils.d.mts +1 -1
- package/esm/helpers/file.utils.d.mts.map +1 -1
- package/esm/helpers/file.utils.mjs +1 -1
- package/esm/helpers/file.utils.mjs.map +1 -1
- package/esm/helpers/get-field-value.d.mts +1 -1
- package/esm/helpers/get-field-value.d.mts.map +1 -1
- package/esm/helpers/get-field-value.mjs +1 -1
- package/esm/helpers/get-field-value.mjs.map +1 -1
- package/esm/helpers/is-empty-value.mjs +1 -1
- package/esm/helpers/is-empty-value.mjs.map +1 -1
- package/esm/helpers/path-helpers.d.mts +1 -1
- package/esm/helpers/path-helpers.d.mts.map +1 -1
- package/esm/helpers/path-helpers.mjs +1 -1
- package/esm/helpers/path-helpers.mjs.map +1 -1
- package/esm/helpers/validation-helpers.d.mts +1 -1
- package/esm/helpers/validation-helpers.d.mts.map +1 -1
- package/esm/helpers/validation-helpers.mjs +1 -1
- package/esm/helpers/validation-helpers.mjs.map +1 -1
- package/esm/mutators/array-mutators.d.mts +1 -1
- package/esm/mutators/array-mutators.d.mts.map +1 -1
- package/esm/mutators/array-mutators.mjs +1 -1
- package/esm/mutators/array-mutators.mjs.map +1 -1
- package/esm/mutators/date-mutators.d.mts +1 -1
- package/esm/mutators/date-mutators.d.mts.map +1 -1
- package/esm/mutators/date-mutators.mjs +1 -1
- package/esm/mutators/date-mutators.mjs.map +1 -1
- package/esm/mutators/number-mutators.d.mts +1 -1
- package/esm/mutators/number-mutators.d.mts.map +1 -1
- package/esm/mutators/number-mutators.mjs +1 -1
- package/esm/mutators/number-mutators.mjs.map +1 -1
- package/esm/mutators/object-mutators.d.mts +1 -1
- package/esm/mutators/object-mutators.d.mts.map +1 -1
- package/esm/mutators/object-mutators.mjs +1 -1
- package/esm/mutators/object-mutators.mjs.map +1 -1
- package/esm/mutators/scalar-mutators.d.mts +1 -1
- package/esm/mutators/scalar-mutators.d.mts.map +1 -1
- package/esm/mutators/scalar-mutators.mjs +1 -1
- package/esm/mutators/scalar-mutators.mjs.map +1 -1
- package/esm/mutators/string-mutators.d.mts +1 -1
- package/esm/mutators/string-mutators.d.mts.map +1 -1
- package/esm/mutators/string-mutators.mjs +1 -1
- package/esm/mutators/string-mutators.mjs.map +1 -1
- package/esm/plugins/plugin-system.d.mts +1 -1
- package/esm/plugins/plugin-system.d.mts.map +1 -1
- package/esm/plugins/plugin-system.mjs +1 -1
- package/esm/plugins/plugin-system.mjs.map +1 -1
- package/esm/rules/array/array-rules.d.mts +1 -1
- package/esm/rules/array/array-rules.d.mts.map +1 -1
- package/esm/rules/array/array-rules.mjs +1 -1
- package/esm/rules/array/array-rules.mjs.map +1 -1
- package/esm/rules/color/color-rules.d.mts +1 -1
- package/esm/rules/color/color-rules.d.mts.map +1 -1
- package/esm/rules/color/color-rules.mjs +1 -1
- package/esm/rules/color/color-rules.mjs.map +1 -1
- package/esm/rules/common/enum.d.mts +1 -1
- package/esm/rules/common/enum.d.mts.map +1 -1
- package/esm/rules/common/enum.mjs +1 -1
- package/esm/rules/common/enum.mjs.map +1 -1
- package/esm/rules/common/equals-field-rules.d.mts +1 -1
- package/esm/rules/common/equals-field-rules.d.mts.map +1 -1
- package/esm/rules/common/equals-field-rules.mjs +1 -1
- package/esm/rules/common/equals-field-rules.mjs.map +1 -1
- package/esm/rules/common/instanceof.d.mts +1 -1
- package/esm/rules/common/instanceof.d.mts.map +1 -1
- package/esm/rules/common/instanceof.mjs +1 -1
- package/esm/rules/common/instanceof.mjs.map +1 -1
- package/esm/rules/common/literal.d.mts +1 -1
- package/esm/rules/common/literal.d.mts.map +1 -1
- package/esm/rules/common/literal.mjs +1 -1
- package/esm/rules/common/literal.mjs.map +1 -1
- package/esm/rules/common/type-rules.d.mts +1 -1
- package/esm/rules/common/type-rules.d.mts.map +1 -1
- package/esm/rules/common/type-rules.mjs +1 -1
- package/esm/rules/common/type-rules.mjs.map +1 -1
- package/esm/rules/common/unknown-key.d.mts +1 -1
- package/esm/rules/common/unknown-key.d.mts.map +1 -1
- package/esm/rules/common/unknown-key.mjs +1 -1
- package/esm/rules/common/unknown-key.mjs.map +1 -1
- package/esm/rules/conditional/forbidden-if-rules.d.mts +1 -1
- package/esm/rules/conditional/forbidden-if-rules.d.mts.map +1 -1
- package/esm/rules/conditional/forbidden-if-rules.mjs +1 -1
- package/esm/rules/conditional/forbidden-if-rules.mjs.map +1 -1
- package/esm/rules/conditional/present-if-rules.d.mts +1 -1
- package/esm/rules/conditional/present-if-rules.d.mts.map +1 -1
- package/esm/rules/conditional/present-if-rules.mjs +1 -1
- package/esm/rules/conditional/present-if-rules.mjs.map +1 -1
- package/esm/rules/conditional/present-unless-rules.d.mts +1 -1
- package/esm/rules/conditional/present-unless-rules.d.mts.map +1 -1
- package/esm/rules/conditional/present-unless-rules.mjs +1 -1
- package/esm/rules/conditional/present-unless-rules.mjs.map +1 -1
- package/esm/rules/conditional/present-with-rules.d.mts +1 -1
- package/esm/rules/conditional/present-with-rules.d.mts.map +1 -1
- package/esm/rules/conditional/present-with-rules.mjs +1 -1
- package/esm/rules/conditional/present-with-rules.mjs.map +1 -1
- package/esm/rules/conditional/present-without-rules.d.mts +1 -1
- package/esm/rules/conditional/present-without-rules.d.mts.map +1 -1
- package/esm/rules/conditional/present-without-rules.mjs +1 -1
- package/esm/rules/conditional/present-without-rules.mjs.map +1 -1
- package/esm/rules/conditional/required-if-rules.d.mts +1 -1
- package/esm/rules/conditional/required-if-rules.d.mts.map +1 -1
- package/esm/rules/conditional/required-if-rules.mjs +1 -1
- package/esm/rules/conditional/required-if-rules.mjs.map +1 -1
- package/esm/rules/conditional/required-unless-rules.d.mts +1 -1
- package/esm/rules/conditional/required-unless-rules.d.mts.map +1 -1
- package/esm/rules/conditional/required-unless-rules.mjs +1 -1
- package/esm/rules/conditional/required-unless-rules.mjs.map +1 -1
- package/esm/rules/conditional/required-when-rule.d.mts +1 -1
- package/esm/rules/conditional/required-when-rule.d.mts.map +1 -1
- package/esm/rules/conditional/required-when-rule.mjs +1 -1
- package/esm/rules/conditional/required-when-rule.mjs.map +1 -1
- package/esm/rules/conditional/required-with-rules.d.mts +1 -1
- package/esm/rules/conditional/required-with-rules.d.mts.map +1 -1
- package/esm/rules/conditional/required-with-rules.mjs +1 -1
- package/esm/rules/conditional/required-with-rules.mjs.map +1 -1
- package/esm/rules/conditional/required-without-rules.d.mts +1 -1
- package/esm/rules/conditional/required-without-rules.d.mts.map +1 -1
- package/esm/rules/conditional/required-without-rules.mjs +1 -1
- package/esm/rules/conditional/required-without-rules.mjs.map +1 -1
- package/esm/rules/core/equal.d.mts +1 -1
- package/esm/rules/core/equal.d.mts.map +1 -1
- package/esm/rules/core/equal.mjs +1 -1
- package/esm/rules/core/equal.mjs.map +1 -1
- package/esm/rules/core/forbidden.d.mts +1 -1
- package/esm/rules/core/forbidden.d.mts.map +1 -1
- package/esm/rules/core/forbidden.mjs +1 -1
- package/esm/rules/core/forbidden.mjs.map +1 -1
- package/esm/rules/core/required.d.mts +1 -1
- package/esm/rules/core/required.d.mts.map +1 -1
- package/esm/rules/core/required.mjs +1 -1
- package/esm/rules/core/required.mjs.map +1 -1
- package/esm/rules/core/union.d.mts +1 -1
- package/esm/rules/core/union.d.mts.map +1 -1
- package/esm/rules/core/union.mjs +1 -1
- package/esm/rules/core/union.mjs.map +1 -1
- package/esm/rules/core/when.d.mts +1 -1
- package/esm/rules/core/when.d.mts.map +1 -1
- package/esm/rules/core/when.mjs +1 -1
- package/esm/rules/core/when.mjs.map +1 -1
- package/esm/rules/date/date-comparison-rules.d.mts +1 -1
- package/esm/rules/date/date-comparison-rules.d.mts.map +1 -1
- package/esm/rules/date/date-comparison-rules.mjs +1 -1
- package/esm/rules/date/date-comparison-rules.mjs.map +1 -1
- package/esm/rules/date/date-day-rules.d.mts +1 -1
- package/esm/rules/date/date-day-rules.d.mts.map +1 -1
- package/esm/rules/date/date-day-rules.mjs +1 -1
- package/esm/rules/date/date-day-rules.mjs.map +1 -1
- package/esm/rules/date/date-field-comparison-rules.d.mts +1 -1
- package/esm/rules/date/date-field-comparison-rules.d.mts.map +1 -1
- package/esm/rules/date/date-field-comparison-rules.mjs +1 -1
- package/esm/rules/date/date-field-comparison-rules.mjs.map +1 -1
- package/esm/rules/date/date-period-rules.d.mts +1 -1
- package/esm/rules/date/date-period-rules.d.mts.map +1 -1
- package/esm/rules/date/date-period-rules.mjs +1 -1
- package/esm/rules/date/date-period-rules.mjs.map +1 -1
- package/esm/rules/date/date-relative-rules.d.mts +1 -1
- package/esm/rules/date/date-relative-rules.d.mts.map +1 -1
- package/esm/rules/date/date-relative-rules.mjs +1 -1
- package/esm/rules/date/date-relative-rules.mjs.map +1 -1
- package/esm/rules/date/date-special-rules.d.mts +1 -1
- package/esm/rules/date/date-special-rules.d.mts.map +1 -1
- package/esm/rules/date/date-special-rules.mjs +1 -1
- package/esm/rules/date/date-special-rules.mjs.map +1 -1
- package/esm/rules/date/date.d.mts +1 -1
- package/esm/rules/date/date.d.mts.map +1 -1
- package/esm/rules/date/date.mjs +1 -1
- package/esm/rules/date/date.mjs.map +1 -1
- package/esm/rules/file/dimensions.d.mts +1 -1
- package/esm/rules/file/dimensions.d.mts.map +1 -1
- package/esm/rules/file/dimensions.mjs +1 -1
- package/esm/rules/file/dimensions.mjs.map +1 -1
- package/esm/rules/file/file-size.d.mts +1 -1
- package/esm/rules/file/file-size.d.mts.map +1 -1
- package/esm/rules/file/file-size.mjs +1 -1
- package/esm/rules/file/file-size.mjs.map +1 -1
- package/esm/rules/length/length-rules.d.mts +1 -1
- package/esm/rules/length/length-rules.d.mts.map +1 -1
- package/esm/rules/length/length-rules.mjs +1 -1
- package/esm/rules/length/length-rules.mjs.map +1 -1
- package/esm/rules/number/number-rules.d.mts +1 -1
- package/esm/rules/number/number-rules.d.mts.map +1 -1
- package/esm/rules/number/number-rules.mjs +1 -1
- package/esm/rules/number/number-rules.mjs.map +1 -1
- package/esm/rules/scalar/accepted-rule.mjs +1 -1
- package/esm/rules/scalar/accepted-rule.mjs.map +1 -1
- package/esm/rules/scalar/declined-rule.mjs +1 -1
- package/esm/rules/scalar/declined-rule.mjs.map +1 -1
- package/esm/rules/string/alpha.d.mts +1 -1
- package/esm/rules/string/alpha.d.mts.map +1 -1
- package/esm/rules/string/alpha.mjs +1 -1
- package/esm/rules/string/alpha.mjs.map +1 -1
- package/esm/rules/string/credit-card.d.mts +1 -1
- package/esm/rules/string/credit-card.d.mts.map +1 -1
- package/esm/rules/string/credit-card.mjs +1 -1
- package/esm/rules/string/credit-card.mjs.map +1 -1
- package/esm/rules/string/email.d.mts +1 -1
- package/esm/rules/string/email.d.mts.map +1 -1
- package/esm/rules/string/email.mjs +1 -1
- package/esm/rules/string/email.mjs.map +1 -1
- package/esm/rules/string/id-formats.d.mts +1 -1
- package/esm/rules/string/id-formats.d.mts.map +1 -1
- package/esm/rules/string/id-formats.mjs +1 -1
- package/esm/rules/string/id-formats.mjs.map +1 -1
- package/esm/rules/string/ip.d.mts +1 -1
- package/esm/rules/string/ip.d.mts.map +1 -1
- package/esm/rules/string/ip.mjs +1 -1
- package/esm/rules/string/ip.mjs.map +1 -1
- package/esm/rules/string/matches.d.mts +1 -1
- package/esm/rules/string/matches.d.mts.map +1 -1
- package/esm/rules/string/matches.mjs +1 -1
- package/esm/rules/string/matches.mjs.map +1 -1
- package/esm/rules/string/pattern.d.mts +1 -1
- package/esm/rules/string/pattern.d.mts.map +1 -1
- package/esm/rules/string/pattern.mjs +1 -1
- package/esm/rules/string/pattern.mjs.map +1 -1
- package/esm/rules/string/string-comparison.d.mts +1 -1
- package/esm/rules/string/string-comparison.d.mts.map +1 -1
- package/esm/rules/string/string-comparison.mjs +1 -1
- package/esm/rules/string/string-comparison.mjs.map +1 -1
- package/esm/rules/string/strong-password-rule.d.mts +1 -1
- package/esm/rules/string/strong-password-rule.d.mts.map +1 -1
- package/esm/rules/string/strong-password-rule.mjs +1 -1
- package/esm/rules/string/strong-password-rule.mjs.map +1 -1
- package/esm/rules/string/url.d.mts +1 -1
- package/esm/rules/string/url.d.mts.map +1 -1
- package/esm/rules/string/url.mjs +1 -1
- package/esm/rules/string/url.mjs.map +1 -1
- package/esm/rules/string/without-whitespace.d.mts +1 -1
- package/esm/rules/string/without-whitespace.d.mts.map +1 -1
- package/esm/rules/string/without-whitespace.mjs +1 -1
- package/esm/rules/string/without-whitespace.mjs.map +1 -1
- package/esm/standard-schema/json-schema.d.mts +1 -1
- package/esm/standard-schema/json-schema.d.mts.map +1 -1
- package/esm/standard-schema/json-schema.mjs +1 -1
- package/esm/standard-schema/json-schema.mjs.map +1 -1
- package/esm/standard-schema/map-result.d.mts +1 -1
- package/esm/standard-schema/map-result.d.mts.map +1 -1
- package/esm/standard-schema/map-result.mjs +1 -1
- package/esm/standard-schema/map-result.mjs.map +1 -1
- package/esm/standard-schema/types.d.mts +1 -1
- package/esm/standard-schema/types.d.mts.map +1 -1
- package/esm/types/conditional-types.d.mts +1 -1
- package/esm/types/conditional-types.d.mts.map +1 -1
- package/esm/types/context-types.d.mts +1 -1
- package/esm/types/context-types.d.mts.map +1 -1
- package/esm/types/data-transformer-types.d.mts +1 -1
- package/esm/types/data-transformer-types.d.mts.map +1 -1
- package/esm/types/date-types.d.mts +1 -1
- package/esm/types/date-types.d.mts.map +1 -1
- package/esm/types/date-types.mjs +1 -1
- package/esm/types/date-types.mjs.map +1 -1
- package/esm/types/file.types.d.mts +1 -1
- package/esm/types/file.types.d.mts.map +1 -1
- package/esm/types/inference-types.d.mts +1 -1
- package/esm/types/inference-types.d.mts.map +1 -1
- package/esm/types/mutator-types.d.mts +1 -1
- package/esm/types/mutator-types.d.mts.map +1 -1
- package/esm/types/result-types.d.mts +1 -1
- package/esm/types/result-types.d.mts.map +1 -1
- package/esm/types/rule-types.d.mts +1 -1
- package/esm/types/rule-types.d.mts.map +1 -1
- package/esm/types/schema-types.d.mts +1 -1
- package/esm/types/schema-types.d.mts.map +1 -1
- package/esm/validators/any-validator.d.mts +1 -1
- package/esm/validators/any-validator.d.mts.map +1 -1
- package/esm/validators/any-validator.mjs +1 -1
- package/esm/validators/any-validator.mjs.map +1 -1
- package/esm/validators/array-validator.d.mts +1 -1
- package/esm/validators/array-validator.d.mts.map +1 -1
- package/esm/validators/array-validator.mjs +1 -1
- package/esm/validators/array-validator.mjs.map +1 -1
- package/esm/validators/base-validator.d.mts +1 -1
- package/esm/validators/base-validator.d.mts.map +1 -1
- package/esm/validators/base-validator.mjs +1 -1
- package/esm/validators/base-validator.mjs.map +1 -1
- package/esm/validators/boolean-validator.d.mts +1 -1
- package/esm/validators/boolean-validator.d.mts.map +1 -1
- package/esm/validators/boolean-validator.mjs +1 -1
- package/esm/validators/boolean-validator.mjs.map +1 -1
- package/esm/validators/computed-validator.d.mts +1 -1
- package/esm/validators/computed-validator.d.mts.map +1 -1
- package/esm/validators/computed-validator.mjs +1 -1
- package/esm/validators/computed-validator.mjs.map +1 -1
- package/esm/validators/date-validator.d.mts +1 -1
- package/esm/validators/date-validator.d.mts.map +1 -1
- package/esm/validators/date-validator.mjs +1 -1
- package/esm/validators/date-validator.mjs.map +1 -1
- package/esm/validators/discriminated-union-validator.d.mts +1 -1
- 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 -1
- package/esm/validators/float-validator.d.mts.map +1 -1
- package/esm/validators/float-validator.mjs +1 -1
- package/esm/validators/float-validator.mjs.map +1 -1
- package/esm/validators/instanceof-validator.d.mts +1 -1
- package/esm/validators/instanceof-validator.d.mts.map +1 -1
- package/esm/validators/instanceof-validator.mjs +1 -1
- package/esm/validators/instanceof-validator.mjs.map +1 -1
- package/esm/validators/int-validator.d.mts +1 -1
- package/esm/validators/int-validator.d.mts.map +1 -1
- package/esm/validators/int-validator.mjs +1 -1
- package/esm/validators/int-validator.mjs.map +1 -1
- package/esm/validators/lazy-validator.d.mts +1 -1
- 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 -1
- package/esm/validators/literal-validator.d.mts.map +1 -1
- package/esm/validators/literal-validator.mjs +1 -1
- package/esm/validators/literal-validator.mjs.map +1 -1
- package/esm/validators/managed-validator.d.mts +1 -1
- package/esm/validators/managed-validator.d.mts.map +1 -1
- package/esm/validators/managed-validator.mjs +1 -1
- package/esm/validators/managed-validator.mjs.map +1 -1
- package/esm/validators/methods/equality-conditional-methods.d.mts +1 -1
- package/esm/validators/methods/equality-conditional-methods.d.mts.map +1 -1
- package/esm/validators/methods/equality-conditional-methods.mjs +1 -1
- package/esm/validators/methods/equality-conditional-methods.mjs.map +1 -1
- package/esm/validators/methods/forbidden-methods.d.mts +1 -1
- package/esm/validators/methods/forbidden-methods.d.mts.map +1 -1
- package/esm/validators/methods/forbidden-methods.mjs +1 -1
- package/esm/validators/methods/forbidden-methods.mjs.map +1 -1
- package/esm/validators/methods/present-methods.d.mts +1 -1
- package/esm/validators/methods/present-methods.d.mts.map +1 -1
- package/esm/validators/methods/present-methods.mjs +1 -1
- package/esm/validators/methods/present-methods.mjs.map +1 -1
- package/esm/validators/methods/required-methods.d.mts +1 -1
- package/esm/validators/methods/required-methods.d.mts.map +1 -1
- package/esm/validators/methods/required-methods.mjs +1 -1
- package/esm/validators/methods/required-methods.mjs.map +1 -1
- package/esm/validators/number-validator.d.mts +1 -1
- package/esm/validators/number-validator.d.mts.map +1 -1
- package/esm/validators/number-validator.mjs +1 -1
- package/esm/validators/number-validator.mjs.map +1 -1
- package/esm/validators/numeric-validator.d.mts +1 -1
- package/esm/validators/numeric-validator.d.mts.map +1 -1
- package/esm/validators/numeric-validator.mjs +1 -1
- package/esm/validators/numeric-validator.mjs.map +1 -1
- package/esm/validators/object-validator.d.mts +1 -1
- package/esm/validators/object-validator.d.mts.map +1 -1
- package/esm/validators/object-validator.mjs +1 -1
- package/esm/validators/object-validator.mjs.map +1 -1
- package/esm/validators/primitive-validator.d.mts +1 -1
- package/esm/validators/primitive-validator.d.mts.map +1 -1
- package/esm/validators/primitive-validator.mjs +1 -1
- package/esm/validators/primitive-validator.mjs.map +1 -1
- package/esm/validators/record-validator.d.mts +1 -1
- package/esm/validators/record-validator.d.mts.map +1 -1
- package/esm/validators/record-validator.mjs +1 -1
- package/esm/validators/record-validator.mjs.map +1 -1
- package/esm/validators/scalar-validator.d.mts +1 -1
- package/esm/validators/scalar-validator.d.mts.map +1 -1
- package/esm/validators/scalar-validator.mjs +1 -1
- package/esm/validators/scalar-validator.mjs.map +1 -1
- package/esm/validators/string-validator.d.mts +1 -1
- package/esm/validators/string-validator.d.mts.map +1 -1
- package/esm/validators/string-validator.mjs +1 -1
- package/esm/validators/string-validator.mjs.map +1 -1
- package/esm/validators/tuple-validator.d.mts +1 -1
- package/esm/validators/tuple-validator.d.mts.map +1 -1
- package/esm/validators/tuple-validator.mjs +1 -1
- package/esm/validators/tuple-validator.mjs.map +1 -1
- package/esm/validators/union-validator.d.mts +1 -1
- package/esm/validators/union-validator.d.mts.map +1 -1
- package/esm/validators/union-validator.mjs +1 -1
- package/esm/validators/union-validator.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"date.mjs","names":[],"sources":["C:/Work/Warlock.js/seal/src/rules/date/date.ts"],"sourcesContent":["import { get } from \"@mongez/reinforcements\";\r\nimport { invalidRule, VALID_RULE } from \"../../helpers\";\r\nimport { isDateValue } from \"../../helpers/date-helpers\";\r\nimport type { SchemaRule } from \"../../types\";\r\nimport type { WeekDay } from \"../../types/date-types\";\r\nimport { WEEK_DAYS } from \"../../types/date-types\";\r\n\r\n/**\r\n * Date rule - validates date format\r\n */\r\nexport const dateRule: SchemaRule = {\r\n name: \"date\",\r\n defaultErrorMessage: \"The :input must be a valid date\",\r\n async validate(value: any, context) {\r\n if (value instanceof Date && !isNaN(value.getTime())) {\r\n return VALID_RULE;\r\n }\r\n\r\n return invalidRule(this, context);\r\n },\r\n};\r\n\r\n/**\r\n * Min date rule - date must be >= given date or field\r\n * Smart detection: date value or field name\r\n */\r\nexport const minDateRule: SchemaRule<{\r\n dateOrField: Date | string | number;\r\n scope?: \"global\" | \"sibling\";\r\n}> = {\r\n name: \"minDate\",\r\n description: \"The field must be at least the given date or field\",\r\n defaultErrorMessage: \"The :input must be at least :dateOrField\",\r\n async validate(value: Date, context) {\r\n const { dateOrField, scope = \"global\" } = this.context.options;\r\n let compareDate: Date;\r\n\r\n if (isDateValue(dateOrField)) {\r\n // Value comparison\r\n compareDate = new Date(dateOrField);\r\n } else {\r\n // Field comparison\r\n const source = scope === \"sibling\" ? context.parent : context.allValues;\r\n const fieldValue = get(source, dateOrField as string);\r\n\r\n if (fieldValue === undefined) {\r\n return VALID_RULE;\r\n }\r\n\r\n compareDate = new Date(fieldValue);\r\n }\r\n\r\n const inputDate = new Date(value);\r\n\r\n if (inputDate >= compareDate) {\r\n return VALID_RULE;\r\n }\r\n return invalidRule(this, context);\r\n },\r\n};\r\n\r\n/**\r\n * Max date rule - date must be <= given date or field\r\n * Smart detection: date value or field name\r\n */\r\nexport const maxDateRule: SchemaRule<{\r\n dateOrField: Date | string | number;\r\n scope?: \"global\" | \"sibling\";\r\n}> = {\r\n name: \"maxDate\",\r\n defaultErrorMessage: \"The :input must be at most :dateOrField\",\r\n async validate(value: Date, context) {\r\n const { dateOrField, scope = \"global\" } = this.context.options;\r\n let compareDate: Date;\r\n\r\n if (isDateValue(dateOrField)) {\r\n // Value comparison\r\n compareDate = new Date(dateOrField);\r\n } else {\r\n // Field comparison\r\n const source = scope === \"sibling\" ? context.parent : context.allValues;\r\n const fieldValue = get(source, dateOrField as string);\r\n\r\n if (fieldValue === undefined) {\r\n return VALID_RULE;\r\n }\r\n\r\n compareDate = new Date(fieldValue);\r\n }\r\n\r\n const inputDate = new Date(value);\r\n\r\n if (inputDate <= compareDate) {\r\n return VALID_RULE;\r\n }\r\n return invalidRule(this, context);\r\n },\r\n};\r\n\r\n/**\r\n * From today rule - date must be today or in the future\r\n */\r\nexport const fromTodayRule: SchemaRule = {\r\n name: \"fromToday\",\r\n defaultErrorMessage: \"The :input must be today or in the future\",\r\n async validate(value: Date, context) {\r\n const today = new Date();\r\n today.setHours(0, 0, 0, 0);\r\n const inputDate = new Date(value);\r\n inputDate.setHours(0, 0, 0, 0);\r\n\r\n if (inputDate >= today) {\r\n return VALID_RULE;\r\n }\r\n return invalidRule(this, context);\r\n },\r\n};\r\n\r\n/**\r\n * Before today rule - date must be before today\r\n */\r\nexport const beforeTodayRule: SchemaRule = {\r\n name: \"beforeToday\",\r\n defaultErrorMessage: \"The :input must be before today\",\r\n async validate(value: Date, context) {\r\n const today = new Date();\r\n today.setHours(0, 0, 0, 0);\r\n const inputDate = new Date(value);\r\n inputDate.setHours(0, 0, 0, 0);\r\n\r\n if (inputDate < today) {\r\n return VALID_RULE;\r\n }\r\n return invalidRule(this, context);\r\n },\r\n};\r\n\r\n/**\r\n * From hour rule - time must be from specific hour onwards\r\n */\r\nexport const fromHourRule: SchemaRule<{ hour: number }> = {\r\n name: \"fromHour\",\r\n defaultErrorMessage: \"The :input must be from :hour:00 onwards\",\r\n async validate(value: Date, context) {\r\n const inputDate = new Date(value);\r\n const hour = inputDate.getHours();\r\n\r\n if (hour >= this.context.options.hour) {\r\n return VALID_RULE;\r\n }\r\n\r\n this.context.translationParams.hour = this.context.options.hour;\r\n return invalidRule(this, context);\r\n },\r\n};\r\n\r\n/**\r\n * Before hour rule - time must be before specific hour\r\n */\r\nexport const beforeHourRule: SchemaRule<{ hour: number }> = {\r\n name: \"beforeHour\",\r\n defaultErrorMessage: \"The :input must be before :hour:00\",\r\n async validate(value: Date, context) {\r\n const inputDate = new Date(value);\r\n const hour = inputDate.getHours();\r\n\r\n if (hour < this.context.options.hour) {\r\n return VALID_RULE;\r\n }\r\n\r\n this.context.translationParams.hour = this.context.options.hour;\r\n return invalidRule(this, context);\r\n },\r\n};\r\n\r\n/**\r\n * Between hours rule - time must be between start and end hours\r\n */\r\nexport const betweenHoursRule: SchemaRule<{\r\n startHour: number;\r\n endHour: number;\r\n}> = {\r\n name: \"betweenHours\",\r\n defaultErrorMessage: \"The :input must be between :startHour:00 and :endHour:00\",\r\n async validate(value: Date, context) {\r\n const inputDate = new Date(value);\r\n const hour = inputDate.getHours();\r\n const { startHour, endHour } = this.context.options;\r\n\r\n if (hour >= startHour && hour <= endHour) {\r\n return VALID_RULE;\r\n }\r\n\r\n this.context.translationParams.startHour = startHour;\r\n this.context.translationParams.endHour = endHour;\r\n return invalidRule(this, context);\r\n },\r\n};\r\n\r\n/**\r\n * From minute rule - time must be from specific minute onwards\r\n */\r\nexport const fromMinuteRule: SchemaRule<{ minute: number }> = {\r\n name: \"fromMinute\",\r\n defaultErrorMessage: \"The :input must be from minute :minute onwards\",\r\n async validate(value: Date, context) {\r\n const inputDate = new Date(value);\r\n const minute = inputDate.getMinutes();\r\n\r\n if (minute >= this.context.options.minute) {\r\n return VALID_RULE;\r\n }\r\n\r\n this.context.translationParams.minute = this.context.options.minute;\r\n\r\n return invalidRule(this, context);\r\n },\r\n};\r\n\r\n/**\r\n * Before minute rule - time must be before specific minute\r\n */\r\nexport const beforeMinuteRule: SchemaRule<{ minute: number }> = {\r\n name: \"beforeMinute\",\r\n defaultErrorMessage: \"The :input must be before minute :minute\",\r\n async validate(value: Date, context) {\r\n const inputDate = new Date(value);\r\n const minute = inputDate.getMinutes();\r\n\r\n if (minute < this.context.options.minute) {\r\n return VALID_RULE;\r\n }\r\n\r\n this.context.translationParams.minute = this.context.options.minute;\r\n\r\n return invalidRule(this, context);\r\n },\r\n};\r\n\r\n/**\r\n * Between minutes rule - time must be between start and end minutes\r\n */\r\nexport const betweenMinutesRule: SchemaRule<{\r\n startMinute: number;\r\n endMinute: number;\r\n}> = {\r\n name: \"betweenMinutes\",\r\n defaultErrorMessage: \"The :input must be between minute :startMinute and :endMinute\",\r\n async validate(value: Date, context) {\r\n const inputDate = new Date(value);\r\n const minute = inputDate.getMinutes();\r\n const { startMinute, endMinute } = this.context.options;\r\n\r\n if (minute >= startMinute && minute <= endMinute) {\r\n return VALID_RULE;\r\n }\r\n\r\n this.context.translationParams.startMinute = startMinute;\r\n this.context.translationParams.endMinute = endMinute;\r\n\r\n return invalidRule(this, context);\r\n },\r\n};\r\n\r\n/**\r\n * Age rule - calculate age from date\r\n */\r\nexport const ageRule: SchemaRule<{ years: number }> = {\r\n name: \"age\",\r\n defaultErrorMessage: \"The :input must be exactly :years years old\",\r\n async validate(value: Date, context) {\r\n const birthDate = new Date(value);\r\n const today = new Date();\r\n let age = today.getFullYear() - birthDate.getFullYear();\r\n const monthDiff = today.getMonth() - birthDate.getMonth();\r\n\r\n if (monthDiff < 0 || (monthDiff === 0 && today.getDate() < birthDate.getDate())) {\r\n age--;\r\n }\r\n\r\n if (age === this.context.options.years) {\r\n return VALID_RULE;\r\n }\r\n\r\n this.context.translationParams.years = this.context.options.years;\r\n\r\n return invalidRule(this, context);\r\n },\r\n};\r\n\r\n/**\r\n * Min age rule - minimum age requirement\r\n */\r\nexport const minAgeRule: SchemaRule<{ years: number }> = {\r\n name: \"minAge\",\r\n defaultErrorMessage: \"The :input must be at least :years years old\",\r\n async validate(value: Date, context) {\r\n const birthDate = new Date(value);\r\n const today = new Date();\r\n let age = today.getFullYear() - birthDate.getFullYear();\r\n const monthDiff = today.getMonth() - birthDate.getMonth();\r\n\r\n if (monthDiff < 0 || (monthDiff === 0 && today.getDate() < birthDate.getDate())) {\r\n age--;\r\n }\r\n\r\n if (age >= this.context.options.years) {\r\n return VALID_RULE;\r\n }\r\n\r\n this.context.translationParams.years = this.context.options.years;\r\n\r\n return invalidRule(this, context);\r\n },\r\n};\r\n\r\n/**\r\n * Max age rule - maximum age requirement\r\n */\r\nexport const maxAgeRule: SchemaRule<{ years: number }> = {\r\n name: \"maxAge\",\r\n defaultErrorMessage: \"The :input must be at most :years years old\",\r\n async validate(value: Date, context) {\r\n const birthDate = new Date(value);\r\n const today = new Date();\r\n let age = today.getFullYear() - birthDate.getFullYear();\r\n const monthDiff = today.getMonth() - birthDate.getMonth();\r\n\r\n if (monthDiff < 0 || (monthDiff === 0 && today.getDate() < birthDate.getDate())) {\r\n age--;\r\n }\r\n\r\n if (age <= this.context.options.years) {\r\n return VALID_RULE;\r\n }\r\n\r\n this.context.translationParams.years = this.context.options.years;\r\n\r\n return invalidRule(this, context);\r\n },\r\n};\r\n\r\n/**\r\n * Week day rule - date must be specific weekday\r\n */\r\nexport const weekDayRule: SchemaRule<{ day: WeekDay }> = {\r\n name: \"weekDay\",\r\n defaultErrorMessage: \"The :input must be a :day\",\r\n async validate(value: Date, context) {\r\n const inputDate = new Date(value);\r\n const dayOfWeek = inputDate.getDay();\r\n const expectedDay = WEEK_DAYS[this.context.options.day];\r\n\r\n if (dayOfWeek === expectedDay) {\r\n return VALID_RULE;\r\n }\r\n\r\n this.context.translatableParams.day = this.context.options.day;\r\n\r\n return invalidRule(this, context);\r\n },\r\n};\r\n"],"mappings":";;;;;;;;;;A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AAmB,MAAM,KAAK,QAAQ,QAAQ;EAE3D,OAAO,YAAY,MAAM,OAAO;CAClC;AACF"}
|
|
1
|
+
{"version":3,"file":"date.mjs","names":[],"sources":["../../../../../../../../seal/src/rules/date/date.ts"],"sourcesContent":["import { get } from \"@mongez/reinforcements\";\r\nimport { invalidRule, VALID_RULE } from \"../../helpers\";\r\nimport { isDateValue } from \"../../helpers/date-helpers\";\r\nimport type { SchemaRule } from \"../../types\";\r\nimport type { WeekDay } from \"../../types/date-types\";\r\nimport { WEEK_DAYS } from \"../../types/date-types\";\r\n\r\n/**\r\n * Date rule - validates date format\r\n */\r\nexport const dateRule: SchemaRule = {\r\n name: \"date\",\r\n defaultErrorMessage: \"The :input must be a valid date\",\r\n async validate(value: any, context) {\r\n if (value instanceof Date && !isNaN(value.getTime())) {\r\n return VALID_RULE;\r\n }\r\n\r\n return invalidRule(this, context);\r\n },\r\n};\r\n\r\n/**\r\n * Min date rule - date must be >= given date or field\r\n * Smart detection: date value or field name\r\n */\r\nexport const minDateRule: SchemaRule<{\r\n dateOrField: Date | string | number;\r\n scope?: \"global\" | \"sibling\";\r\n}> = {\r\n name: \"minDate\",\r\n description: \"The field must be at least the given date or field\",\r\n defaultErrorMessage: \"The :input must be at least :dateOrField\",\r\n async validate(value: Date, context) {\r\n const { dateOrField, scope = \"global\" } = this.context.options;\r\n let compareDate: Date;\r\n\r\n if (isDateValue(dateOrField)) {\r\n // Value comparison\r\n compareDate = new Date(dateOrField);\r\n } else {\r\n // Field comparison\r\n const source = scope === \"sibling\" ? context.parent : context.allValues;\r\n const fieldValue = get(source, dateOrField as string);\r\n\r\n if (fieldValue === undefined) {\r\n return VALID_RULE;\r\n }\r\n\r\n compareDate = new Date(fieldValue);\r\n }\r\n\r\n const inputDate = new Date(value);\r\n\r\n if (inputDate >= compareDate) {\r\n return VALID_RULE;\r\n }\r\n return invalidRule(this, context);\r\n },\r\n};\r\n\r\n/**\r\n * Max date rule - date must be <= given date or field\r\n * Smart detection: date value or field name\r\n */\r\nexport const maxDateRule: SchemaRule<{\r\n dateOrField: Date | string | number;\r\n scope?: \"global\" | \"sibling\";\r\n}> = {\r\n name: \"maxDate\",\r\n defaultErrorMessage: \"The :input must be at most :dateOrField\",\r\n async validate(value: Date, context) {\r\n const { dateOrField, scope = \"global\" } = this.context.options;\r\n let compareDate: Date;\r\n\r\n if (isDateValue(dateOrField)) {\r\n // Value comparison\r\n compareDate = new Date(dateOrField);\r\n } else {\r\n // Field comparison\r\n const source = scope === \"sibling\" ? context.parent : context.allValues;\r\n const fieldValue = get(source, dateOrField as string);\r\n\r\n if (fieldValue === undefined) {\r\n return VALID_RULE;\r\n }\r\n\r\n compareDate = new Date(fieldValue);\r\n }\r\n\r\n const inputDate = new Date(value);\r\n\r\n if (inputDate <= compareDate) {\r\n return VALID_RULE;\r\n }\r\n return invalidRule(this, context);\r\n },\r\n};\r\n\r\n/**\r\n * From today rule - date must be today or in the future\r\n */\r\nexport const fromTodayRule: SchemaRule = {\r\n name: \"fromToday\",\r\n defaultErrorMessage: \"The :input must be today or in the future\",\r\n async validate(value: Date, context) {\r\n const today = new Date();\r\n today.setHours(0, 0, 0, 0);\r\n const inputDate = new Date(value);\r\n inputDate.setHours(0, 0, 0, 0);\r\n\r\n if (inputDate >= today) {\r\n return VALID_RULE;\r\n }\r\n return invalidRule(this, context);\r\n },\r\n};\r\n\r\n/**\r\n * Before today rule - date must be before today\r\n */\r\nexport const beforeTodayRule: SchemaRule = {\r\n name: \"beforeToday\",\r\n defaultErrorMessage: \"The :input must be before today\",\r\n async validate(value: Date, context) {\r\n const today = new Date();\r\n today.setHours(0, 0, 0, 0);\r\n const inputDate = new Date(value);\r\n inputDate.setHours(0, 0, 0, 0);\r\n\r\n if (inputDate < today) {\r\n return VALID_RULE;\r\n }\r\n return invalidRule(this, context);\r\n },\r\n};\r\n\r\n/**\r\n * From hour rule - time must be from specific hour onwards\r\n */\r\nexport const fromHourRule: SchemaRule<{ hour: number }> = {\r\n name: \"fromHour\",\r\n defaultErrorMessage: \"The :input must be from :hour:00 onwards\",\r\n async validate(value: Date, context) {\r\n const inputDate = new Date(value);\r\n const hour = inputDate.getHours();\r\n\r\n if (hour >= this.context.options.hour) {\r\n return VALID_RULE;\r\n }\r\n\r\n this.context.translationParams.hour = this.context.options.hour;\r\n return invalidRule(this, context);\r\n },\r\n};\r\n\r\n/**\r\n * Before hour rule - time must be before specific hour\r\n */\r\nexport const beforeHourRule: SchemaRule<{ hour: number }> = {\r\n name: \"beforeHour\",\r\n defaultErrorMessage: \"The :input must be before :hour:00\",\r\n async validate(value: Date, context) {\r\n const inputDate = new Date(value);\r\n const hour = inputDate.getHours();\r\n\r\n if (hour < this.context.options.hour) {\r\n return VALID_RULE;\r\n }\r\n\r\n this.context.translationParams.hour = this.context.options.hour;\r\n return invalidRule(this, context);\r\n },\r\n};\r\n\r\n/**\r\n * Between hours rule - time must be between start and end hours\r\n */\r\nexport const betweenHoursRule: SchemaRule<{\r\n startHour: number;\r\n endHour: number;\r\n}> = {\r\n name: \"betweenHours\",\r\n defaultErrorMessage: \"The :input must be between :startHour:00 and :endHour:00\",\r\n async validate(value: Date, context) {\r\n const inputDate = new Date(value);\r\n const hour = inputDate.getHours();\r\n const { startHour, endHour } = this.context.options;\r\n\r\n if (hour >= startHour && hour <= endHour) {\r\n return VALID_RULE;\r\n }\r\n\r\n this.context.translationParams.startHour = startHour;\r\n this.context.translationParams.endHour = endHour;\r\n return invalidRule(this, context);\r\n },\r\n};\r\n\r\n/**\r\n * From minute rule - time must be from specific minute onwards\r\n */\r\nexport const fromMinuteRule: SchemaRule<{ minute: number }> = {\r\n name: \"fromMinute\",\r\n defaultErrorMessage: \"The :input must be from minute :minute onwards\",\r\n async validate(value: Date, context) {\r\n const inputDate = new Date(value);\r\n const minute = inputDate.getMinutes();\r\n\r\n if (minute >= this.context.options.minute) {\r\n return VALID_RULE;\r\n }\r\n\r\n this.context.translationParams.minute = this.context.options.minute;\r\n\r\n return invalidRule(this, context);\r\n },\r\n};\r\n\r\n/**\r\n * Before minute rule - time must be before specific minute\r\n */\r\nexport const beforeMinuteRule: SchemaRule<{ minute: number }> = {\r\n name: \"beforeMinute\",\r\n defaultErrorMessage: \"The :input must be before minute :minute\",\r\n async validate(value: Date, context) {\r\n const inputDate = new Date(value);\r\n const minute = inputDate.getMinutes();\r\n\r\n if (minute < this.context.options.minute) {\r\n return VALID_RULE;\r\n }\r\n\r\n this.context.translationParams.minute = this.context.options.minute;\r\n\r\n return invalidRule(this, context);\r\n },\r\n};\r\n\r\n/**\r\n * Between minutes rule - time must be between start and end minutes\r\n */\r\nexport const betweenMinutesRule: SchemaRule<{\r\n startMinute: number;\r\n endMinute: number;\r\n}> = {\r\n name: \"betweenMinutes\",\r\n defaultErrorMessage: \"The :input must be between minute :startMinute and :endMinute\",\r\n async validate(value: Date, context) {\r\n const inputDate = new Date(value);\r\n const minute = inputDate.getMinutes();\r\n const { startMinute, endMinute } = this.context.options;\r\n\r\n if (minute >= startMinute && minute <= endMinute) {\r\n return VALID_RULE;\r\n }\r\n\r\n this.context.translationParams.startMinute = startMinute;\r\n this.context.translationParams.endMinute = endMinute;\r\n\r\n return invalidRule(this, context);\r\n },\r\n};\r\n\r\n/**\r\n * Age rule - calculate age from date\r\n */\r\nexport const ageRule: SchemaRule<{ years: number }> = {\r\n name: \"age\",\r\n defaultErrorMessage: \"The :input must be exactly :years years old\",\r\n async validate(value: Date, context) {\r\n const birthDate = new Date(value);\r\n const today = new Date();\r\n let age = today.getFullYear() - birthDate.getFullYear();\r\n const monthDiff = today.getMonth() - birthDate.getMonth();\r\n\r\n if (monthDiff < 0 || (monthDiff === 0 && today.getDate() < birthDate.getDate())) {\r\n age--;\r\n }\r\n\r\n if (age === this.context.options.years) {\r\n return VALID_RULE;\r\n }\r\n\r\n this.context.translationParams.years = this.context.options.years;\r\n\r\n return invalidRule(this, context);\r\n },\r\n};\r\n\r\n/**\r\n * Min age rule - minimum age requirement\r\n */\r\nexport const minAgeRule: SchemaRule<{ years: number }> = {\r\n name: \"minAge\",\r\n defaultErrorMessage: \"The :input must be at least :years years old\",\r\n async validate(value: Date, context) {\r\n const birthDate = new Date(value);\r\n const today = new Date();\r\n let age = today.getFullYear() - birthDate.getFullYear();\r\n const monthDiff = today.getMonth() - birthDate.getMonth();\r\n\r\n if (monthDiff < 0 || (monthDiff === 0 && today.getDate() < birthDate.getDate())) {\r\n age--;\r\n }\r\n\r\n if (age >= this.context.options.years) {\r\n return VALID_RULE;\r\n }\r\n\r\n this.context.translationParams.years = this.context.options.years;\r\n\r\n return invalidRule(this, context);\r\n },\r\n};\r\n\r\n/**\r\n * Max age rule - maximum age requirement\r\n */\r\nexport const maxAgeRule: SchemaRule<{ years: number }> = {\r\n name: \"maxAge\",\r\n defaultErrorMessage: \"The :input must be at most :years years old\",\r\n async validate(value: Date, context) {\r\n const birthDate = new Date(value);\r\n const today = new Date();\r\n let age = today.getFullYear() - birthDate.getFullYear();\r\n const monthDiff = today.getMonth() - birthDate.getMonth();\r\n\r\n if (monthDiff < 0 || (monthDiff === 0 && today.getDate() < birthDate.getDate())) {\r\n age--;\r\n }\r\n\r\n if (age <= this.context.options.years) {\r\n return VALID_RULE;\r\n }\r\n\r\n this.context.translationParams.years = this.context.options.years;\r\n\r\n return invalidRule(this, context);\r\n },\r\n};\r\n\r\n/**\r\n * Week day rule - date must be specific weekday\r\n */\r\nexport const weekDayRule: SchemaRule<{ day: WeekDay }> = {\r\n name: \"weekDay\",\r\n defaultErrorMessage: \"The :input must be a :day\",\r\n async validate(value: Date, context) {\r\n const inputDate = new Date(value);\r\n const dayOfWeek = inputDate.getDay();\r\n const expectedDay = WEEK_DAYS[this.context.options.day];\r\n\r\n if (dayOfWeek === expectedDay) {\r\n return VALID_RULE;\r\n }\r\n\r\n this.context.translatableParams.day = this.context.options.day;\r\n\r\n return invalidRule(this, context);\r\n },\r\n};\r\n"],"mappings":";;;;;;;;;;AAUA,MAAa,WAAuB;CAClC,MAAM;CACN,qBAAqB;CAC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YAAY,MAAM,OAAO;CAClC;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dimensions.d.mts","names":[],"sources":["
|
|
1
|
+
{"version":3,"file":"dimensions.d.mts","names":[],"sources":["../../../../../../../../seal/src/rules/file/dimensions.ts"],"mappings":";;;;;AAMA;cAAa,YAAA,EAAc,UAAU;EAAG,QAAQ;AAAA;AAAA;AAmBhD;;AAnBgD,cAmBnC,YAAA,EAAc,UAAU;EAAG,QAAQ;AAAA;AAmBhD;;;AAAA,cAAa,aAAA,EAAe,UAAU;EAAG,SAAS;AAAA;;;;cAmBrC,aAAA,EAAe,UAAU;EAAG,SAAS;AAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { VALID_RULE, invalidRule } from "../../helpers/validation-helpers.mjs";
|
|
2
2
|
import "../../helpers/index.mjs";
|
|
3
3
|
|
|
4
|
-
//#region seal/src/rules/file/dimensions.ts
|
|
4
|
+
//#region ../seal/src/rules/file/dimensions.ts
|
|
5
5
|
/**
|
|
6
6
|
* Min width rule - image width validation
|
|
7
7
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dimensions.mjs","names":[],"sources":["
|
|
1
|
+
{"version":3,"file":"dimensions.mjs","names":[],"sources":["../../../../../../../../seal/src/rules/file/dimensions.ts"],"sourcesContent":["import { invalidRule, VALID_RULE } from \"../../helpers\";\r\nimport type { SchemaRule } from \"../../types\";\r\n\r\n/**\r\n * Min width rule - image width validation\r\n */\r\nexport const minWidthRule: SchemaRule<{ minWidth: number }> = {\r\n name: \"minWidth\",\r\n defaultErrorMessage: \"The :input must be at least :minWidth pixels wide\",\r\n async validate(value: any, context) {\r\n const dimensions = await value.dimensions();\r\n\r\n if (dimensions.width >= this.context.options.minWidth) {\r\n return VALID_RULE;\r\n }\r\n\r\n this.context.translationParams.minWidth = this.context.options.minWidth;\r\n\r\n return invalidRule(this, context);\r\n },\r\n};\r\n\r\n/**\r\n * Max width rule - image width validation\r\n */\r\nexport const maxWidthRule: SchemaRule<{ maxWidth: number }> = {\r\n name: \"maxWidth\",\r\n defaultErrorMessage: \"The :input must be at most :maxWidth pixels wide\",\r\n async validate(value: any, context) {\r\n const dimensions = await value.dimensions();\r\n\r\n if (dimensions.width <= this.context.options.maxWidth) {\r\n return VALID_RULE;\r\n }\r\n\r\n this.context.translationParams.maxWidth = this.context.options.maxWidth;\r\n\r\n return invalidRule(this, context);\r\n },\r\n};\r\n\r\n/**\r\n * Min height rule - image height validation\r\n */\r\nexport const minHeightRule: SchemaRule<{ minHeight: number }> = {\r\n name: \"minHeight\",\r\n defaultErrorMessage: \"The :input must be at least :minHeight pixels tall\",\r\n async validate(value: any, context) {\r\n const dimensions = await value.dimensions();\r\n\r\n if (dimensions.height >= this.context.options.minHeight) {\r\n return VALID_RULE;\r\n }\r\n\r\n this.context.translationParams.minHeight = this.context.options.minHeight;\r\n\r\n return invalidRule(this, context);\r\n },\r\n};\r\n\r\n/**\r\n * Max height rule - image height validation\r\n */\r\nexport const maxHeightRule: SchemaRule<{ maxHeight: number }> = {\r\n name: \"maxHeight\",\r\n defaultErrorMessage: \"The :input must be at most :maxHeight pixels tall\",\r\n async validate(value: any, context) {\r\n const dimensions = await value.dimensions();\r\n\r\n if (dimensions.height <= this.context.options.maxHeight) {\r\n return VALID_RULE;\r\n }\r\n\r\n this.context.translationParams.maxHeight = this.context.options.maxHeight;\r\n\r\n return invalidRule(this, context);\r\n },\r\n};\r\n"],"mappings":";;;;;;;AAMA,MAAa,eAAiD;CAC5D,MAAM;CACN,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAGlC,KAAI,MAFqB,MAAM,WAAW,GAE3B,SAAS,KAAK,QAAQ,QAAQ,UAC3C,OAAO;EAGT,KAAK,QAAQ,kBAAkB,WAAW,KAAK,QAAQ,QAAQ;EAE/D,OAAO,YAAY,MAAM,OAAO;CAClC;AACF;;;;AAKA,MAAa,eAAiD;CAC5D,MAAM;CACN,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAGlC,KAAI,MAFqB,MAAM,WAAW,GAE3B,SAAS,KAAK,QAAQ,QAAQ,UAC3C,OAAO;EAGT,KAAK,QAAQ,kBAAkB,WAAW,KAAK,QAAQ,QAAQ;EAE/D,OAAO,YAAY,MAAM,OAAO;CAClC;AACF;;;;AAKA,MAAa,gBAAmD;CAC9D,MAAM;CACN,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAGlC,KAAI,MAFqB,MAAM,WAAW,GAE3B,UAAU,KAAK,QAAQ,QAAQ,WAC5C,OAAO;EAGT,KAAK,QAAQ,kBAAkB,YAAY,KAAK,QAAQ,QAAQ;EAEhE,OAAO,YAAY,MAAM,OAAO;CAClC;AACF;;;;AAKA,MAAa,gBAAmD;CAC9D,MAAM;CACN,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAGlC,KAAI,MAFqB,MAAM,WAAW,GAE3B,UAAU,KAAK,QAAQ,QAAQ,WAC5C,OAAO;EAGT,KAAK,QAAQ,kBAAkB,YAAY,KAAK,QAAQ,QAAQ;EAEhE,OAAO,YAAY,MAAM,OAAO;CAClC;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-size.d.mts","names":[],"sources":["
|
|
1
|
+
{"version":3,"file":"file-size.d.mts","names":[],"sources":["../../../../../../../../seal/src/rules/file/file-size.ts"],"mappings":";;;;;AAMA;cAAa,eAAA,EAAiB,UAAU;EAAG,OAAO;AAAA;AAAA;AAmBlD;;AAnBkD,cAmBrC,eAAA,EAAiB,UAAU;EAAG,OAAO;AAAA"}
|
|
@@ -2,7 +2,7 @@ import { humanizeSize } from "../../helpers/file.utils.mjs";
|
|
|
2
2
|
import { VALID_RULE, invalidRule } from "../../helpers/validation-helpers.mjs";
|
|
3
3
|
import "../../helpers/index.mjs";
|
|
4
4
|
|
|
5
|
-
//#region seal/src/rules/file/file-size.ts
|
|
5
|
+
//#region ../seal/src/rules/file/file-size.ts
|
|
6
6
|
/**
|
|
7
7
|
* Max file size rule
|
|
8
8
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-size.mjs","names":[],"sources":["
|
|
1
|
+
{"version":3,"file":"file-size.mjs","names":[],"sources":["../../../../../../../../seal/src/rules/file/file-size.ts"],"sourcesContent":["import { humanizeSize, invalidRule, VALID_RULE } from \"../../helpers\";\r\nimport type { SchemaRule } from \"../../types\";\r\n\r\n/**\r\n * Max file size rule\r\n */\r\nexport const maxFileSizeRule: SchemaRule<{ maxSize: number }> = {\r\n name: \"maxFileSize\",\r\n defaultErrorMessage: \"The :input must not exceed :maxSize\",\r\n async validate(value: any, context) {\r\n const size = typeof value.size === \"function\" ? await value.size() : value.size;\r\n\r\n if (size <= this.context.options.maxSize) {\r\n return VALID_RULE;\r\n }\r\n\r\n this.context.translationParams.maxSize = humanizeSize(this.context.options.maxSize);\r\n\r\n return invalidRule(this, context);\r\n },\r\n};\r\n\r\n/**\r\n * Min file size rule\r\n */\r\nexport const minFileSizeRule: SchemaRule<{ minSize: number }> = {\r\n name: \"minFileSize\",\r\n defaultErrorMessage: \"The :input must be at least :minSize\",\r\n async validate(value: any, context) {\r\n const size = typeof value.size === \"function\" ? await value.size() : value.size;\r\n\r\n if (size >= this.context.options.minSize) {\r\n return VALID_RULE;\r\n }\r\n\r\n this.context.translationParams.minSize = humanizeSize(this.context.options.minSize);\r\n\r\n return invalidRule(this, context);\r\n },\r\n};\r\n"],"mappings":";;;;;;;;AAMA,MAAa,kBAAmD;CAC9D,MAAM;CACN,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAGlC,KAFa,OAAO,MAAM,SAAS,aAAa,MAAM,MAAM,KAAK,IAAI,MAAM,SAE/D,KAAK,QAAQ,QAAQ,SAC/B,OAAO;EAGT,KAAK,QAAQ,kBAAkB,UAAU,aAAa,KAAK,QAAQ,QAAQ,OAAO;EAElF,OAAO,YAAY,MAAM,OAAO;CAClC;AACF;;;;AAKA,MAAa,kBAAmD;CAC9D,MAAM;CACN,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAGlC,KAFa,OAAO,MAAM,SAAS,aAAa,MAAM,MAAM,KAAK,IAAI,MAAM,SAE/D,KAAK,QAAQ,QAAQ,SAC/B,OAAO;EAGT,KAAK,QAAQ,kBAAkB,UAAU,aAAa,KAAK,QAAQ,QAAQ,OAAO;EAElF,OAAO,YAAY,MAAM,OAAO;CAClC;AACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SchemaRule } from "../../types/rule-types.mjs";
|
|
2
2
|
|
|
3
|
-
//#region seal/src/rules/length/length-rules.d.ts
|
|
3
|
+
//#region ../seal/src/rules/length/length-rules.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* Min length rule - validates minimum length
|
|
6
6
|
* Works for any value with a length property (strings, arrays, etc.)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"length-rules.d.mts","names":[],"sources":["
|
|
1
|
+
{"version":3,"file":"length-rules.d.mts","names":[],"sources":["../../../../../../../../seal/src/rules/length/length-rules.ts"],"mappings":";;;;;AAOA;;cAAa,aAAA,EAAe,UAAU;EAAG,SAAS;AAAA;AAoBlD;;;;AAAA,cAAa,aAAA,EAAe,UAAU;EAAG,SAAS;AAAA;;;;;cAoBrC,iBAAA,EAAmB,UAAU;EACxC,SAAA;EACA,SAAA;AAAA;;;;AAsB0C;cAA/B,UAAA,EAAY,UAAU;EAAG,MAAM;AAAA;;AAmBI;AAiBhD;cAjBa,YAAA,EAAc,UAAU;EAAG,QAAQ;AAAA;AAiBA;AAiBhD;;AAjBgD,cAAnC,YAAA,EAAc,UAAU;EAAG,QAAQ;AAAA;;;;cAiBnC,SAAA,EAAW,UAAU;EAAG,KAAK;AAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { VALID_RULE, invalidRule } from "../../helpers/validation-helpers.mjs";
|
|
2
2
|
import "../../helpers/index.mjs";
|
|
3
3
|
|
|
4
|
-
//#region seal/src/rules/length/length-rules.ts
|
|
4
|
+
//#region ../seal/src/rules/length/length-rules.ts
|
|
5
5
|
/**
|
|
6
6
|
* Min length rule - validates minimum length
|
|
7
7
|
* Works for any value with a length property (strings, arrays, etc.)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"length-rules.mjs","names":[],"sources":["
|
|
1
|
+
{"version":3,"file":"length-rules.mjs","names":[],"sources":["../../../../../../../../seal/src/rules/length/length-rules.ts"],"sourcesContent":["import { invalidRule, VALID_RULE } from \"../../helpers\";\r\nimport type { SchemaRule } from \"../../types\";\r\n\r\n/**\r\n * Min length rule - validates minimum length\r\n * Works for any value with a length property (strings, arrays, etc.)\r\n */\r\nexport const minLengthRule: SchemaRule<{ minLength: number }> = {\r\n name: \"minLength\",\r\n defaultErrorMessage: \"The :input must be at least :minLength characters long\",\r\n async validate(value: any, context) {\r\n const length = typeof value?.length === \"number\" ? value.length : String(value || \"\").length;\r\n\r\n if (length >= this.context.options.minLength) {\r\n return VALID_RULE;\r\n }\r\n\r\n this.context.translationParams.minLength = this.context.options.minLength;\r\n\r\n return invalidRule(this, context);\r\n },\r\n};\r\n\r\n/**\r\n * Max length rule - validates maximum length\r\n * Works for any value with a length property (strings, arrays, etc.)\r\n */\r\nexport const maxLengthRule: SchemaRule<{ maxLength: number }> = {\r\n name: \"maxLength\",\r\n defaultErrorMessage: \"The :input must not exceed :maxLength characters\",\r\n async validate(value: any, context) {\r\n const length = typeof value?.length === \"number\" ? value.length : String(value || \"\").length;\r\n\r\n if (length <= this.context.options.maxLength) {\r\n return VALID_RULE;\r\n }\r\n\r\n this.context.translationParams.maxLength = this.context.options.maxLength;\r\n\r\n return invalidRule(this, context);\r\n },\r\n};\r\n\r\n/**\r\n * Between length rule - validates length is between min and max (inclusive)\r\n * Works for any value with a length property (strings, arrays, etc.)\r\n */\r\nexport const betweenLengthRule: SchemaRule<{\r\n minLength: number;\r\n maxLength: number;\r\n}> = {\r\n name: \"betweenLength\",\r\n defaultErrorMessage: \"The :input must be between :minLength and :maxLength characters long\",\r\n async validate(value: any, context) {\r\n const length = typeof value?.length === \"number\" ? value.length : String(value || \"\").length;\r\n\r\n if (length >= this.context.options.minLength && length <= this.context.options.maxLength) {\r\n return VALID_RULE;\r\n }\r\n\r\n this.context.translationParams.minLength = this.context.options.minLength;\r\n this.context.translationParams.maxLength = this.context.options.maxLength;\r\n\r\n return invalidRule(this, context);\r\n },\r\n};\r\n\r\n/**\r\n * Length rule - validates exact length\r\n * Works for any value with a length property (strings, arrays, etc.)\r\n */\r\nexport const lengthRule: SchemaRule<{ length: number }> = {\r\n name: \"length\",\r\n defaultErrorMessage: \"The :input must be exactly :length characters long\",\r\n async validate(value: any, context) {\r\n const length = typeof value?.length === \"number\" ? value.length : String(value || \"\").length;\r\n\r\n if (length === this.context.options.length) {\r\n return VALID_RULE;\r\n }\r\n\r\n this.context.translationParams.length = this.context.options.length;\r\n\r\n return invalidRule(this, context);\r\n },\r\n};\r\n\r\n/**\r\n * Min words rule - validates minimum word count\r\n */\r\nexport const minWordsRule: SchemaRule<{ minWords: number }> = {\r\n name: \"minWords\",\r\n defaultErrorMessage: \"The :input must be at least :minWords words\",\r\n async validate(value: any, context) {\r\n if (String(value || \"\").split(\" \").length >= this.context.options.minWords) {\r\n return VALID_RULE;\r\n }\r\n\r\n this.context.translationParams.minWords = this.context.options.minWords;\r\n\r\n return invalidRule(this, context);\r\n },\r\n};\r\n\r\n/**\r\n * Max words rule - validates maximum word count\r\n */\r\nexport const maxWordsRule: SchemaRule<{ maxWords: number }> = {\r\n name: \"maxWords\",\r\n defaultErrorMessage: \"The :input must be at most :maxWords words\",\r\n async validate(value: any, context) {\r\n if (String(value || \"\").split(\" \").length <= this.context.options.maxWords) {\r\n return VALID_RULE;\r\n }\r\n\r\n this.context.translationParams.maxWords = this.context.options.maxWords;\r\n\r\n return invalidRule(this, context);\r\n },\r\n};\r\n\r\n/**\r\n * Words rule - validates exact word count\r\n */\r\nexport const wordsRule: SchemaRule<{ words: number }> = {\r\n name: \"words\",\r\n defaultErrorMessage: \"The :input must be exactly :words words\",\r\n async validate(value: any, context) {\r\n if (String(value || \"\").split(\" \").length === this.context.options.words) {\r\n return VALID_RULE;\r\n }\r\n\r\n this.context.translationParams.words = this.context.options.words;\r\n\r\n return invalidRule(this, context);\r\n },\r\n};\r\n"],"mappings":";;;;;;;;AAOA,MAAa,gBAAmD;CAC9D,MAAM;CACN,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAGlC,KAFe,OAAO,OAAO,WAAW,WAAW,MAAM,SAAS,OAAO,SAAS,EAAE,EAAE,WAExE,KAAK,QAAQ,QAAQ,WACjC,OAAO;EAGT,KAAK,QAAQ,kBAAkB,YAAY,KAAK,QAAQ,QAAQ;EAEhE,OAAO,YAAY,MAAM,OAAO;CAClC;AACF;;;;;AAMA,MAAa,gBAAmD;CAC9D,MAAM;CACN,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAGlC,KAFe,OAAO,OAAO,WAAW,WAAW,MAAM,SAAS,OAAO,SAAS,EAAE,EAAE,WAExE,KAAK,QAAQ,QAAQ,WACjC,OAAO;EAGT,KAAK,QAAQ,kBAAkB,YAAY,KAAK,QAAQ,QAAQ;EAEhE,OAAO,YAAY,MAAM,OAAO;CAClC;AACF;;;;;AAMA,MAAa,oBAGR;CACH,MAAM;CACN,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAClC,MAAM,SAAS,OAAO,OAAO,WAAW,WAAW,MAAM,SAAS,OAAO,SAAS,EAAE,EAAE;EAEtF,IAAI,UAAU,KAAK,QAAQ,QAAQ,aAAa,UAAU,KAAK,QAAQ,QAAQ,WAC7E,OAAO;EAGT,KAAK,QAAQ,kBAAkB,YAAY,KAAK,QAAQ,QAAQ;EAChE,KAAK,QAAQ,kBAAkB,YAAY,KAAK,QAAQ,QAAQ;EAEhE,OAAO,YAAY,MAAM,OAAO;CAClC;AACF;;;;;AAMA,MAAa,aAA6C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ts
|
|
4
4
|
/**
|
|
5
5
|
* Min rule - value must be equal or greater than minimum
|
|
6
6
|
* Supports field names with sibling scope
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"number-rules.d.mts","names":[],"sources":["
|
|
1
|
+
{"version":3,"file":"number-rules.d.mts","names":[],"sources":["../../../../../../../../seal/src/rules/number/number-rules.ts"],"mappings":";;;;;AAQA;;cAAa,OAAA,EAAS,UAAU;EAC9B,GAAA;EACA,KAAA;AAAA;;;AAAK;AAwCP;cAAa,OAAA,EAAS,UAAU;EAC9B,GAAA;EACA,KAAA;AAAA;;;;AAAK;cAwCM,eAAA,EAAiB,UAAU;EACtC,KAAA;EACA,KAAA;AAAA;;;;;cAwCW,YAAA,EAAc,UAAU;EACnC,KAAA;EACA,KAAA;AAAA;;;;cAuCW,YAAA,EAAc,UAU1B;;AAjDM;AAuCP;cAea,YAAA,EAAc,UAU1B;;;AAfA;cAoBY,OAAA,EAAS,UAUrB;;;;cAKY,QAAA,EAAU,UAUtB;AAzBD;;;AAAA,cA8Ba,UAAA,EAAY,UAAU;EAAG,KAAK;AAAA;;;;AAL1C;cAuBY,kBAAA,EAAoB,UAAU;EACzC,GAAA;EACA,GAAA;EACA,KAAA;AAAA"}
|
|
@@ -2,7 +2,7 @@ import { VALID_RULE, invalidRule } from "../../helpers/validation-helpers.mjs";
|
|
|
2
2
|
import "../../helpers/index.mjs";
|
|
3
3
|
import { get } from "@mongez/reinforcements";
|
|
4
4
|
|
|
5
|
-
//#region seal/src/rules/number/number-rules.ts
|
|
5
|
+
//#region ../seal/src/rules/number/number-rules.ts
|
|
6
6
|
/**
|
|
7
7
|
* Min rule - value must be equal or greater than minimum
|
|
8
8
|
* Supports field names with sibling scope
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"number-rules.mjs","names":[],"sources":["C:/Work/Warlock.js/seal/src/rules/number/number-rules.ts"],"sourcesContent":["import { get } from \"@mongez/reinforcements\";\r\nimport { invalidRule, VALID_RULE } from \"../../helpers\";\r\nimport type { SchemaRule } from \"../../types\";\r\n\r\n/**\r\n * Min rule - value must be equal or greater than minimum\r\n * Supports field names with sibling scope\r\n */\r\nexport const minRule: SchemaRule<{\r\n min: number | string;\r\n scope?: \"global\" | \"sibling\";\r\n}> = {\r\n name: \"min\",\r\n defaultErrorMessage: \"The :input must be at least :min\",\r\n async validate(value: any, context) {\r\n const { min, scope = \"global\" } = this.context.options;\r\n let compareMin: number;\r\n\r\n if (typeof min === \"number\") {\r\n compareMin = min;\r\n this.context.translationParams.min = min;\r\n } else {\r\n const source = scope === \"sibling\" ? context.parent : context.allValues;\r\n const fieldValue = get(source, min);\r\n\r\n if (fieldValue === undefined) {\r\n return VALID_RULE;\r\n }\r\n\r\n this.context.translatableParams.min = min;\r\n\r\n compareMin = Number(fieldValue);\r\n\r\n if (isNaN(compareMin)) {\r\n return VALID_RULE;\r\n }\r\n }\r\n\r\n if (value >= compareMin) {\r\n return VALID_RULE;\r\n }\r\n\r\n return invalidRule(this, context);\r\n },\r\n};\r\n\r\n/**\r\n * Max rule - value must be equal or less than maximum\r\n * Supports field names with sibling scope\r\n */\r\nexport const maxRule: SchemaRule<{\r\n max: number | string;\r\n scope?: \"global\" | \"sibling\";\r\n}> = {\r\n name: \"max\",\r\n defaultErrorMessage: \"The :input must equal to or less than :max\",\r\n async validate(value: any, context) {\r\n const { max, scope = \"global\" } = this.context.options;\r\n let compareMax: number;\r\n\r\n if (typeof max === \"number\") {\r\n compareMax = max;\r\n this.context.translationParams.max = max;\r\n } else {\r\n const source = scope === \"sibling\" ? context.parent : context.allValues;\r\n const fieldValue = get(source, max);\r\n\r\n if (fieldValue === undefined) {\r\n return VALID_RULE;\r\n }\r\n\r\n this.context.translatableParams.max = max;\r\n\r\n compareMax = Number(fieldValue);\r\n\r\n if (isNaN(compareMax)) {\r\n return VALID_RULE;\r\n }\r\n }\r\n\r\n if (value <= compareMax) {\r\n return VALID_RULE;\r\n }\r\n\r\n return invalidRule(this, context);\r\n },\r\n};\r\n\r\n/**\r\n * Greater than rule - value must be strictly greater than minimum\r\n * Supports field names with sibling scope\r\n */\r\nexport const greaterThanRule: SchemaRule<{\r\n value: number | string;\r\n scope?: \"global\" | \"sibling\";\r\n}> = {\r\n name: \"greaterThan\",\r\n defaultErrorMessage: \"The :input must be greater than :value\",\r\n async validate(value: any, context) {\r\n const { value: compareValue, scope = \"global\" } = this.context.options;\r\n let compareNumber: number;\r\n\r\n if (typeof compareValue === \"number\") {\r\n compareNumber = compareValue;\r\n this.context.translationParams.value = compareValue;\r\n } else {\r\n const source = scope === \"sibling\" ? context.parent : context.allValues;\r\n const fieldValue = get(source, compareValue);\r\n\r\n if (fieldValue === undefined) {\r\n return VALID_RULE;\r\n }\r\n\r\n this.context.translatableParams.value = compareValue;\r\n\r\n compareNumber = Number(fieldValue);\r\n\r\n if (isNaN(compareNumber)) {\r\n return VALID_RULE;\r\n }\r\n }\r\n\r\n if (value > compareNumber) {\r\n return VALID_RULE;\r\n }\r\n\r\n return invalidRule(this, context);\r\n },\r\n};\r\n\r\n/**\r\n * Less than rule - value must be strictly less than maximum\r\n * Supports field names with sibling scope\r\n */\r\nexport const lessThanRule: SchemaRule<{\r\n value: number | string;\r\n scope?: \"global\" | \"sibling\";\r\n}> = {\r\n name: \"lessThan\",\r\n defaultErrorMessage: \"The :input must be less than :value\",\r\n async validate(value: any, context) {\r\n const { value: compareValue, scope = \"global\" } = this.context.options;\r\n let compareNumber: number;\r\n\r\n if (typeof compareValue === \"number\") {\r\n compareNumber = compareValue;\r\n this.context.translationParams.value = compareValue;\r\n } else {\r\n const source = scope === \"sibling\" ? context.parent : context.allValues;\r\n const fieldValue = get(source, compareValue);\r\n\r\n if (fieldValue === undefined) {\r\n return VALID_RULE;\r\n }\r\n\r\n this.context.translatableParams.value = compareValue;\r\n\r\n compareNumber = Number(fieldValue);\r\n\r\n if (isNaN(compareNumber)) {\r\n return VALID_RULE;\r\n }\r\n }\r\n\r\n if (value < compareNumber) {\r\n return VALID_RULE;\r\n }\r\n\r\n return invalidRule(this, context);\r\n },\r\n};\r\n\r\n/**\r\n * Positive rule - value must be greater than 0\r\n */\r\nexport const positiveRule: SchemaRule = {\r\n name: \"positive\",\r\n defaultErrorMessage: \"The :input must be a positive number\",\r\n async validate(value: any, context) {\r\n if (value > 0) {\r\n return VALID_RULE;\r\n }\r\n\r\n return invalidRule(this, context);\r\n },\r\n};\r\n\r\n/**\r\n * Negative rule - value must be less than 0\r\n */\r\nexport const negativeRule: SchemaRule = {\r\n name: \"negative\",\r\n defaultErrorMessage: \"The :input must be a negative number\",\r\n async validate(value: any, context) {\r\n if (value < 0) {\r\n return VALID_RULE;\r\n }\r\n\r\n return invalidRule(this, context);\r\n },\r\n};\r\n\r\n/**\r\n * Odd rule - value must be an odd number\r\n */\r\nexport const oddRule: SchemaRule = {\r\n name: \"odd\",\r\n defaultErrorMessage: \"The :input must be an odd number\",\r\n async validate(value: any, context) {\r\n if (value % 2 !== 0) {\r\n return VALID_RULE;\r\n }\r\n\r\n return invalidRule(this, context);\r\n },\r\n};\r\n\r\n/**\r\n * Even rule - value must be an even number\r\n */\r\nexport const evenRule: SchemaRule = {\r\n name: \"even\",\r\n defaultErrorMessage: \"The :input must be an even number\",\r\n async validate(value: any, context) {\r\n if (value % 2 === 0) {\r\n return VALID_RULE;\r\n }\r\n\r\n return invalidRule(this, context);\r\n },\r\n};\r\n\r\n/**\r\n * Modulo rule - value must be divisible by given number\r\n */\r\nexport const moduloRule: SchemaRule<{ value: number }> = {\r\n name: \"modulo\",\r\n defaultErrorMessage: \"The :input must be divisible by :value\",\r\n async validate(value: any, context) {\r\n if (value % this.context.options.value === 0) {\r\n return VALID_RULE;\r\n }\r\n\r\n this.context.translationParams.value = this.context.options.value;\r\n\r\n return invalidRule(this, context);\r\n },\r\n};\r\n\r\n/**\r\n * Between rule - value must be between the given two numbers (Inclusive)\r\n * Supports field names with sibling scope\r\n */\r\nexport const betweenNumbersRule: SchemaRule<{\r\n min: number | string;\r\n max: number | string;\r\n scope?: \"global\" | \"sibling\";\r\n}> = {\r\n name: \"betweenNumbers\",\r\n defaultErrorMessage: \"The :input must be between :min and :max\",\r\n async validate(value: any, context) {\r\n const { min, max, scope = \"global\" } = this.context.options;\r\n\r\n // Extract min value\r\n let compareMin: number;\r\n if (typeof min === \"number\") {\r\n compareMin = min;\r\n this.context.translationParams.min = min;\r\n } else {\r\n const source = scope === \"sibling\" ? context.parent : context.allValues;\r\n const fieldValue = get(source, min);\r\n\r\n if (fieldValue === undefined) {\r\n return VALID_RULE;\r\n }\r\n\r\n this.context.translatableParams.min = min;\r\n\r\n compareMin = Number(fieldValue);\r\n if (isNaN(compareMin)) {\r\n return VALID_RULE;\r\n }\r\n }\r\n\r\n // Extract max value\r\n let compareMax: number;\r\n if (typeof max === \"number\") {\r\n compareMax = max;\r\n this.context.translationParams.max = max;\r\n } else {\r\n const source = scope === \"sibling\" ? context.parent : context.allValues;\r\n const fieldValue = get(source, max);\r\n\r\n if (fieldValue === undefined) {\r\n return VALID_RULE;\r\n }\r\n\r\n this.context.translatableParams.max = max;\r\n\r\n compareMax = Number(fieldValue);\r\n if (isNaN(compareMax)) {\r\n return VALID_RULE;\r\n }\r\n }\r\n\r\n if (value >= compareMin && value <= compareMax) {\r\n return VALID_RULE;\r\n }\r\n\r\n return invalidRule(this, context);\r\n },\r\n};\r\n"],"mappings":";;;;;;;;;AAQA,MAAa,UAGR;CACH,MAAM;CACN,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAClC,MAAM,EAAE,KAAK,QAAQ,aAAa,KAAK,QAAQ;EAC/C,IAAI;EAEJ,IAAI,OAAO,QAAQ,UAAU;GAC3B,aAAa;GACb,KAAK,QAAQ,kBAAkB,MAAM;EACvC,OAAO;GAEL,MAAM,aAAa,IADJ,UAAU,YAAY,QAAQ,SAAS,QAAQ,WAC/B,GAAG;GAElC,IAAI,eAAe,QACjB,OAAO;GAGT,KAAK,QAAQ,mBAAmB,MAAM;GAEt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AAQ,QAAQ;EAE5D,OAAO,YAAY,MAAM,OAAO;CAClC;AACF;;;;;AAMA,MAAa,qBAIR;CACH,MAAM;CACN,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAClC,MAAM,EAAE,KAAK,KAAK,QAAQ,aAAa,KAAK,QAAQ;EAGpD,IAAI;EACJ,IAAI,OAAO,QAAQ,UAAU;GAC3B,aAAa;GACb,KAAK,QAAQ,kBAAkB,MAAM;EACvC,OAAO;GAEL,MAAM,aAAa,IADJ,UAAU,YAAY,QAAQ,SAAS,QAAQ,WAC/B,GAAG;GAElC,IAAI,eAAe,QACjB,OAAO;GAGT,KAAK,QAAQ,mBAAmB,MAAM;GAEtC,aAAa,OAAO,UAAU;GAC9B,IAAI,MAAM,UAAU,GAClB,OAAO;EAEX;EAGA,IAAI;EACJ,IAAI,OAAO,QAAQ,UAAU;GAC3B,aAAa;GACb,KAAK,QAAQ,kBAAkB,MAAM;EACvC,OAAO;GAEL,MAAM,aAAa,IADJ,UAAU,YAAY,QAAQ,SAAS,QAAQ,WAC/B,GAAG;GAElC,IAAI,eAAe,QACjB,OAAO;GAGT,KAAK,QAAQ,mBAAmB,MAAM;GAEtC,aAAa,OAAO,UAAU;GAC9B,IAAI,MAAM,UAAU,GAClB,OAAO;EAEX;EAEA,IAAI,SAAS,cAAc,SAAS,YAClC,OAAO;EAGT,OAAO,YAAY,MAAM,OAAO;CAClC;AACF"}
|
|
1
|
+
{"version":3,"file":"number-rules.mjs","names":[],"sources":["../../../../../../../../seal/src/rules/number/number-rules.ts"],"sourcesContent":["import { get } from \"@mongez/reinforcements\";\r\nimport { invalidRule, VALID_RULE } from \"../../helpers\";\r\nimport type { SchemaRule } from \"../../types\";\r\n\r\n/**\r\n * Min rule - value must be equal or greater than minimum\r\n * Supports field names with sibling scope\r\n */\r\nexport const minRule: SchemaRule<{\r\n min: number | string;\r\n scope?: \"global\" | \"sibling\";\r\n}> = {\r\n name: \"min\",\r\n defaultErrorMessage: \"The :input must be at least :min\",\r\n async validate(value: any, context) {\r\n const { min, scope = \"global\" } = this.context.options;\r\n let compareMin: number;\r\n\r\n if (typeof min === \"number\") {\r\n compareMin = min;\r\n this.context.translationParams.min = min;\r\n } else {\r\n const source = scope === \"sibling\" ? context.parent : context.allValues;\r\n const fieldValue = get(source, min);\r\n\r\n if (fieldValue === undefined) {\r\n return VALID_RULE;\r\n }\r\n\r\n this.context.translatableParams.min = min;\r\n\r\n compareMin = Number(fieldValue);\r\n\r\n if (isNaN(compareMin)) {\r\n return VALID_RULE;\r\n }\r\n }\r\n\r\n if (value >= compareMin) {\r\n return VALID_RULE;\r\n }\r\n\r\n return invalidRule(this, context);\r\n },\r\n};\r\n\r\n/**\r\n * Max rule - value must be equal or less than maximum\r\n * Supports field names with sibling scope\r\n */\r\nexport const maxRule: SchemaRule<{\r\n max: number | string;\r\n scope?: \"global\" | \"sibling\";\r\n}> = {\r\n name: \"max\",\r\n defaultErrorMessage: \"The :input must equal to or less than :max\",\r\n async validate(value: any, context) {\r\n const { max, scope = \"global\" } = this.context.options;\r\n let compareMax: number;\r\n\r\n if (typeof max === \"number\") {\r\n compareMax = max;\r\n this.context.translationParams.max = max;\r\n } else {\r\n const source = scope === \"sibling\" ? context.parent : context.allValues;\r\n const fieldValue = get(source, max);\r\n\r\n if (fieldValue === undefined) {\r\n return VALID_RULE;\r\n }\r\n\r\n this.context.translatableParams.max = max;\r\n\r\n compareMax = Number(fieldValue);\r\n\r\n if (isNaN(compareMax)) {\r\n return VALID_RULE;\r\n }\r\n }\r\n\r\n if (value <= compareMax) {\r\n return VALID_RULE;\r\n }\r\n\r\n return invalidRule(this, context);\r\n },\r\n};\r\n\r\n/**\r\n * Greater than rule - value must be strictly greater than minimum\r\n * Supports field names with sibling scope\r\n */\r\nexport const greaterThanRule: SchemaRule<{\r\n value: number | string;\r\n scope?: \"global\" | \"sibling\";\r\n}> = {\r\n name: \"greaterThan\",\r\n defaultErrorMessage: \"The :input must be greater than :value\",\r\n async validate(value: any, context) {\r\n const { value: compareValue, scope = \"global\" } = this.context.options;\r\n let compareNumber: number;\r\n\r\n if (typeof compareValue === \"number\") {\r\n compareNumber = compareValue;\r\n this.context.translationParams.value = compareValue;\r\n } else {\r\n const source = scope === \"sibling\" ? context.parent : context.allValues;\r\n const fieldValue = get(source, compareValue);\r\n\r\n if (fieldValue === undefined) {\r\n return VALID_RULE;\r\n }\r\n\r\n this.context.translatableParams.value = compareValue;\r\n\r\n compareNumber = Number(fieldValue);\r\n\r\n if (isNaN(compareNumber)) {\r\n return VALID_RULE;\r\n }\r\n }\r\n\r\n if (value > compareNumber) {\r\n return VALID_RULE;\r\n }\r\n\r\n return invalidRule(this, context);\r\n },\r\n};\r\n\r\n/**\r\n * Less than rule - value must be strictly less than maximum\r\n * Supports field names with sibling scope\r\n */\r\nexport const lessThanRule: SchemaRule<{\r\n value: number | string;\r\n scope?: \"global\" | \"sibling\";\r\n}> = {\r\n name: \"lessThan\",\r\n defaultErrorMessage: \"The :input must be less than :value\",\r\n async validate(value: any, context) {\r\n const { value: compareValue, scope = \"global\" } = this.context.options;\r\n let compareNumber: number;\r\n\r\n if (typeof compareValue === \"number\") {\r\n compareNumber = compareValue;\r\n this.context.translationParams.value = compareValue;\r\n } else {\r\n const source = scope === \"sibling\" ? context.parent : context.allValues;\r\n const fieldValue = get(source, compareValue);\r\n\r\n if (fieldValue === undefined) {\r\n return VALID_RULE;\r\n }\r\n\r\n this.context.translatableParams.value = compareValue;\r\n\r\n compareNumber = Number(fieldValue);\r\n\r\n if (isNaN(compareNumber)) {\r\n return VALID_RULE;\r\n }\r\n }\r\n\r\n if (value < compareNumber) {\r\n return VALID_RULE;\r\n }\r\n\r\n return invalidRule(this, context);\r\n },\r\n};\r\n\r\n/**\r\n * Positive rule - value must be greater than 0\r\n */\r\nexport const positiveRule: SchemaRule = {\r\n name: \"positive\",\r\n defaultErrorMessage: \"The :input must be a positive number\",\r\n async validate(value: any, context) {\r\n if (value > 0) {\r\n return VALID_RULE;\r\n }\r\n\r\n return invalidRule(this, context);\r\n },\r\n};\r\n\r\n/**\r\n * Negative rule - value must be less than 0\r\n */\r\nexport const negativeRule: SchemaRule = {\r\n name: \"negative\",\r\n defaultErrorMessage: \"The :input must be a negative number\",\r\n async validate(value: any, context) {\r\n if (value < 0) {\r\n return VALID_RULE;\r\n }\r\n\r\n return invalidRule(this, context);\r\n },\r\n};\r\n\r\n/**\r\n * Odd rule - value must be an odd number\r\n */\r\nexport const oddRule: SchemaRule = {\r\n name: \"odd\",\r\n defaultErrorMessage: \"The :input must be an odd number\",\r\n async validate(value: any, context) {\r\n if (value % 2 !== 0) {\r\n return VALID_RULE;\r\n }\r\n\r\n return invalidRule(this, context);\r\n },\r\n};\r\n\r\n/**\r\n * Even rule - value must be an even number\r\n */\r\nexport const evenRule: SchemaRule = {\r\n name: \"even\",\r\n defaultErrorMessage: \"The :input must be an even number\",\r\n async validate(value: any, context) {\r\n if (value % 2 === 0) {\r\n return VALID_RULE;\r\n }\r\n\r\n return invalidRule(this, context);\r\n },\r\n};\r\n\r\n/**\r\n * Modulo rule - value must be divisible by given number\r\n */\r\nexport const moduloRule: SchemaRule<{ value: number }> = {\r\n name: \"modulo\",\r\n defaultErrorMessage: \"The :input must be divisible by :value\",\r\n async validate(value: any, context) {\r\n if (value % this.context.options.value === 0) {\r\n return VALID_RULE;\r\n }\r\n\r\n this.context.translationParams.value = this.context.options.value;\r\n\r\n return invalidRule(this, context);\r\n },\r\n};\r\n\r\n/**\r\n * Between rule - value must be between the given two numbers (Inclusive)\r\n * Supports field names with sibling scope\r\n */\r\nexport const betweenNumbersRule: SchemaRule<{\r\n min: number | string;\r\n max: number | string;\r\n scope?: \"global\" | \"sibling\";\r\n}> = {\r\n name: \"betweenNumbers\",\r\n defaultErrorMessage: \"The :input must be between :min and :max\",\r\n async validate(value: any, context) {\r\n const { min, max, scope = \"global\" } = this.context.options;\r\n\r\n // Extract min value\r\n let compareMin: number;\r\n if (typeof min === \"number\") {\r\n compareMin = min;\r\n this.context.translationParams.min = min;\r\n } else {\r\n const source = scope === \"sibling\" ? context.parent : context.allValues;\r\n const fieldValue = get(source, min);\r\n\r\n if (fieldValue === undefined) {\r\n return VALID_RULE;\r\n }\r\n\r\n this.context.translatableParams.min = min;\r\n\r\n compareMin = Number(fieldValue);\r\n if (isNaN(compareMin)) {\r\n return VALID_RULE;\r\n }\r\n }\r\n\r\n // Extract max value\r\n let compareMax: number;\r\n if (typeof max === \"number\") {\r\n compareMax = max;\r\n this.context.translationParams.max = max;\r\n } else {\r\n const source = scope === \"sibling\" ? context.parent : context.allValues;\r\n const fieldValue = get(source, max);\r\n\r\n if (fieldValue === undefined) {\r\n return VALID_RULE;\r\n }\r\n\r\n this.context.translatableParams.max = max;\r\n\r\n compareMax = Number(fieldValue);\r\n if (isNaN(compareMax)) {\r\n return VALID_RULE;\r\n }\r\n }\r\n\r\n if (value >= compareMin && value <= compareMax) {\r\n return VALID_RULE;\r\n }\r\n\r\n return invalidRule(this, context);\r\n },\r\n};\r\n"],"mappings":";;;;;;;;;AAQA,MAAa,UAGR;CACH,MAAM;CACN,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAClC,MAAM,EAAE,KAAK,QAAQ,aAAa,KAAK,QAAQ;EAC/C,IAAI;EAEJ,IAAI,OAAO,QAAQ,UAAU;GAC3B,aAAa;GACb,KAAK,QAAQ,kBAAkB,MAAM;EACvC,OAAO;GAEL,MAAM,aAAa,IADJ,UAAU,YAAY,QAAQ,SAAS,QAAQ,WAC/B,GAAG;GAElC,IAAI,eAAe,QACjB,OAAO;GAGT,KAAK,QAAQ,mBAAmB,MAAM;GAEtC,aAAa,OAAO,UAAU;GAE9B,IAAI,MAAM,UAAU,GAClB,OAAO;EAEX;EAEA,IAAI,SAAS,YACX,OAAO;EAGT,OAAO,YAAY,MAAM,OAAO;CAClC;AACF;;;;;AAMA,MAAa,UAGR;CACH,MAAM;CACN,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAClC,M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AO,QAAQ,UAAU;GAC3B,aAAa;GACb,KAAK,QAAQ,kBAAkB,MAAM;EACvC,OAAO;GAEL,MAAM,aAAa,IADJ,UAAU,YAAY,QAAQ,SAAS,QAAQ,WAC/B,GAAG;GAElC,IAAI,eAAe,QACjB,OAAO;GAGT,KAAK,QAAQ,mBAAmB,MAAM;GAEtC,aAAa,OAAO,UAAU;GAC9B,IAAI,MAAM,UAAU,GAClB,OAAO;EAEX;EAGA,IAAI;EACJ,IAAI,OAAO,QAAQ,UAAU;GAC3B,aAAa;GACb,KAAK,QAAQ,kBAAkB,MAAM;EACvC,OAAO;GAEL,MAAM,aAAa,IADJ,UAAU,YAAY,QAAQ,SAAS,QAAQ,WAC/B,GAAG;GAElC,IAAI,eAAe,QACjB,OAAO;GAGT,KAAK,QAAQ,mBAAmB,MAAM;GAEtC,aAAa,OAAO,UAAU;GAC9B,IAAI,MAAM,UAAU,GAClB,OAAO;EAEX;EAEA,IAAI,SAAS,cAAc,SAAS,YAClC,OAAO;EAGT,OAAO,YAAY,MAAM,OAAO;CAClC;AACF"}
|
|
@@ -3,7 +3,7 @@ import { VALID_RULE, invalidRule } from "../../helpers/validation-helpers.mjs";
|
|
|
3
3
|
import "../../helpers/index.mjs";
|
|
4
4
|
import { isEmptyValue } from "../../helpers/is-empty-value.mjs";
|
|
5
5
|
|
|
6
|
-
//#region seal/src/rules/scalar/accepted-rule.ts
|
|
6
|
+
//#region ../seal/src/rules/scalar/accepted-rule.ts
|
|
7
7
|
const isAcceptedValue = (value) => {
|
|
8
8
|
return [
|
|
9
9
|
"1",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accepted-rule.mjs","names":[],"sources":["
|
|
1
|
+
{"version":3,"file":"accepted-rule.mjs","names":[],"sources":["../../../../../../../../seal/src/rules/scalar/accepted-rule.ts"],"sourcesContent":["import { getFieldValue, invalidRule, VALID_RULE } from \"../../helpers\";\r\nimport { isEmptyValue } from \"../../helpers/is-empty-value\";\r\nimport type { SchemaRule } from \"../../types\";\r\n\r\nconst isAcceptedValue = (value: any) => {\r\n return [\"1\", \"true\", \"yes\", \"y\", \"on\", 1, true, \"Yes\", \"Y\", \"On\"].includes(value);\r\n};\r\n\r\n/**\r\n * Validate value as accepted if it equals:\r\n * 1 | \"1\" | true | \"true\" | \"yes\" | \"y\" | \"on\"\r\n */\r\nexport const acceptedRule: SchemaRule = {\r\n name: \"accepted\",\r\n defaultErrorMessage: \"The :input must be accepted\",\r\n description:\r\n \"The value must be accepted if it equals: 1 | '1' | true | 'true' | 'yes' | 'y' | 'on' | 1 | true | 'Yes' | 'Y' | 'On'\",\r\n async validate(value: any, context) {\r\n if (isAcceptedValue(value)) {\r\n return VALID_RULE;\r\n }\r\n\r\n return invalidRule(this, context);\r\n },\r\n};\r\n\r\n/**\r\n * Accepted value if another field's value equals to a specific value\r\n */\r\nexport const acceptedIfRule: SchemaRule<{ field: string; value: any }> = {\r\n name: \"acceptedIf\",\r\n description: \"The field must be accepted if :field's value equals to :value\",\r\n defaultErrorMessage: \"The :input must be accepted\",\r\n async validate(value: any, context) {\r\n const fieldValue = getFieldValue(this, context);\r\n const { value: expectedValue } = this.context.options;\r\n\r\n this.context.translatableParams.field = this.context.options.field;\r\n this.context.translatableParams.value = this.context.options.value;\r\n if (fieldValue !== expectedValue) {\r\n return invalidRule(this, context);\r\n }\r\n\r\n if (!isAcceptedValue(value)) {\r\n return invalidRule(this, context);\r\n }\r\n\r\n return VALID_RULE;\r\n },\r\n};\r\n\r\n/**\r\n * Accepted if another field is not equal to the given value\r\n */\r\nexport const acceptedUnlessRule: SchemaRule<{ field: string; value: any }> = {\r\n name: \"acceptedUnless\",\r\n description: \"The field must be accepted if :field's value is not equal to :value\",\r\n defaultErrorMessage: \"The :input must be accepted\",\r\n async validate(value: any, context) {\r\n const fieldValue = getFieldValue(this, context);\r\n const { value: expectedValue } = this.context.options;\r\n\r\n this.context.translatableParams.field = this.context.options.field;\r\n this.context.translatableParams.value = this.context.options.value;\r\n\r\n if (fieldValue === expectedValue) {\r\n return invalidRule(this, context);\r\n }\r\n\r\n if (!isAcceptedValue(value)) {\r\n return invalidRule(this, context);\r\n }\r\n\r\n return VALID_RULE;\r\n },\r\n};\r\n\r\n/**\r\n * Accepted if another field is required\r\n */\r\nexport const acceptedIfRequiredRule: SchemaRule<{ field: string }> = {\r\n name: \"acceptedIfRequired\",\r\n description: \"The field must be accepted if :field is required\",\r\n defaultErrorMessage: \"The :input must be accepted\",\r\n async validate(value: any, context) {\r\n const fieldValue = getFieldValue(this, context);\r\n this.context.translatableParams.field = this.context.options.field;\r\n\r\n if (isEmptyValue(fieldValue)) {\r\n return invalidRule(this, context);\r\n }\r\n\r\n if (!isAcceptedValue(value)) {\r\n return invalidRule(this, context);\r\n }\r\n\r\n return VALID_RULE;\r\n },\r\n};\r\n\r\n/**\r\n * Accepted if another field is present\r\n */\r\nexport const acceptedIfPresentRule: SchemaRule<{ field: string }> = {\r\n name: \"acceptedIfPresent\",\r\n description: \"The field must be accepted if :field is present\",\r\n defaultErrorMessage: \"The :input must be accepted\",\r\n async validate(value: any, context) {\r\n const fieldValue = getFieldValue(this, context);\r\n this.context.translatableParams.field = this.context.options.field;\r\n\r\n if (fieldValue === undefined) {\r\n return invalidRule(this, context);\r\n }\r\n\r\n if (!isAcceptedValue(value)) {\r\n return invalidRule(this, context);\r\n }\r\n\r\n return VALID_RULE;\r\n },\r\n};\r\n\r\n/**\r\n * Accepted if another field is missing\r\n */\r\nexport const acceptedWithoutRule: SchemaRule<{ field: string }> = {\r\n name: \"acceptedWithout\",\r\n description: \"The field must be accepted if :field is missing\",\r\n defaultErrorMessage: \"The :input must be accepted\",\r\n async validate(value: any, context) {\r\n const fieldValue = getFieldValue(this, context);\r\n this.context.translatableParams.field = this.context.options.field;\r\n\r\n if (fieldValue !== undefined) {\r\n return invalidRule(this, context);\r\n }\r\n\r\n if (!isAcceptedValue(value)) {\r\n return invalidRule(this, context);\r\n }\r\n\r\n return VALID_RULE;\r\n },\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rB,MAAM,SAAS,OAAY,SAAS;EAClC,MAAM,aAAa,cAAc,MAAM,OAAO;EAC9C,KAAK,QAAQ,mBAAmB,QAAQ,KAAK,QAAQ,QAAQ;EAE7D,IAAI,aAAa,UAAU,GACzB,OAAO,YAAY,MAAM,OAAO;EAGlC,IAAI,CAAC,gBAAgB,KAAK,GACxB,OAAO,YAAY,MAAM,OAAO;EAGlC,OAAO;CACT;AACF;;;;AAKA,MAAa,wBAAuD;CAClE,MAAM;CACN,aAAa;CACb,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAClC,MAAM,aAAa,cAAc,MAAM,OAAO;EAC9C,KAAK,QAAQ,mBAAmB,QAAQ,KAAK,QAAQ,QAAQ;EAE7D,IAAI,eAAe,QACjB,OAAO,YAAY,MAAM,OAAO;EAGlC,IAAI,CAAC,gBAAgB,KAAK,GACxB,OAAO,YAAY,MAAM,OAAO;EAGlC,OAAO;CACT;AACF;;;;AAKA,MAAa,sBAAqD;CAChE,MAAM;CACN,aAAa;CACb,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAClC,MAAM,aAAa,cAAc,MAAM,OAAO;EAC9C,KAAK,QAAQ,mBAAmB,QAAQ,KAAK,QAAQ,QAAQ;EAE7D,IAAI,eAAe,QACjB,OAAO,YAAY,MAAM,OAAO;EAGlC,IAAI,CAAC,gBAAgB,KAAK,GACxB,OAAO,YAAY,MAAM,OAAO;EAGlC,OAAO;CACT;AACF"}
|
|
@@ -3,7 +3,7 @@ import { VALID_RULE, invalidRule } from "../../helpers/validation-helpers.mjs";
|
|
|
3
3
|
import "../../helpers/index.mjs";
|
|
4
4
|
import { isEmptyValue } from "../../helpers/is-empty-value.mjs";
|
|
5
5
|
|
|
6
|
-
//#region seal/src/rules/scalar/declined-rule.ts
|
|
6
|
+
//#region ../seal/src/rules/scalar/declined-rule.ts
|
|
7
7
|
const isDeclinedValue = (value) => {
|
|
8
8
|
return [
|
|
9
9
|
"0",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"declined-rule.mjs","names":[],"sources":["
|
|
1
|
+
{"version":3,"file":"declined-rule.mjs","names":[],"sources":["../../../../../../../../seal/src/rules/scalar/declined-rule.ts"],"sourcesContent":["import { getFieldValue, invalidRule, VALID_RULE } from \"../../helpers\";\r\nimport { isEmptyValue } from \"../../helpers/is-empty-value\";\r\nimport type { SchemaRule } from \"../../types\";\r\n\r\nconst isDeclinedValue = (value: any) => {\r\n return [\"0\", \"false\", \"no\", \"n\", \"off\", 0, false, \"No\", \"N\", \"Off\"].includes(value);\r\n};\r\n\r\n/**\r\n * Validate value as declined if it equals:\r\n * 0 | \"0\" | false | \"false\" | \"no\" | \"n\" | \"off\" | 0 | false | \"No\" | \"N\" | \"Off\"\r\n */\r\nexport const declinedRule: SchemaRule = {\r\n name: \"declined\",\r\n defaultErrorMessage: \"The :input must be declined\",\r\n description:\r\n \"The value must be declined if it equals: 0 | '0' | false | 'false' | 'no' | 'n' | 'off' | 0 | false | 'No' | 'N' | 'Off'\",\r\n async validate(value: any, context) {\r\n if (isDeclinedValue(value)) {\r\n return VALID_RULE;\r\n }\r\n\r\n return invalidRule(this, context);\r\n },\r\n};\r\n\r\n/**\r\n * Declined value if another field's value equals to a specific value\r\n */\r\nexport const declinedIfRule: SchemaRule<{ field: string; value: any }> = {\r\n name: \"declinedIf\",\r\n description: \"The field must be declined if :field's value equals to :value\",\r\n defaultErrorMessage: \"The :input must be declined\",\r\n async validate(value: any, context) {\r\n const fieldValue = getFieldValue(this, context);\r\n const { value: expectedValue } = this.context.options;\r\n\r\n this.context.translatableParams.field = this.context.options.field;\r\n this.context.translatableParams.value = this.context.options.value;\r\n\r\n if (fieldValue !== expectedValue) {\r\n return invalidRule(this, context);\r\n }\r\n\r\n if (!isDeclinedValue(value)) {\r\n return invalidRule(this, context);\r\n }\r\n\r\n return VALID_RULE;\r\n },\r\n};\r\n\r\n/**\r\n * Declined if another field is not equal to the given value\r\n */\r\nexport const declinedUnlessRule: SchemaRule<{ field: string; value: any }> = {\r\n name: \"declinedUnless\",\r\n description: \"The field must be declined if :field's value is not equal to :value\",\r\n defaultErrorMessage: \"The :input must be declined\",\r\n async validate(value: any, context) {\r\n const fieldValue = getFieldValue(this, context);\r\n const { value: expectedValue } = this.context.options;\r\n\r\n this.context.translatableParams.field = this.context.options.field;\r\n this.context.translatableParams.value = this.context.options.value;\r\n if (fieldValue === expectedValue) {\r\n return invalidRule(this, context);\r\n }\r\n\r\n if (!isDeclinedValue(value)) {\r\n return invalidRule(this, context);\r\n }\r\n\r\n return VALID_RULE;\r\n },\r\n};\r\n\r\n/**\r\n * Declined if another field is required\r\n */\r\nexport const declinedIfRequiredRule: SchemaRule<{ field: string }> = {\r\n name: \"declinedIfRequired\",\r\n description: \"The field must be declined if :field is required\",\r\n defaultErrorMessage: \"The :input must be declined\",\r\n async validate(value: any, context) {\r\n const fieldValue = getFieldValue(this, context);\r\n this.context.translatableParams.field = this.context.options.field;\r\n\r\n if (isEmptyValue(fieldValue)) {\r\n return invalidRule(this, context);\r\n }\r\n\r\n if (!isDeclinedValue(value)) {\r\n return invalidRule(this, context);\r\n }\r\n\r\n return VALID_RULE;\r\n },\r\n};\r\n\r\n/**\r\n * Declined if another field is present\r\n */\r\nexport const declinedIfPresentRule: SchemaRule<{ field: string }> = {\r\n name: \"declinedIfPresent\",\r\n description: \"The field must be declined if :field is present\",\r\n defaultErrorMessage: \"The :input must be declined\",\r\n async validate(value: any, context) {\r\n const fieldValue = getFieldValue(this, context);\r\n this.context.translatableParams.field = this.context.options.field;\r\n\r\n if (fieldValue === undefined) {\r\n return invalidRule(this, context);\r\n }\r\n\r\n if (!isDeclinedValue(value)) {\r\n return invalidRule(this, context);\r\n }\r\n\r\n return VALID_RULE;\r\n },\r\n};\r\n\r\n/**\r\n * Declined if another field is missing\r\n */\r\nexport const declinedWithoutRule: SchemaRule<{ field: string }> = {\r\n name: \"declinedWithout\",\r\n description: \"The field must be declined if :field is missing\",\r\n defaultErrorMessage: \"The :input must be declined\",\r\n async validate(value: any, context) {\r\n const fieldValue = getFieldValue(this, context);\r\n this.context.translatableParams.field = this.context.options.field;\r\n\r\n if (fieldValue !== undefined) {\r\n return invalidRule(this, context);\r\n }\r\n\r\n if (!isDeclinedValue(value)) {\r\n return invalidRule(this, context);\r\n }\r\n\r\n return VALID_RULE;\r\n },\r\n};\r\n"],"mappings":";;;;;;AAIA,MAAM,mBAAmB,UAAe;CACtC,OAAO;EAAC;EAAK;EAAS;EAAM;EAAK;EAAO;EAAG;EAAO;EAAM;EAAK;CAAK,EAAE,SAAS,KAAK;AACpF;;;;;AAMA,MAAa,eAA2B;CACtC,MAAM;CACN,qBAAqB;CACrB,aACE;CACF,MAAM,SAAS,OAAY,SAAS;EAClC,IAAI,gBAAgB,KAAK,GACvB,OAAO;EAGT,OAAO,YAAY,MAAM,OAAO;CAClC;AACF;;;;AAKA,MAAa,iBAA4D;CACvE,MAAM;CACN,aAAa;CACb,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAClC,MAAM,aAAa,cAAc,MAAM,OAAO;EAC9C,MAAM,EAAE,OAAO,kBAAkB,KAAK,QAAQ;EAE9C,KAAK,QAAQ,mBAAmB,QAAQ,KAAK,QAAQ,QAAQ;EAC7D,KAAK,QAAQ,mBAAmB,QAAQ,KAAK,QAAQ,QAAQ;EAE7D,IAAI,eAAe,eACjB,OAAO,YAAY,MAAM,OAAO;EAGlC,IAAI,CAAC,gBAAgB,KAAK,GACxB,OAAO,YAAY,MAAM,OAAO;EAGlC,OAAO;CACT;AACF;;;;AAKA,MAAa,qBAAgE;CAC3E,MAAM;CACN,aAAa;CACb,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAClC,MAAM,aAAa,cAAc,MAAM,OAAO;EAC9C,MAAM,EAAE,OAAO,kBAAkB,KAAK,QAAQ;EAE9C,KAAK,QAAQ,mBAAmB,QAAQ,KAAK,QAAQ,QAAQ;EAC7D,KAAK,QAAQ,mBAAmB,QAAQ,KAA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../../../../../../../../seal/src/rules/string/alpha.ts"],"mappings":";;;;;AAMA;cAAa,SAAA,EAAW,UASvB;;;AAAA;cAKY,gBAAA,EAAkB,UAS9B;;;;cAKY,aAAA,EAAe,UAS3B"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { VALID_RULE, invalidRule } from "../../helpers/validation-helpers.mjs";
|
|
2
2
|
import "../../helpers/index.mjs";
|
|
3
3
|
|
|
4
|
-
//#region seal/src/rules/string/alpha.ts
|
|
4
|
+
//#region ../seal/src/rules/string/alpha.ts
|
|
5
5
|
/**
|
|
6
6
|
* Alpha rule - allows only alphabetic characters
|
|
7
7
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alpha.mjs","names":[],"sources":["
|
|
1
|
+
{"version":3,"file":"alpha.mjs","names":[],"sources":["../../../../../../../../seal/src/rules/string/alpha.ts"],"sourcesContent":["import { invalidRule, VALID_RULE } from \"../../helpers\";\r\nimport type { SchemaRule } from \"../../types\";\r\n\r\n/**\r\n * Alpha rule - allows only alphabetic characters\r\n */\r\nexport const alphaRule: SchemaRule = {\r\n name: \"alpha\",\r\n defaultErrorMessage: \"The :input must contain only alphabetic characters\",\r\n async validate(value: any, context) {\r\n if (/^[a-zA-Z]+$/.test(value)) {\r\n return VALID_RULE;\r\n }\r\n return invalidRule(this, context);\r\n },\r\n};\r\n\r\n/**\r\n * AlphaNumeric rule - allows only alphanumeric characters\r\n */\r\nexport const alphaNumericRule: SchemaRule = {\r\n name: \"alphaNumeric\",\r\n defaultErrorMessage: \"The :input must contain only alphanumeric characters\",\r\n async validate(value: any, context) {\r\n if (/^[a-zA-Z0-9]+$/.test(value)) {\r\n return VALID_RULE;\r\n }\r\n return invalidRule(this, context);\r\n },\r\n};\r\n\r\n/**\r\n * Numeric string rule - allows only numeric characters\r\n */\r\nexport const isNumericRule: SchemaRule = {\r\n name: \"numeric\",\r\n defaultErrorMessage: \"The :input must contain only numeric characters\",\r\n async validate(value: any, context) {\r\n if (/^[0-9]+$/.test(String(value))) {\r\n return VALID_RULE;\r\n }\r\n return invalidRule(this, context);\r\n },\r\n};\r\n"],"mappings":";;;;;;;AAMA,MAAa,YAAwB;CACnC,MAAM;CACN,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAClC,IAAI,cAAc,KAAK,KAAK,GAC1B,OAAO;EAET,OAAO,YAAY,MAAM,OAAO;CAClC;AACF;;;;AAKA,MAAa,mBAA+B;CAC1C,MAAM;CACN,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAClC,IAAI,iBAAiB,KAAK,KAAK,GAC7B,OAAO;EAET,OAAO,YAAY,MAAM,OAAO;CAClC;AACF;;;;AAKA,MAAa,gBAA4B;CACvC,MAAM;CACN,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAClC,IAAI,WAAW,KAAK,OAAO,KAAK,CAAC,GAC/B,OAAO;EAET,OAAO,YAAY,MAAM,OAAO;CAClC;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"credit-card.d.mts","names":[],"sources":["
|
|
1
|
+
{"version":3,"file":"credit-card.d.mts","names":[],"sources":["../../../../../../../../seal/src/rules/string/credit-card.ts"],"mappings":";;;;;AAMA;cAAa,gBAAA,EAAkB,UAkC9B"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { VALID_RULE, invalidRule } from "../../helpers/validation-helpers.mjs";
|
|
2
2
|
import "../../helpers/index.mjs";
|
|
3
3
|
|
|
4
|
-
//#region seal/src/rules/string/credit-card.ts
|
|
4
|
+
//#region ../seal/src/rules/string/credit-card.ts
|
|
5
5
|
/**
|
|
6
6
|
* Credit card rule - validates credit card number
|
|
7
7
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"credit-card.mjs","names":[],"sources":["
|
|
1
|
+
{"version":3,"file":"credit-card.mjs","names":[],"sources":["../../../../../../../../seal/src/rules/string/credit-card.ts"],"sourcesContent":["import { invalidRule, VALID_RULE } from \"../../helpers\";\r\nimport type { SchemaRule } from \"../../types\";\r\n\r\n/**\r\n * Credit card rule - validates credit card number\r\n */\r\nexport const isCreditCardRule: SchemaRule = {\r\n name: \"creditCard\",\r\n defaultErrorMessage: \"The :input must be a valid credit card number\",\r\n async validate(value: any, context) {\r\n // Luhn algorithm for credit card validation\r\n const cardNumber = String(value).replace(/\\s/g, \"\");\r\n\r\n if (!/^\\d+$/.test(cardNumber)) {\r\n return invalidRule(this, context);\r\n }\r\n\r\n let sum = 0;\r\n let isEven = false;\r\n\r\n for (let i = cardNumber.length - 1; i >= 0; i--) {\r\n let digit = parseInt(cardNumber[i], 10);\r\n\r\n if (isEven) {\r\n digit *= 2;\r\n if (digit > 9) {\r\n digit -= 9;\r\n }\r\n }\r\n\r\n sum += digit;\r\n isEven = !isEven;\r\n }\r\n\r\n if (sum % 10 === 0) {\r\n return VALID_RULE;\r\n }\r\n\r\n return invalidRule(this, context);\r\n },\r\n};\r\n"],"mappings":";;;;;;;AAMA,MAAa,mBAA+B;CAC1C,MAAM;CACN,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAElC,MAAM,aAAa,OAAO,KAAK,EAAE,QAAQ,OAAO,EAAE;EAElD,IAAI,CAAC,QAAQ,KAAK,UAAU,GAC1B,OAAO,YAAY,MAAM,OAAO;EAGlC,IAAI,MAAM;EACV,IAAI,SAAS;EAEb,KAAK,IAAI,IAAI,WAAW,SAAS,GAAG,KAAK,GAAG,KAAK;GAC/C,IAAI,QAAQ,SAAS,WAAW,IAAI,EAAE;GAEtC,IAAI,QAAQ;IACV,SAAS;IACT,IAAI,QAAQ,GACV,SAAS;GAEb;GAEA,OAAO;GACP,SAAS,CAAC;EACZ;EAEA,IAAI,MAAM,OAAO,GACf,OAAO;EAGT,OAAO,YAAY,MAAM,OAAO;CAClC;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"email.d.mts","names":[],"sources":["
|
|
1
|
+
{"version":3,"file":"email.d.mts","names":[],"sources":["../../../../../../../../seal/src/rules/string/email.ts"],"mappings":";;;;;AAOA;cAAa,SAAA,EAAW,UASvB"}
|
|
@@ -2,7 +2,7 @@ import { VALID_RULE, invalidRule } from "../../helpers/validation-helpers.mjs";
|
|
|
2
2
|
import "../../helpers/index.mjs";
|
|
3
3
|
import { isEmail } from "@mongez/supportive-is";
|
|
4
4
|
|
|
5
|
-
//#region seal/src/rules/string/email.ts
|
|
5
|
+
//#region ../seal/src/rules/string/email.ts
|
|
6
6
|
/**
|
|
7
7
|
* Email rule - validates email format
|
|
8
8
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"email.mjs","names":[],"sources":["
|
|
1
|
+
{"version":3,"file":"email.mjs","names":[],"sources":["../../../../../../../../seal/src/rules/string/email.ts"],"sourcesContent":["import { isEmail } from \"@mongez/supportive-is\";\r\nimport { invalidRule, VALID_RULE } from \"../../helpers\";\r\nimport type { SchemaRule } from \"../../types\";\r\n\r\n/**\r\n * Email rule - validates email format\r\n */\r\nexport const emailRule: SchemaRule = {\r\n name: \"email\",\r\n defaultErrorMessage: \"The :input must be a valid email address\",\r\n async validate(value: any, context) {\r\n if (isEmail(value)) {\r\n return VALID_RULE;\r\n }\r\n return invalidRule(this, context);\r\n },\r\n};\r\n"],"mappings":";;;;;;;;AAOA,MAAa,YAAwB;CACnC,MAAM;CACN,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAClC,IAAI,QAAQ,KAAK,GACf,OAAO;EAET,OAAO,YAAY,MAAM,OAAO;CAClC;AACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SchemaRule } from "../../types/rule-types.mjs";
|
|
2
2
|
|
|
3
|
-
//#region seal/src/rules/string/id-formats.d.ts
|
|
3
|
+
//#region ../seal/src/rules/string/id-formats.d.ts
|
|
4
4
|
type UUIDVersion = 1 | 3 | 4 | 5 | 6 | 7;
|
|
5
5
|
/**
|
|
6
6
|
* UUID rule — value must be a valid UUID. Optionally restrict to a specific version.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"id-formats.d.mts","names":[],"sources":["
|
|
1
|
+
{"version":3,"file":"id-formats.d.mts","names":[],"sources":["../../../../../../../../seal/src/rules/string/id-formats.ts"],"mappings":";;;KAuBY,WAAA;;AAAZ;;;;AAAuB;AAUvB;;cAAa,QAAA,EAAU,UAAU;EAAG,OAAA,GAAU,WAAA;AAAA;;;;AAAW;AA8BzD;;;;AAA2C;AAqB3C;;cArBa,QAAA,EAAU,UAAU;EAAG,OAAO;AAAA;AAyC3C;;;;AAA4C;;;;AAA5C,cApBa,QAAA,EAAU,UAQtB;;;;;;;;;;;cAYY,UAAA,EAAY,UAAU;EAAG,MAAM;AAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { VALID_RULE, invalidRule } from "../../helpers/validation-helpers.mjs";
|
|
2
2
|
import "../../helpers/index.mjs";
|
|
3
3
|
|
|
4
|
-
//#region seal/src/rules/string/id-formats.ts
|
|
4
|
+
//#region ../seal/src/rules/string/id-formats.ts
|
|
5
5
|
/**
|
|
6
6
|
* Modern ID format validators — UUID, CUID, ULID, nanoid.
|
|
7
7
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"id-formats.mjs","names":[],"sources":["
|
|
1
|
+
{"version":3,"file":"id-formats.mjs","names":[],"sources":["../../../../../../../../seal/src/rules/string/id-formats.ts"],"sourcesContent":["import { invalidRule, VALID_RULE } from \"../../helpers\";\nimport type { SchemaRule } from \"../../types\";\n\n/**\n * Modern ID format validators — UUID, CUID, ULID, nanoid.\n *\n * Each rule asserts the value is a string in the canonical format for its\n * identifier scheme. Rules are intentionally strict (variant nibbles checked\n * for UUID, character classes enforced for ULID's Crockford base32, etc.)\n * so \"looks-like-but-not-valid\" inputs are rejected.\n */\n\nconst UUID_ANY = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\n\nconst UUID_BY_VERSION: Record<1 | 3 | 4 | 5 | 6 | 7, RegExp> = {\n 1: /^[0-9a-f]{8}-[0-9a-f]{4}-1[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i,\n 3: /^[0-9a-f]{8}-[0-9a-f]{4}-3[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i,\n 4: /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i,\n 5: /^[0-9a-f]{8}-[0-9a-f]{4}-5[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i,\n 6: /^[0-9a-f]{8}-[0-9a-f]{4}-6[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i,\n 7: /^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i,\n};\n\nexport type UUIDVersion = 1 | 3 | 4 | 5 | 6 | 7;\n\n/**\n * UUID rule — value must be a valid UUID. Optionally restrict to a specific version.\n *\n * @example\n * v.string().uuid() // any RFC 4122 UUID\n * v.string().uuid(4) // only v4 (random)\n * v.string().uuid(7) // only v7 (timestamp-ordered)\n */\nexport const uuidRule: SchemaRule<{ version?: UUIDVersion }> = {\n name: \"uuid\",\n defaultErrorMessage: \"The :input must be a valid UUID\",\n async validate(value, context) {\n if (typeof value !== \"string\") return invalidRule(this, context);\n\n const version = this.context.options.version;\n\n const pattern = version ? UUID_BY_VERSION[version] : UUID_ANY;\n if (pattern.test(value)) return VALID_RULE;\n\n if (version !== undefined) {\n this.context.translationParams.version = version;\n }\n\n return invalidRule(this, context);\n },\n};\n\n/**\n * CUID rule — value must be a valid CUID.\n *\n * Defaults to CUID2 (24 chars, lowercase, starts with letter — see\n * https://github.com/paralleldrive/cuid2). Pass `{ version: 1 }` for legacy\n * CUID1 format (starts with \"c\", ≥25 chars).\n *\n * @example\n * v.string().cuid() // CUID2\n * v.string().cuid({ version: 1 }) // legacy CUID1\n */\nexport const cuidRule: SchemaRule<{ version?: 1 | 2 }> = {\n name: \"cuid\",\n defaultErrorMessage: \"The :input must be a valid CUID\",\n async validate(value, context) {\n if (typeof value !== \"string\") return invalidRule(this, context);\n const version = this.context.options.version ?? 2;\n const pattern = version === 1 ? /^c[a-z0-9]{24,}$/ : /^[a-z][a-z0-9]{23}$/;\n if (pattern.test(value)) return VALID_RULE;\n this.context.translationParams.version = version;\n return invalidRule(this, context);\n },\n};\n\n/**\n * ULID rule — value must be a valid ULID (26 chars, Crockford base32).\n *\n * Crockford base32 excludes the letters I, L, O, U to avoid ambiguity.\n *\n * @example\n * v.string().ulid()\n */\nexport const ulidRule: SchemaRule = {\n name: \"ulid\",\n defaultErrorMessage: \"The :input must be a valid ULID\",\n async validate(value, context) {\n if (typeof value !== \"string\") return invalidRule(this, context);\n if (/^[0-9A-HJKMNP-TV-Z]{26}$/.test(value)) return VALID_RULE;\n return invalidRule(this, context);\n },\n};\n\n/**\n * nanoid rule — value must be a valid nanoid string.\n *\n * Default length is 21 (standard nanoid). URL-safe alphabet:\n * A–Z, a–z, 0–9, `_`, `-`.\n *\n * @example\n * v.string().nanoid() // 21 chars (default)\n * v.string().nanoid(10) // 10 chars\n */\nexport const nanoidRule: SchemaRule<{ length?: number }> = {\n name: \"nanoid\",\n defaultErrorMessage: \"The :input must be a valid nanoid\",\n async validate(value, context) {\n if (typeof value !== \"string\") return invalidRule(this, context);\n const length = this.context.options.length ?? 21;\n const pattern = new RegExp(`^[A-Za-z0-9_-]{${length}}$`);\n if (pattern.test(value)) return VALID_RULE;\n this.context.translationParams.length = length;\n return invalidRule(this, context);\n },\n};\n"],"mappings":";;;;;;;;;;;;AAYA,MAAM,WAAW;AAEjB,MAAM,kBAAyD;CAC7D,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;AACL;;;;;;;;;AAYA,MAAa,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