@warlock.js/seal 3.0.14
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/README.md +373 -0
- package/cjs/config.d.ts +48 -0
- package/cjs/config.d.ts.map +1 -0
- package/cjs/config.js +42 -0
- package/cjs/config.js.map +1 -0
- package/cjs/factory/index.d.ts +3 -0
- package/cjs/factory/index.d.ts.map +1 -0
- package/cjs/factory/validate.d.ts +8 -0
- package/cjs/factory/validate.d.ts.map +1 -0
- package/cjs/factory/validate.js +21 -0
- package/cjs/factory/validate.js.map +1 -0
- package/cjs/factory/validators.d.ts +32 -0
- package/cjs/factory/validators.d.ts.map +1 -0
- package/cjs/factory/validators.js +38 -0
- package/cjs/factory/validators.js.map +1 -0
- package/cjs/helpers/date-helpers.d.ts +16 -0
- package/cjs/helpers/date-helpers.d.ts.map +1 -0
- package/cjs/helpers/date-helpers.js +25 -0
- package/cjs/helpers/date-helpers.js.map +1 -0
- package/cjs/helpers/get-field-value.d.ts +37 -0
- package/cjs/helpers/get-field-value.d.ts.map +1 -0
- package/cjs/helpers/get-field-value.js +40 -0
- package/cjs/helpers/get-field-value.js.map +1 -0
- package/cjs/helpers/index.d.ts +5 -0
- package/cjs/helpers/index.d.ts.map +1 -0
- package/cjs/helpers/path-helpers.d.ts +5 -0
- package/cjs/helpers/path-helpers.d.ts.map +1 -0
- package/cjs/helpers/path-helpers.js +8 -0
- package/cjs/helpers/path-helpers.js.map +1 -0
- package/cjs/helpers/validation-helpers.d.ts +4 -0
- package/cjs/helpers/validation-helpers.d.ts.map +1 -0
- package/cjs/helpers/validation-helpers.js +39 -0
- package/cjs/helpers/validation-helpers.js.map +1 -0
- package/cjs/index.d.ts +29 -0
- package/cjs/index.d.ts.map +1 -0
- package/cjs/index.js +1 -0
- package/cjs/index.js.map +1 -0
- package/cjs/mutators/array-mutators.d.ts +12 -0
- package/cjs/mutators/array-mutators.d.ts.map +1 -0
- package/cjs/mutators/array-mutators.js +37 -0
- package/cjs/mutators/array-mutators.js.map +1 -0
- package/cjs/mutators/date-mutators.d.ts +39 -0
- package/cjs/mutators/date-mutators.d.ts.map +1 -0
- package/cjs/mutators/date-mutators.js +120 -0
- package/cjs/mutators/date-mutators.js.map +1 -0
- package/cjs/mutators/index.d.ts +6 -0
- package/cjs/mutators/index.d.ts.map +1 -0
- package/cjs/mutators/number-mutators.d.ts +8 -0
- package/cjs/mutators/number-mutators.d.ts.map +1 -0
- package/cjs/mutators/number-mutators.js +18 -0
- package/cjs/mutators/number-mutators.js.map +1 -0
- package/cjs/mutators/object-mutators.d.ts +8 -0
- package/cjs/mutators/object-mutators.d.ts.map +1 -0
- package/cjs/mutators/object-mutators.js +50 -0
- package/cjs/mutators/object-mutators.js.map +1 -0
- package/cjs/mutators/string-mutators.d.ts +72 -0
- package/cjs/mutators/string-mutators.d.ts.map +1 -0
- package/cjs/mutators/string-mutators.js +193 -0
- package/cjs/mutators/string-mutators.js.map +1 -0
- package/cjs/plugins/index.d.ts +7 -0
- package/cjs/plugins/index.d.ts.map +1 -0
- package/cjs/plugins/plugin-system.d.ts +71 -0
- package/cjs/plugins/plugin-system.d.ts.map +1 -0
- package/cjs/plugins/plugin-system.js +68 -0
- package/cjs/plugins/plugin-system.js.map +1 -0
- package/cjs/rules/array/array-rules.d.ts +12 -0
- package/cjs/rules/array/array-rules.d.ts.map +1 -0
- package/cjs/rules/array/array-rules.js +44 -0
- package/cjs/rules/array/array-rules.js.map +1 -0
- package/cjs/rules/array/index.d.ts +2 -0
- package/cjs/rules/array/index.d.ts.map +1 -0
- package/cjs/rules/color/color-rules.d.ts +30 -0
- package/cjs/rules/color/color-rules.d.ts.map +1 -0
- package/cjs/rules/color/color-rules.js +120 -0
- package/cjs/rules/color/color-rules.js.map +1 -0
- package/cjs/rules/color/index.d.ts +2 -0
- package/cjs/rules/color/index.d.ts.map +1 -0
- package/cjs/rules/common/enum.d.ts +26 -0
- package/cjs/rules/common/enum.d.ts.map +1 -0
- package/cjs/rules/common/enum.js +55 -0
- package/cjs/rules/common/enum.js.map +1 -0
- package/cjs/rules/common/equals-field-rules.d.ts +18 -0
- package/cjs/rules/common/equals-field-rules.d.ts.map +1 -0
- package/cjs/rules/common/equals-field-rules.js +38 -0
- package/cjs/rules/common/equals-field-rules.js.map +1 -0
- package/cjs/rules/common/index.d.ts +5 -0
- package/cjs/rules/common/index.d.ts.map +1 -0
- package/cjs/rules/common/type-rules.d.ts +34 -0
- package/cjs/rules/common/type-rules.d.ts.map +1 -0
- package/cjs/rules/common/type-rules.js +104 -0
- package/cjs/rules/common/type-rules.js.map +1 -0
- package/cjs/rules/common/unknown-key.d.ts +9 -0
- package/cjs/rules/common/unknown-key.d.ts.map +1 -0
- package/cjs/rules/common/unknown-key.js +20 -0
- package/cjs/rules/common/unknown-key.js.map +1 -0
- package/cjs/rules/conditional/index.d.ts +9 -0
- package/cjs/rules/conditional/index.d.ts.map +1 -0
- package/cjs/rules/conditional/present-if-rules.d.ts +45 -0
- package/cjs/rules/conditional/present-if-rules.d.ts.map +1 -0
- package/cjs/rules/conditional/present-if-rules.js +98 -0
- package/cjs/rules/conditional/present-if-rules.js.map +1 -0
- package/cjs/rules/conditional/present-unless-rules.d.ts +11 -0
- package/cjs/rules/conditional/present-unless-rules.d.ts.map +1 -0
- package/cjs/rules/conditional/present-unless-rules.js +20 -0
- package/cjs/rules/conditional/present-unless-rules.js.map +1 -0
- package/cjs/rules/conditional/present-with-rules.d.ts +26 -0
- package/cjs/rules/conditional/present-with-rules.d.ts.map +1 -0
- package/cjs/rules/conditional/present-with-rules.js +63 -0
- package/cjs/rules/conditional/present-with-rules.js.map +1 -0
- package/cjs/rules/conditional/present-without-rules.d.ts +26 -0
- package/cjs/rules/conditional/present-without-rules.d.ts.map +1 -0
- package/cjs/rules/conditional/present-without-rules.js +63 -0
- package/cjs/rules/conditional/present-without-rules.js.map +1 -0
- package/cjs/rules/conditional/required-if-rules.d.ts +45 -0
- package/cjs/rules/conditional/required-if-rules.d.ts.map +1 -0
- package/cjs/rules/conditional/required-if-rules.js +98 -0
- package/cjs/rules/conditional/required-if-rules.js.map +1 -0
- package/cjs/rules/conditional/required-unless-rules.d.ts +11 -0
- package/cjs/rules/conditional/required-unless-rules.d.ts.map +1 -0
- package/cjs/rules/conditional/required-unless-rules.js +20 -0
- package/cjs/rules/conditional/required-unless-rules.js.map +1 -0
- package/cjs/rules/conditional/required-with-rules.d.ts +26 -0
- package/cjs/rules/conditional/required-with-rules.d.ts.map +1 -0
- package/cjs/rules/conditional/required-with-rules.js +63 -0
- package/cjs/rules/conditional/required-with-rules.js.map +1 -0
- package/cjs/rules/conditional/required-without-rules.d.ts +26 -0
- package/cjs/rules/conditional/required-without-rules.d.ts.map +1 -0
- package/cjs/rules/conditional/required-without-rules.js +63 -0
- package/cjs/rules/conditional/required-without-rules.js.map +1 -0
- package/cjs/rules/core/equal.d.ts +8 -0
- package/cjs/rules/core/equal.d.ts.map +1 -0
- package/cjs/rules/core/equal.js +13 -0
- package/cjs/rules/core/equal.js.map +1 -0
- package/cjs/rules/core/forbidden.d.ts +6 -0
- package/cjs/rules/core/forbidden.d.ts.map +1 -0
- package/cjs/rules/core/forbidden.js +13 -0
- package/cjs/rules/core/forbidden.js.map +1 -0
- package/cjs/rules/core/index.d.ts +5 -0
- package/cjs/rules/core/index.d.ts.map +1 -0
- package/cjs/rules/core/required.d.ts +11 -0
- package/cjs/rules/core/required.d.ts.map +1 -0
- package/cjs/rules/core/required.js +31 -0
- package/cjs/rules/core/required.js.map +1 -0
- package/cjs/rules/core/when.d.ts +6 -0
- package/cjs/rules/core/when.d.ts.map +1 -0
- package/cjs/rules/core/when.js +40 -0
- package/cjs/rules/core/when.js.map +1 -0
- package/cjs/rules/date/date-comparison-rules.d.ts +25 -0
- package/cjs/rules/date/date-comparison-rules.d.ts.map +1 -0
- package/cjs/rules/date/date-comparison-rules.js +78 -0
- package/cjs/rules/date/date-comparison-rules.js.map +1 -0
- package/cjs/rules/date/date-day-rules.d.ts +21 -0
- package/cjs/rules/date/date-day-rules.d.ts.map +1 -0
- package/cjs/rules/date/date-day-rules.js +65 -0
- package/cjs/rules/date/date-day-rules.js.map +1 -0
- package/cjs/rules/date/date-field-comparison-rules.d.ts +28 -0
- package/cjs/rules/date/date-field-comparison-rules.d.ts.map +1 -0
- package/cjs/rules/date/date-field-comparison-rules.js +90 -0
- package/cjs/rules/date/date-field-comparison-rules.js.map +1 -0
- package/cjs/rules/date/date-period-rules.d.ts +108 -0
- package/cjs/rules/date/date-period-rules.d.ts.map +1 -0
- package/cjs/rules/date/date-period-rules.js +566 -0
- package/cjs/rules/date/date-period-rules.js.map +1 -0
- package/cjs/rules/date/date-relative-rules.d.ts +20 -0
- package/cjs/rules/date/date-relative-rules.d.ts.map +1 -0
- package/cjs/rules/date/date-relative-rules.js +57 -0
- package/cjs/rules/date/date-relative-rules.js.map +1 -0
- package/cjs/rules/date/date-special-rules.d.ts +20 -0
- package/cjs/rules/date/date-special-rules.d.ts.map +1 -0
- package/cjs/rules/date/date-special-rules.js +72 -0
- package/cjs/rules/date/date-special-rules.js.map +1 -0
- package/cjs/rules/date/date.d.ts +93 -0
- package/cjs/rules/date/date.d.ts.map +1 -0
- package/cjs/rules/date/date.js +279 -0
- package/cjs/rules/date/date.js.map +1 -0
- package/cjs/rules/date/index.d.ts +8 -0
- package/cjs/rules/date/index.d.ts.map +1 -0
- package/cjs/rules/file/dimensions.d.ts +26 -0
- package/cjs/rules/file/dimensions.d.ts.map +1 -0
- package/cjs/rules/file/dimensions.js +56 -0
- package/cjs/rules/file/dimensions.js.map +1 -0
- package/cjs/rules/file/file-size.d.ts +14 -0
- package/cjs/rules/file/file-size.d.ts.map +1 -0
- package/cjs/rules/file/file-size.js +26 -0
- package/cjs/rules/file/file-size.js.map +1 -0
- package/cjs/rules/file/index.d.ts +11 -0
- package/cjs/rules/file/index.d.ts.map +1 -0
- package/cjs/rules/index.d.ts +19 -0
- package/cjs/rules/index.d.ts.map +1 -0
- package/cjs/rules/length/index.d.ts +2 -0
- package/cjs/rules/length/index.d.ts.map +1 -0
- package/cjs/rules/length/length-rules.d.ts +49 -0
- package/cjs/rules/length/length-rules.d.ts.map +1 -0
- package/cjs/rules/length/length-rules.js +116 -0
- package/cjs/rules/length/length-rules.js.map +1 -0
- package/cjs/rules/number/index.d.ts +2 -0
- package/cjs/rules/number/index.d.ts.map +1 -0
- package/cjs/rules/number/number-rules.d.ts +43 -0
- package/cjs/rules/number/number-rules.d.ts.map +1 -0
- package/cjs/rules/number/number-rules.js +107 -0
- package/cjs/rules/number/number-rules.js.map +1 -0
- package/cjs/rules/scalar/accepted-rule.d.ts +39 -0
- package/cjs/rules/scalar/accepted-rule.d.ts.map +1 -0
- package/cjs/rules/scalar/accepted-rule.js +110 -0
- package/cjs/rules/scalar/accepted-rule.js.map +1 -0
- package/cjs/rules/scalar/declined-rule.d.ts +39 -0
- package/cjs/rules/scalar/declined-rule.d.ts.map +1 -0
- package/cjs/rules/scalar/declined-rule.js +110 -0
- package/cjs/rules/scalar/declined-rule.js.map +1 -0
- package/cjs/rules/scalar/index.d.ts +3 -0
- package/cjs/rules/scalar/index.d.ts.map +1 -0
- package/cjs/rules/string/alpha.d.ts +14 -0
- package/cjs/rules/string/alpha.d.ts.map +1 -0
- package/cjs/rules/string/alpha.js +39 -0
- package/cjs/rules/string/alpha.js.map +1 -0
- package/cjs/rules/string/credit-card.d.ts +6 -0
- package/cjs/rules/string/credit-card.d.ts.map +1 -0
- package/cjs/rules/string/credit-card.js +31 -0
- package/cjs/rules/string/credit-card.js.map +1 -0
- package/cjs/rules/string/email.d.ts +6 -0
- package/cjs/rules/string/email.d.ts.map +1 -0
- package/cjs/rules/string/email.js +13 -0
- package/cjs/rules/string/email.js.map +1 -0
- package/cjs/rules/string/index.d.ts +17 -0
- package/cjs/rules/string/index.d.ts.map +1 -0
- package/cjs/rules/string/ip.d.ts +14 -0
- package/cjs/rules/string/ip.d.ts.map +1 -0
- package/cjs/rules/string/ip.js +39 -0
- package/cjs/rules/string/ip.js.map +1 -0
- package/cjs/rules/string/matches.d.ts +8 -0
- package/cjs/rules/string/matches.d.ts.map +1 -0
- package/cjs/rules/string/matches.js +14 -0
- package/cjs/rules/string/matches.js.map +1 -0
- package/cjs/rules/string/pattern.d.ts +8 -0
- package/cjs/rules/string/pattern.d.ts.map +1 -0
- package/cjs/rules/string/pattern.js +13 -0
- package/cjs/rules/string/pattern.js.map +1 -0
- package/cjs/rules/string/string-comparison.d.ts +26 -0
- package/cjs/rules/string/string-comparison.d.ts.map +1 -0
- package/cjs/rules/string/string-comparison.js +52 -0
- package/cjs/rules/string/string-comparison.js.map +1 -0
- package/cjs/rules/string/strong-password-rule.d.ts +14 -0
- package/cjs/rules/string/strong-password-rule.d.ts.map +1 -0
- package/cjs/rules/string/strong-password-rule.js +38 -0
- package/cjs/rules/string/strong-password-rule.js.map +1 -0
- package/cjs/rules/string/url.d.ts +6 -0
- package/cjs/rules/string/url.d.ts.map +1 -0
- package/cjs/rules/string/url.js +16 -0
- package/cjs/rules/string/url.js.map +1 -0
- package/cjs/rules/string/without-whitespace.d.ts +6 -0
- package/cjs/rules/string/without-whitespace.d.ts.map +1 -0
- package/cjs/rules/string/without-whitespace.js +13 -0
- package/cjs/rules/string/without-whitespace.js.map +1 -0
- package/cjs/types/conditional-types.d.ts +15 -0
- package/cjs/types/conditional-types.d.ts.map +1 -0
- package/cjs/types/context-types.d.ts +44 -0
- package/cjs/types/context-types.d.ts.map +1 -0
- package/cjs/types/data-transformer-types.d.ts +25 -0
- package/cjs/types/data-transformer-types.d.ts.map +1 -0
- package/cjs/types/date-types.d.ts +9 -0
- package/cjs/types/date-types.d.ts.map +1 -0
- package/cjs/types/date-types.js +12 -0
- package/cjs/types/date-types.js.map +1 -0
- package/cjs/types/index.d.ts +10 -0
- package/cjs/types/index.d.ts.map +1 -0
- package/cjs/types/inference-types.d.ts +29 -0
- package/cjs/types/inference-types.d.ts.map +1 -0
- package/cjs/types/mutator-types.d.ts +27 -0
- package/cjs/types/mutator-types.d.ts.map +1 -0
- package/cjs/types/result-types.d.ts +19 -0
- package/cjs/types/result-types.d.ts.map +1 -0
- package/cjs/types/rule-types.d.ts +53 -0
- package/cjs/types/rule-types.d.ts.map +1 -0
- package/cjs/types/schema-types.d.ts +6 -0
- package/cjs/types/schema-types.d.ts.map +1 -0
- package/cjs/validators/any-validator.d.ts +7 -0
- package/cjs/validators/any-validator.d.ts.map +1 -0
- package/cjs/validators/any-validator.js +5 -0
- package/cjs/validators/any-validator.js.map +1 -0
- package/cjs/validators/array-validator.d.ts +51 -0
- package/cjs/validators/array-validator.d.ts.map +1 -0
- package/cjs/validators/array-validator.js +120 -0
- package/cjs/validators/array-validator.js.map +1 -0
- package/cjs/validators/base-validator.d.ts +500 -0
- package/cjs/validators/base-validator.d.ts.map +1 -0
- package/cjs/validators/base-validator.js +950 -0
- package/cjs/validators/base-validator.js.map +1 -0
- package/cjs/validators/boolean-validator.d.ts +43 -0
- package/cjs/validators/boolean-validator.d.ts.map +1 -0
- package/cjs/validators/boolean-validator.js +48 -0
- package/cjs/validators/boolean-validator.js.map +1 -0
- package/cjs/validators/date-validator.d.ts +303 -0
- package/cjs/validators/date-validator.d.ts.map +1 -0
- package/cjs/validators/date-validator.js +639 -0
- package/cjs/validators/date-validator.js.map +1 -0
- package/cjs/validators/float-validator.d.ts +8 -0
- package/cjs/validators/float-validator.d.ts.map +1 -0
- package/cjs/validators/float-validator.js +9 -0
- package/cjs/validators/float-validator.js.map +1 -0
- package/cjs/validators/index.d.ts +20 -0
- package/cjs/validators/index.d.ts.map +1 -0
- package/cjs/validators/int-validator.d.ts +8 -0
- package/cjs/validators/int-validator.d.ts.map +1 -0
- package/cjs/validators/int-validator.js +9 -0
- package/cjs/validators/int-validator.js.map +1 -0
- package/cjs/validators/number-validator.d.ts +35 -0
- package/cjs/validators/number-validator.d.ts.map +1 -0
- package/cjs/validators/number-validator.js +66 -0
- package/cjs/validators/number-validator.js.map +1 -0
- package/cjs/validators/object-validator.d.ts +24 -0
- package/cjs/validators/object-validator.d.ts.map +1 -0
- package/cjs/validators/object-validator.js +120 -0
- package/cjs/validators/object-validator.js.map +1 -0
- package/cjs/validators/scalar-validator.d.ts +74 -0
- package/cjs/validators/scalar-validator.d.ts.map +1 -0
- package/cjs/validators/scalar-validator.js +145 -0
- package/cjs/validators/scalar-validator.js.map +1 -0
- package/cjs/validators/string-validator.d.ts +187 -0
- package/cjs/validators/string-validator.d.ts.map +1 -0
- package/cjs/validators/string-validator.js +404 -0
- package/cjs/validators/string-validator.js.map +1 -0
- package/esm/config.d.ts +48 -0
- package/esm/config.d.ts.map +1 -0
- package/esm/config.js +42 -0
- package/esm/config.js.map +1 -0
- package/esm/factory/index.d.ts +3 -0
- package/esm/factory/index.d.ts.map +1 -0
- package/esm/factory/validate.d.ts +8 -0
- package/esm/factory/validate.d.ts.map +1 -0
- package/esm/factory/validate.js +21 -0
- package/esm/factory/validate.js.map +1 -0
- package/esm/factory/validators.d.ts +32 -0
- package/esm/factory/validators.d.ts.map +1 -0
- package/esm/factory/validators.js +38 -0
- package/esm/factory/validators.js.map +1 -0
- package/esm/helpers/date-helpers.d.ts +16 -0
- package/esm/helpers/date-helpers.d.ts.map +1 -0
- package/esm/helpers/date-helpers.js +25 -0
- package/esm/helpers/date-helpers.js.map +1 -0
- package/esm/helpers/get-field-value.d.ts +37 -0
- package/esm/helpers/get-field-value.d.ts.map +1 -0
- package/esm/helpers/get-field-value.js +40 -0
- package/esm/helpers/get-field-value.js.map +1 -0
- package/esm/helpers/index.d.ts +5 -0
- package/esm/helpers/index.d.ts.map +1 -0
- package/esm/helpers/path-helpers.d.ts +5 -0
- package/esm/helpers/path-helpers.d.ts.map +1 -0
- package/esm/helpers/path-helpers.js +8 -0
- package/esm/helpers/path-helpers.js.map +1 -0
- package/esm/helpers/validation-helpers.d.ts +4 -0
- package/esm/helpers/validation-helpers.d.ts.map +1 -0
- package/esm/helpers/validation-helpers.js +39 -0
- package/esm/helpers/validation-helpers.js.map +1 -0
- package/esm/index.d.ts +29 -0
- package/esm/index.d.ts.map +1 -0
- package/esm/index.js +1 -0
- package/esm/index.js.map +1 -0
- package/esm/mutators/array-mutators.d.ts +12 -0
- package/esm/mutators/array-mutators.d.ts.map +1 -0
- package/esm/mutators/array-mutators.js +37 -0
- package/esm/mutators/array-mutators.js.map +1 -0
- package/esm/mutators/date-mutators.d.ts +39 -0
- package/esm/mutators/date-mutators.d.ts.map +1 -0
- package/esm/mutators/date-mutators.js +120 -0
- package/esm/mutators/date-mutators.js.map +1 -0
- package/esm/mutators/index.d.ts +6 -0
- package/esm/mutators/index.d.ts.map +1 -0
- package/esm/mutators/number-mutators.d.ts +8 -0
- package/esm/mutators/number-mutators.d.ts.map +1 -0
- package/esm/mutators/number-mutators.js +18 -0
- package/esm/mutators/number-mutators.js.map +1 -0
- package/esm/mutators/object-mutators.d.ts +8 -0
- package/esm/mutators/object-mutators.d.ts.map +1 -0
- package/esm/mutators/object-mutators.js +50 -0
- package/esm/mutators/object-mutators.js.map +1 -0
- package/esm/mutators/string-mutators.d.ts +72 -0
- package/esm/mutators/string-mutators.d.ts.map +1 -0
- package/esm/mutators/string-mutators.js +193 -0
- package/esm/mutators/string-mutators.js.map +1 -0
- package/esm/plugins/index.d.ts +7 -0
- package/esm/plugins/index.d.ts.map +1 -0
- package/esm/plugins/plugin-system.d.ts +71 -0
- package/esm/plugins/plugin-system.d.ts.map +1 -0
- package/esm/plugins/plugin-system.js +68 -0
- package/esm/plugins/plugin-system.js.map +1 -0
- package/esm/rules/array/array-rules.d.ts +12 -0
- package/esm/rules/array/array-rules.d.ts.map +1 -0
- package/esm/rules/array/array-rules.js +44 -0
- package/esm/rules/array/array-rules.js.map +1 -0
- package/esm/rules/array/index.d.ts +2 -0
- package/esm/rules/array/index.d.ts.map +1 -0
- package/esm/rules/color/color-rules.d.ts +30 -0
- package/esm/rules/color/color-rules.d.ts.map +1 -0
- package/esm/rules/color/color-rules.js +120 -0
- package/esm/rules/color/color-rules.js.map +1 -0
- package/esm/rules/color/index.d.ts +2 -0
- package/esm/rules/color/index.d.ts.map +1 -0
- package/esm/rules/common/enum.d.ts +26 -0
- package/esm/rules/common/enum.d.ts.map +1 -0
- package/esm/rules/common/enum.js +55 -0
- package/esm/rules/common/enum.js.map +1 -0
- package/esm/rules/common/equals-field-rules.d.ts +18 -0
- package/esm/rules/common/equals-field-rules.d.ts.map +1 -0
- package/esm/rules/common/equals-field-rules.js +38 -0
- package/esm/rules/common/equals-field-rules.js.map +1 -0
- package/esm/rules/common/index.d.ts +5 -0
- package/esm/rules/common/index.d.ts.map +1 -0
- package/esm/rules/common/type-rules.d.ts +34 -0
- package/esm/rules/common/type-rules.d.ts.map +1 -0
- package/esm/rules/common/type-rules.js +104 -0
- package/esm/rules/common/type-rules.js.map +1 -0
- package/esm/rules/common/unknown-key.d.ts +9 -0
- package/esm/rules/common/unknown-key.d.ts.map +1 -0
- package/esm/rules/common/unknown-key.js +20 -0
- package/esm/rules/common/unknown-key.js.map +1 -0
- package/esm/rules/conditional/index.d.ts +9 -0
- package/esm/rules/conditional/index.d.ts.map +1 -0
- package/esm/rules/conditional/present-if-rules.d.ts +45 -0
- package/esm/rules/conditional/present-if-rules.d.ts.map +1 -0
- package/esm/rules/conditional/present-if-rules.js +98 -0
- package/esm/rules/conditional/present-if-rules.js.map +1 -0
- package/esm/rules/conditional/present-unless-rules.d.ts +11 -0
- package/esm/rules/conditional/present-unless-rules.d.ts.map +1 -0
- package/esm/rules/conditional/present-unless-rules.js +20 -0
- package/esm/rules/conditional/present-unless-rules.js.map +1 -0
- package/esm/rules/conditional/present-with-rules.d.ts +26 -0
- package/esm/rules/conditional/present-with-rules.d.ts.map +1 -0
- package/esm/rules/conditional/present-with-rules.js +63 -0
- package/esm/rules/conditional/present-with-rules.js.map +1 -0
- package/esm/rules/conditional/present-without-rules.d.ts +26 -0
- package/esm/rules/conditional/present-without-rules.d.ts.map +1 -0
- package/esm/rules/conditional/present-without-rules.js +63 -0
- package/esm/rules/conditional/present-without-rules.js.map +1 -0
- package/esm/rules/conditional/required-if-rules.d.ts +45 -0
- package/esm/rules/conditional/required-if-rules.d.ts.map +1 -0
- package/esm/rules/conditional/required-if-rules.js +98 -0
- package/esm/rules/conditional/required-if-rules.js.map +1 -0
- package/esm/rules/conditional/required-unless-rules.d.ts +11 -0
- package/esm/rules/conditional/required-unless-rules.d.ts.map +1 -0
- package/esm/rules/conditional/required-unless-rules.js +20 -0
- package/esm/rules/conditional/required-unless-rules.js.map +1 -0
- package/esm/rules/conditional/required-with-rules.d.ts +26 -0
- package/esm/rules/conditional/required-with-rules.d.ts.map +1 -0
- package/esm/rules/conditional/required-with-rules.js +63 -0
- package/esm/rules/conditional/required-with-rules.js.map +1 -0
- package/esm/rules/conditional/required-without-rules.d.ts +26 -0
- package/esm/rules/conditional/required-without-rules.d.ts.map +1 -0
- package/esm/rules/conditional/required-without-rules.js +63 -0
- package/esm/rules/conditional/required-without-rules.js.map +1 -0
- package/esm/rules/core/equal.d.ts +8 -0
- package/esm/rules/core/equal.d.ts.map +1 -0
- package/esm/rules/core/equal.js +13 -0
- package/esm/rules/core/equal.js.map +1 -0
- package/esm/rules/core/forbidden.d.ts +6 -0
- package/esm/rules/core/forbidden.d.ts.map +1 -0
- package/esm/rules/core/forbidden.js +13 -0
- package/esm/rules/core/forbidden.js.map +1 -0
- package/esm/rules/core/index.d.ts +5 -0
- package/esm/rules/core/index.d.ts.map +1 -0
- package/esm/rules/core/required.d.ts +11 -0
- package/esm/rules/core/required.d.ts.map +1 -0
- package/esm/rules/core/required.js +31 -0
- package/esm/rules/core/required.js.map +1 -0
- package/esm/rules/core/when.d.ts +6 -0
- package/esm/rules/core/when.d.ts.map +1 -0
- package/esm/rules/core/when.js +40 -0
- package/esm/rules/core/when.js.map +1 -0
- package/esm/rules/date/date-comparison-rules.d.ts +25 -0
- package/esm/rules/date/date-comparison-rules.d.ts.map +1 -0
- package/esm/rules/date/date-comparison-rules.js +78 -0
- package/esm/rules/date/date-comparison-rules.js.map +1 -0
- package/esm/rules/date/date-day-rules.d.ts +21 -0
- package/esm/rules/date/date-day-rules.d.ts.map +1 -0
- package/esm/rules/date/date-day-rules.js +65 -0
- package/esm/rules/date/date-day-rules.js.map +1 -0
- package/esm/rules/date/date-field-comparison-rules.d.ts +28 -0
- package/esm/rules/date/date-field-comparison-rules.d.ts.map +1 -0
- package/esm/rules/date/date-field-comparison-rules.js +90 -0
- package/esm/rules/date/date-field-comparison-rules.js.map +1 -0
- package/esm/rules/date/date-period-rules.d.ts +108 -0
- package/esm/rules/date/date-period-rules.d.ts.map +1 -0
- package/esm/rules/date/date-period-rules.js +566 -0
- package/esm/rules/date/date-period-rules.js.map +1 -0
- package/esm/rules/date/date-relative-rules.d.ts +20 -0
- package/esm/rules/date/date-relative-rules.d.ts.map +1 -0
- package/esm/rules/date/date-relative-rules.js +57 -0
- package/esm/rules/date/date-relative-rules.js.map +1 -0
- package/esm/rules/date/date-special-rules.d.ts +20 -0
- package/esm/rules/date/date-special-rules.d.ts.map +1 -0
- package/esm/rules/date/date-special-rules.js +72 -0
- package/esm/rules/date/date-special-rules.js.map +1 -0
- package/esm/rules/date/date.d.ts +93 -0
- package/esm/rules/date/date.d.ts.map +1 -0
- package/esm/rules/date/date.js +279 -0
- package/esm/rules/date/date.js.map +1 -0
- package/esm/rules/date/index.d.ts +8 -0
- package/esm/rules/date/index.d.ts.map +1 -0
- package/esm/rules/file/dimensions.d.ts +26 -0
- package/esm/rules/file/dimensions.d.ts.map +1 -0
- package/esm/rules/file/dimensions.js +56 -0
- package/esm/rules/file/dimensions.js.map +1 -0
- package/esm/rules/file/file-size.d.ts +14 -0
- package/esm/rules/file/file-size.d.ts.map +1 -0
- package/esm/rules/file/file-size.js +26 -0
- package/esm/rules/file/file-size.js.map +1 -0
- package/esm/rules/file/index.d.ts +11 -0
- package/esm/rules/file/index.d.ts.map +1 -0
- package/esm/rules/index.d.ts +19 -0
- package/esm/rules/index.d.ts.map +1 -0
- package/esm/rules/length/index.d.ts +2 -0
- package/esm/rules/length/index.d.ts.map +1 -0
- package/esm/rules/length/length-rules.d.ts +49 -0
- package/esm/rules/length/length-rules.d.ts.map +1 -0
- package/esm/rules/length/length-rules.js +116 -0
- package/esm/rules/length/length-rules.js.map +1 -0
- package/esm/rules/number/index.d.ts +2 -0
- package/esm/rules/number/index.d.ts.map +1 -0
- package/esm/rules/number/number-rules.d.ts +43 -0
- package/esm/rules/number/number-rules.d.ts.map +1 -0
- package/esm/rules/number/number-rules.js +107 -0
- package/esm/rules/number/number-rules.js.map +1 -0
- package/esm/rules/scalar/accepted-rule.d.ts +39 -0
- package/esm/rules/scalar/accepted-rule.d.ts.map +1 -0
- package/esm/rules/scalar/accepted-rule.js +110 -0
- package/esm/rules/scalar/accepted-rule.js.map +1 -0
- package/esm/rules/scalar/declined-rule.d.ts +39 -0
- package/esm/rules/scalar/declined-rule.d.ts.map +1 -0
- package/esm/rules/scalar/declined-rule.js +110 -0
- package/esm/rules/scalar/declined-rule.js.map +1 -0
- package/esm/rules/scalar/index.d.ts +3 -0
- package/esm/rules/scalar/index.d.ts.map +1 -0
- package/esm/rules/string/alpha.d.ts +14 -0
- package/esm/rules/string/alpha.d.ts.map +1 -0
- package/esm/rules/string/alpha.js +39 -0
- package/esm/rules/string/alpha.js.map +1 -0
- package/esm/rules/string/credit-card.d.ts +6 -0
- package/esm/rules/string/credit-card.d.ts.map +1 -0
- package/esm/rules/string/credit-card.js +31 -0
- package/esm/rules/string/credit-card.js.map +1 -0
- package/esm/rules/string/email.d.ts +6 -0
- package/esm/rules/string/email.d.ts.map +1 -0
- package/esm/rules/string/email.js +13 -0
- package/esm/rules/string/email.js.map +1 -0
- package/esm/rules/string/index.d.ts +17 -0
- package/esm/rules/string/index.d.ts.map +1 -0
- package/esm/rules/string/ip.d.ts +14 -0
- package/esm/rules/string/ip.d.ts.map +1 -0
- package/esm/rules/string/ip.js +39 -0
- package/esm/rules/string/ip.js.map +1 -0
- package/esm/rules/string/matches.d.ts +8 -0
- package/esm/rules/string/matches.d.ts.map +1 -0
- package/esm/rules/string/matches.js +14 -0
- package/esm/rules/string/matches.js.map +1 -0
- package/esm/rules/string/pattern.d.ts +8 -0
- package/esm/rules/string/pattern.d.ts.map +1 -0
- package/esm/rules/string/pattern.js +13 -0
- package/esm/rules/string/pattern.js.map +1 -0
- package/esm/rules/string/string-comparison.d.ts +26 -0
- package/esm/rules/string/string-comparison.d.ts.map +1 -0
- package/esm/rules/string/string-comparison.js +52 -0
- package/esm/rules/string/string-comparison.js.map +1 -0
- package/esm/rules/string/strong-password-rule.d.ts +14 -0
- package/esm/rules/string/strong-password-rule.d.ts.map +1 -0
- package/esm/rules/string/strong-password-rule.js +38 -0
- package/esm/rules/string/strong-password-rule.js.map +1 -0
- package/esm/rules/string/url.d.ts +6 -0
- package/esm/rules/string/url.d.ts.map +1 -0
- package/esm/rules/string/url.js +16 -0
- package/esm/rules/string/url.js.map +1 -0
- package/esm/rules/string/without-whitespace.d.ts +6 -0
- package/esm/rules/string/without-whitespace.d.ts.map +1 -0
- package/esm/rules/string/without-whitespace.js +13 -0
- package/esm/rules/string/without-whitespace.js.map +1 -0
- package/esm/types/conditional-types.d.ts +15 -0
- package/esm/types/conditional-types.d.ts.map +1 -0
- package/esm/types/context-types.d.ts +44 -0
- package/esm/types/context-types.d.ts.map +1 -0
- package/esm/types/data-transformer-types.d.ts +25 -0
- package/esm/types/data-transformer-types.d.ts.map +1 -0
- package/esm/types/date-types.d.ts +9 -0
- package/esm/types/date-types.d.ts.map +1 -0
- package/esm/types/date-types.js +12 -0
- package/esm/types/date-types.js.map +1 -0
- package/esm/types/index.d.ts +10 -0
- package/esm/types/index.d.ts.map +1 -0
- package/esm/types/inference-types.d.ts +29 -0
- package/esm/types/inference-types.d.ts.map +1 -0
- package/esm/types/mutator-types.d.ts +27 -0
- package/esm/types/mutator-types.d.ts.map +1 -0
- package/esm/types/result-types.d.ts +19 -0
- package/esm/types/result-types.d.ts.map +1 -0
- package/esm/types/rule-types.d.ts +53 -0
- package/esm/types/rule-types.d.ts.map +1 -0
- package/esm/types/schema-types.d.ts +6 -0
- package/esm/types/schema-types.d.ts.map +1 -0
- package/esm/validators/any-validator.d.ts +7 -0
- package/esm/validators/any-validator.d.ts.map +1 -0
- package/esm/validators/any-validator.js +5 -0
- package/esm/validators/any-validator.js.map +1 -0
- package/esm/validators/array-validator.d.ts +51 -0
- package/esm/validators/array-validator.d.ts.map +1 -0
- package/esm/validators/array-validator.js +120 -0
- package/esm/validators/array-validator.js.map +1 -0
- package/esm/validators/base-validator.d.ts +500 -0
- package/esm/validators/base-validator.d.ts.map +1 -0
- package/esm/validators/base-validator.js +950 -0
- package/esm/validators/base-validator.js.map +1 -0
- package/esm/validators/boolean-validator.d.ts +43 -0
- package/esm/validators/boolean-validator.d.ts.map +1 -0
- package/esm/validators/boolean-validator.js +48 -0
- package/esm/validators/boolean-validator.js.map +1 -0
- package/esm/validators/date-validator.d.ts +303 -0
- package/esm/validators/date-validator.d.ts.map +1 -0
- package/esm/validators/date-validator.js +639 -0
- package/esm/validators/date-validator.js.map +1 -0
- package/esm/validators/float-validator.d.ts +8 -0
- package/esm/validators/float-validator.d.ts.map +1 -0
- package/esm/validators/float-validator.js +9 -0
- package/esm/validators/float-validator.js.map +1 -0
- package/esm/validators/index.d.ts +20 -0
- package/esm/validators/index.d.ts.map +1 -0
- package/esm/validators/int-validator.d.ts +8 -0
- package/esm/validators/int-validator.d.ts.map +1 -0
- package/esm/validators/int-validator.js +9 -0
- package/esm/validators/int-validator.js.map +1 -0
- package/esm/validators/number-validator.d.ts +35 -0
- package/esm/validators/number-validator.d.ts.map +1 -0
- package/esm/validators/number-validator.js +66 -0
- package/esm/validators/number-validator.js.map +1 -0
- package/esm/validators/object-validator.d.ts +24 -0
- package/esm/validators/object-validator.d.ts.map +1 -0
- package/esm/validators/object-validator.js +120 -0
- package/esm/validators/object-validator.js.map +1 -0
- package/esm/validators/scalar-validator.d.ts +74 -0
- package/esm/validators/scalar-validator.d.ts.map +1 -0
- package/esm/validators/scalar-validator.js +145 -0
- package/esm/validators/scalar-validator.js.map +1 -0
- package/esm/validators/string-validator.d.ts +187 -0
- package/esm/validators/string-validator.d.ts.map +1 -0
- package/esm/validators/string-validator.js +404 -0
- package/esm/validators/string-validator.js.map +1 -0
- package/package.json +29 -0
package/esm/config.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Seal Configuration
|
|
3
|
+
*
|
|
4
|
+
* Global configuration for the Seal validation library
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Global Seal configuration
|
|
8
|
+
*/
|
|
9
|
+
const config = {
|
|
10
|
+
firstErrorOnly: true,
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Configure Seal globally
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* import { configureSeal } from "@warlock.js/seal";
|
|
18
|
+
* import { trans } from "@mongez/localization";
|
|
19
|
+
*
|
|
20
|
+
* configureSeal({
|
|
21
|
+
* translateRule: (ruleTranslation) => trans(`validation.${ruleTranslation.rule.name}`, ruleTranslation.attributes),
|
|
22
|
+
* translateAttribute: (attributeTranslation) => trans(`validation.attributes.${attributeTranslation.rule.name}.${attributeTranslation.attribute}`, attributeTranslation.context.allValues),
|
|
23
|
+
* });
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
function configureSeal(options) {
|
|
27
|
+
Object.assign(config, options);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Get current Seal configuration
|
|
31
|
+
*/
|
|
32
|
+
function getSealConfig() {
|
|
33
|
+
return config;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Reset configuration to defaults
|
|
37
|
+
*/
|
|
38
|
+
function resetSealConfig() {
|
|
39
|
+
delete config.translateRule;
|
|
40
|
+
delete config.translateAttribute;
|
|
41
|
+
config.firstErrorOnly = true;
|
|
42
|
+
}export{configureSeal,getSealConfig,resetSealConfig};//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sources":["../src/config.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;;;;AAIG;AA8BH;;AAEG;AACH,MAAM,MAAM,GAAe;AACzB,IAAA,cAAc,EAAE,IAAI;CACrB,CAAC;AAEF;;;;;;;;;;;;;AAaG;AACG,SAAU,aAAa,CAAC,OAA4B,EAAA;AACxD,IAAA,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AACjC,CAAC;AAED;;AAEG;SACa,aAAa,GAAA;AAC3B,IAAA,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;AAEG;SACa,eAAe,GAAA;IAC7B,OAAO,MAAM,CAAC,aAAa,CAAC;IAC5B,OAAO,MAAM,CAAC,kBAAkB,CAAC;AAEjC,IAAA,MAAM,CAAC,cAAc,GAAG,IAAI,CAAC;AAC/B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/factory/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type SealConfig } from "../config";
|
|
2
|
+
import type { ValidationResult } from "../types";
|
|
3
|
+
import type { BaseValidator } from "../validators";
|
|
4
|
+
/**
|
|
5
|
+
* Validate data against a schema
|
|
6
|
+
*/
|
|
7
|
+
export declare const validate: <T extends BaseValidator>(schema: T, data: any, configurations?: SealConfig) => Promise<ValidationResult>;
|
|
8
|
+
//# sourceMappingURL=validate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/factory/validate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,UAAU,EAAE,MAAM,WAAW,CAAC;AAC3D,OAAO,KAAK,EAAiB,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAChE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnD;;GAEG;AACH,eAAO,MAAM,QAAQ,6CAEb,GAAG,mBACO,UAAU,KACzB,QAAQ,gBAAgB,CAiB1B,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import {getSealConfig}from'../config.js';/**
|
|
2
|
+
* Validate data against a schema
|
|
3
|
+
*/
|
|
4
|
+
const validate = async (schema, data, // Temporarily use any - will fix type inference
|
|
5
|
+
configurations = getSealConfig()) => {
|
|
6
|
+
const context = {
|
|
7
|
+
allValues: data,
|
|
8
|
+
parent: null,
|
|
9
|
+
value: data,
|
|
10
|
+
key: "",
|
|
11
|
+
path: "",
|
|
12
|
+
translateRule(ruleTranslation) {
|
|
13
|
+
return configurations.translateRule?.(ruleTranslation) ?? "";
|
|
14
|
+
},
|
|
15
|
+
translateAttribute(attributeTranslation) {
|
|
16
|
+
return configurations.translateAttribute?.(attributeTranslation) ?? "";
|
|
17
|
+
},
|
|
18
|
+
configurations,
|
|
19
|
+
};
|
|
20
|
+
return await schema.validate(data, context);
|
|
21
|
+
};export{validate};//# sourceMappingURL=validate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.js","sources":["../../src/factory/validate.ts"],"sourcesContent":[null],"names":[],"mappings":"yCAIA;;AAEG;AACU,MAAA,QAAQ,GAAG,OACtB,MAAS,EACT,IAAS;AACT,cAA6B,GAAA,aAAa,EAAE,KACf;AAC7B,IAAA,MAAM,OAAO,GAAkB;AAC7B,QAAA,SAAS,EAAE,IAAI;AACf,QAAA,MAAM,EAAE,IAAI;AACZ,QAAA,KAAK,EAAE,IAAI;AACX,QAAA,GAAG,EAAE,EAAE;AACP,QAAA,IAAI,EAAE,EAAE;AACR,QAAA,aAAa,CAAC,eAAe,EAAA;YAC3B,OAAO,cAAc,CAAC,aAAa,GAAG,eAAe,CAAC,IAAI,EAAE,CAAC;SAC9D;AACD,QAAA,kBAAkB,CAAC,oBAAoB,EAAA;YACrC,OAAO,cAAc,CAAC,kBAAkB,GAAG,oBAAoB,CAAC,IAAI,EAAE,CAAC;SACxE;QACD,cAAc;KACf,CAAC;IAEF,OAAO,MAAM,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AAC9C"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Schema, ValidationResult } from "../types";
|
|
2
|
+
import type { BaseValidator } from "../validators";
|
|
3
|
+
import { AnyValidator, ArrayValidator, BooleanValidator, DateValidator, FloatValidator, IntValidator, NumberValidator, ObjectValidator, ScalarValidator, StringValidator } from "../validators";
|
|
4
|
+
/**
|
|
5
|
+
* Seal factory object - creates instances of validators
|
|
6
|
+
*
|
|
7
|
+
* Use 'v' to create validation schemas (seals) for your data
|
|
8
|
+
*/
|
|
9
|
+
export declare const v: ValidatorV;
|
|
10
|
+
export interface ValidatorV {
|
|
11
|
+
object: <T extends Schema>(schema: T, errorMessage?: string) => ObjectValidator & {
|
|
12
|
+
schema: T;
|
|
13
|
+
};
|
|
14
|
+
any: () => AnyValidator;
|
|
15
|
+
forbidden: () => AnyValidator;
|
|
16
|
+
array: <T extends BaseValidator>(validator: T, errorMessage?: string) => ArrayValidator & {
|
|
17
|
+
validator: T;
|
|
18
|
+
};
|
|
19
|
+
date: (errorMessage?: string) => DateValidator;
|
|
20
|
+
string: (errorMessage?: string) => StringValidator;
|
|
21
|
+
enum: (values: any, errorMessage?: string) => ScalarValidator;
|
|
22
|
+
number: (errorMessage?: string) => NumberValidator;
|
|
23
|
+
int: (errorMessage?: string) => IntValidator;
|
|
24
|
+
float: (errorMessage?: string) => FloatValidator;
|
|
25
|
+
boolean: (errorMessage?: string) => BooleanValidator;
|
|
26
|
+
scalar: (errorMessage?: string) => ScalarValidator;
|
|
27
|
+
localized: (valueValidator?: BaseValidator, errorMessage?: string) => ArrayValidator & {
|
|
28
|
+
validator: BaseValidator;
|
|
29
|
+
};
|
|
30
|
+
validate: <T extends BaseValidator>(schema: T, data: any) => Promise<ValidationResult>;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=validators.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validators.d.ts","sourceRoot":"","sources":["../../src/factory/validators.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AACzD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EACL,YAAY,EACZ,cAAc,EACd,gBAAgB,EAChB,aAAa,EACb,cAAc,EACd,YAAY,EACZ,eAAe,EACf,eAAe,EACf,eAAe,EACf,eAAe,EAChB,MAAM,eAAe,CAAC;AAGvB;;;;GAIG;AACH,eAAO,MAAM,CAAC,EAAE,UAwDU,CAAC;AAE3B,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,CAAC,CAAC,SAAS,MAAM,EACvB,MAAM,EAAE,CAAC,EACT,YAAY,CAAC,EAAE,MAAM,KAClB,eAAe,GAAG;QACrB,MAAM,EAAE,CAAC,CAAC;KACX,CAAC;IACF,GAAG,EAAE,MAAM,YAAY,CAAC;IACxB,SAAS,EAAE,MAAM,YAAY,CAAC;IAC9B,KAAK,EAAE,CAAC,CAAC,SAAS,aAAa,EAC7B,SAAS,EAAE,CAAC,EACZ,YAAY,CAAC,EAAE,MAAM,KAClB,cAAc,GAAG;QACpB,SAAS,EAAE,CAAC,CAAC;KACd,CAAC;IACF,IAAI,EAAE,CAAC,YAAY,CAAC,EAAE,MAAM,KAAK,aAAa,CAAC;IAC/C,MAAM,EAAE,CAAC,YAAY,CAAC,EAAE,MAAM,KAAK,eAAe,CAAC;IACnD,IAAI,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,YAAY,CAAC,EAAE,MAAM,KAAK,eAAe,CAAC;IAC9D,MAAM,EAAE,CAAC,YAAY,CAAC,EAAE,MAAM,KAAK,eAAe,CAAC;IACnD,GAAG,EAAE,CAAC,YAAY,CAAC,EAAE,MAAM,KAAK,YAAY,CAAC;IAC7C,KAAK,EAAE,CAAC,YAAY,CAAC,EAAE,MAAM,KAAK,cAAc,CAAC;IACjD,OAAO,EAAE,CAAC,YAAY,CAAC,EAAE,MAAM,KAAK,gBAAgB,CAAC;IACrD,MAAM,EAAE,CAAC,YAAY,CAAC,EAAE,MAAM,KAAK,eAAe,CAAC;IACnD,SAAS,EAAE,CACT,cAAc,CAAC,EAAE,aAAa,EAC9B,YAAY,CAAC,EAAE,MAAM,KAClB,cAAc,GAAG;QACpB,SAAS,EAAE,aAAa,CAAC;KAC1B,CAAC;IACF,QAAQ,EAAE,CAAC,CAAC,SAAS,aAAa,EAChC,MAAM,EAAE,CAAC,EACT,IAAI,EAAE,GAAG,KACN,OAAO,CAAC,gBAAgB,CAAC,CAAC;CAChC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import {AnyValidator}from'../validators/any-validator.js';import {ArrayValidator}from'../validators/array-validator.js';import'@mongez/reinforcements';import'@mongez/supportive-is';import'net';import {BooleanValidator}from'../validators/boolean-validator.js';import {DateValidator}from'../validators/date-validator.js';import {FloatValidator}from'../validators/float-validator.js';import {IntValidator}from'../validators/int-validator.js';import {NumberValidator}from'../validators/number-validator.js';import {ObjectValidator}from'../validators/object-validator.js';import {ScalarValidator}from'../validators/scalar-validator.js';import {StringValidator}from'../validators/string-validator.js';import {validate}from'./validate.js';/**
|
|
2
|
+
* Seal factory object - creates instances of validators
|
|
3
|
+
*
|
|
4
|
+
* Use 'v' to create validation schemas (seals) for your data
|
|
5
|
+
*/
|
|
6
|
+
const v = {
|
|
7
|
+
/** Create an object validator */
|
|
8
|
+
object: (schema, errorMessage) => new ObjectValidator(schema, errorMessage),
|
|
9
|
+
/** Create an any validator */
|
|
10
|
+
any: () => new AnyValidator(),
|
|
11
|
+
/** Create a forbidden validator */
|
|
12
|
+
forbidden: () => v.any().forbidden(),
|
|
13
|
+
/** Create an array validator */
|
|
14
|
+
array: (validator, errorMessage) => new ArrayValidator(validator, errorMessage),
|
|
15
|
+
/** Create a date validator */
|
|
16
|
+
date: (errorMessage) => new DateValidator(errorMessage),
|
|
17
|
+
/** Create a string validator */
|
|
18
|
+
string: (errorMessage) => new StringValidator(errorMessage),
|
|
19
|
+
/** Create an enum validator */
|
|
20
|
+
enum: (values, errorMessage) => new StringValidator().enum(values, errorMessage),
|
|
21
|
+
/** Create a number validator */
|
|
22
|
+
number: (errorMessage) => new NumberValidator(errorMessage),
|
|
23
|
+
/** Create an integer validator */
|
|
24
|
+
int: (errorMessage) => new IntValidator(errorMessage),
|
|
25
|
+
/** Create a float validator */
|
|
26
|
+
float: (errorMessage) => new FloatValidator(errorMessage),
|
|
27
|
+
/** Create a boolean validator */
|
|
28
|
+
boolean: (errorMessage) => new BooleanValidator(errorMessage),
|
|
29
|
+
/** Create a scalar validator */
|
|
30
|
+
scalar: (errorMessage) => new ScalarValidator(errorMessage),
|
|
31
|
+
/** Create a localized array validator */
|
|
32
|
+
localized: (valueValidator, errorMessage) => v.array(v.object({
|
|
33
|
+
localeCode: v.string().required(),
|
|
34
|
+
value: (valueValidator || v.string()).required(),
|
|
35
|
+
}), errorMessage),
|
|
36
|
+
/** Validate data against a schema */
|
|
37
|
+
validate: validate,
|
|
38
|
+
};export{v};//# sourceMappingURL=validators.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validators.js","sources":["../../src/factory/validators.ts"],"sourcesContent":[null],"names":["validateFunction"],"mappings":"4tBAgBA;;;;AAIG;AACU,MAAA,CAAC,GAAe;;AAE3B,IAAA,MAAM,EAAE,CAAmB,MAAS,EAAE,YAAqB,KACzD,IAAI,eAAe,CAAC,MAAM,EAAE,YAAY,CAEvC;;AAGH,IAAA,GAAG,EAAE,MAAM,IAAI,YAAY,EAAE;;IAG7B,SAAS,EAAE,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,SAAS,EAAE;;AAGpC,IAAA,KAAK,EAAE,CAA0B,SAAY,EAAE,YAAqB,KAClE,IAAI,cAAc,CAAC,SAAS,EAAE,YAAY,CAEzC;;IAGH,IAAI,EAAE,CAAC,YAAqB,KAAK,IAAI,aAAa,CAAC,YAAY,CAAC;;IAGhE,MAAM,EAAE,CAAC,YAAqB,KAAK,IAAI,eAAe,CAAC,YAAY,CAAC;;AAGpE,IAAA,IAAI,EAAE,CAAC,MAAW,EAAE,YAAqB,KACvC,IAAI,eAAe,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,YAAY,CAAC;;IAGlD,MAAM,EAAE,CAAC,YAAqB,KAAK,IAAI,eAAe,CAAC,YAAY,CAAC;;IAGpE,GAAG,EAAE,CAAC,YAAqB,KAAK,IAAI,YAAY,CAAC,YAAY,CAAC;;IAG9D,KAAK,EAAE,CAAC,YAAqB,KAAK,IAAI,cAAc,CAAC,YAAY,CAAC;;IAGlE,OAAO,EAAE,CAAC,YAAqB,KAAK,IAAI,gBAAgB,CAAC,YAAY,CAAC;;IAGtE,MAAM,EAAE,CAAC,YAAqB,KAAK,IAAI,eAAe,CAAC,YAAY,CAAC;;AAGpE,IAAA,SAAS,EAAE,CAAC,cAA8B,EAAE,YAAqB,KAC/D,CAAC,CAAC,KAAK,CACL,CAAC,CAAC,MAAM,CAAC;AACP,QAAA,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;QACjC,KAAK,EAAE,CAAC,cAAc,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,QAAQ,EAAE;KACjD,CAAC,EACF,YAAY,CACb;;AAGH,IAAA,QAAQ,EAAEA,QAAgB;"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Detect if value is a date value or field name
|
|
3
|
+
*
|
|
4
|
+
* Date values:
|
|
5
|
+
* - Date instance
|
|
6
|
+
* - Number (timestamp)
|
|
7
|
+
* - String with date separators (- or /)
|
|
8
|
+
*
|
|
9
|
+
* Field names:
|
|
10
|
+
* - Strings without - or /
|
|
11
|
+
*
|
|
12
|
+
* @param value - Value to check
|
|
13
|
+
* @returns true if it's a date value, false if it's a field name
|
|
14
|
+
*/
|
|
15
|
+
export declare function isDateValue(value: any): boolean;
|
|
16
|
+
//# sourceMappingURL=date-helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date-helpers.d.ts","sourceRoot":"","sources":["../../src/helpers/date-helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO,CAU/C"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Detect if value is a date value or field name
|
|
3
|
+
*
|
|
4
|
+
* Date values:
|
|
5
|
+
* - Date instance
|
|
6
|
+
* - Number (timestamp)
|
|
7
|
+
* - String with date separators (- or /)
|
|
8
|
+
*
|
|
9
|
+
* Field names:
|
|
10
|
+
* - Strings without - or /
|
|
11
|
+
*
|
|
12
|
+
* @param value - Value to check
|
|
13
|
+
* @returns true if it's a date value, false if it's a field name
|
|
14
|
+
*/
|
|
15
|
+
function isDateValue(value) {
|
|
16
|
+
if (value instanceof Date)
|
|
17
|
+
return true;
|
|
18
|
+
if (typeof value === "number")
|
|
19
|
+
return true;
|
|
20
|
+
if (typeof value === "string" &&
|
|
21
|
+
(value.includes("-") || value.includes("/"))) {
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
return false;
|
|
25
|
+
}export{isDateValue};//# sourceMappingURL=date-helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date-helpers.js","sources":["../../src/helpers/date-helpers.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;;;;;;;;;;;;;AAaG;AACG,SAAU,WAAW,CAAC,KAAU,EAAA;IACpC,IAAI,KAAK,YAAY,IAAI;AAAE,QAAA,OAAO,IAAI,CAAC;IACvC,IAAI,OAAO,KAAK,KAAK,QAAQ;AAAE,QAAA,OAAO,IAAI,CAAC;IAC3C,IACE,OAAO,KAAK,KAAK,QAAQ;AACzB,SAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,EAC5C;AACA,QAAA,OAAO,IAAI,CAAC;AACb,KAAA;AACD,IAAA,OAAO,KAAK,CAAC;AACf"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { ContextualSchemaRule, SchemaContext } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* Get field value based on scope from rule options
|
|
4
|
+
*
|
|
5
|
+
* This utility extracts a field value from either the global context or sibling context
|
|
6
|
+
* based on the `scope` option in the rule's context.
|
|
7
|
+
*
|
|
8
|
+
* @param rule - The contextual schema rule containing options with:
|
|
9
|
+
* - `field` (or custom fieldKey): The field name to extract
|
|
10
|
+
* - `scope` (optional): Either "global" (default) or "sibling"
|
|
11
|
+
* @param context - The schema validation context containing allValues and parent
|
|
12
|
+
* @param fieldKey - The key in rule.context.options that contains the field name (defaults to "field")
|
|
13
|
+
*
|
|
14
|
+
* @returns The value of the specified field from the appropriate source
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* // In a validation rule with scope support:
|
|
18
|
+
* async validate(value: any, context) {
|
|
19
|
+
* const otherFieldValue = getFieldValue(this, context);
|
|
20
|
+
* // Extracts from context.allValues if scope is "global"
|
|
21
|
+
* // Extracts from context.parent if scope is "sibling"
|
|
22
|
+
* }
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* // Using a custom field key:
|
|
26
|
+
* async validate(value: any, context) {
|
|
27
|
+
* const compareValue = getFieldValue(this, context, "compareField");
|
|
28
|
+
* // Looks for rule.context.options.compareField instead of .field
|
|
29
|
+
* }
|
|
30
|
+
*
|
|
31
|
+
* @remarks
|
|
32
|
+
* - **Global scope** (`scope: "global"`): Searches the entire input data (context.allValues)
|
|
33
|
+
* - **Sibling scope** (`scope: "sibling"`): Searches only within the parent object (context.parent)
|
|
34
|
+
* - Uses `@mongez/reinforcements.get()` to support nested paths (e.g., "user.email")
|
|
35
|
+
*/
|
|
36
|
+
export declare function getFieldValue(rule: ContextualSchemaRule, context: SchemaContext, fieldKey?: string): any;
|
|
37
|
+
//# sourceMappingURL=get-field-value.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-field-value.d.ts","sourceRoot":"","sources":["../../src/helpers/get-field-value.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEpE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,oBAAoB,EAC1B,OAAO,EAAE,aAAa,EACtB,QAAQ,SAAU,OAMnB"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import {get}from'@mongez/reinforcements';/**
|
|
2
|
+
* Get field value based on scope from rule options
|
|
3
|
+
*
|
|
4
|
+
* This utility extracts a field value from either the global context or sibling context
|
|
5
|
+
* based on the `scope` option in the rule's context.
|
|
6
|
+
*
|
|
7
|
+
* @param rule - The contextual schema rule containing options with:
|
|
8
|
+
* - `field` (or custom fieldKey): The field name to extract
|
|
9
|
+
* - `scope` (optional): Either "global" (default) or "sibling"
|
|
10
|
+
* @param context - The schema validation context containing allValues and parent
|
|
11
|
+
* @param fieldKey - The key in rule.context.options that contains the field name (defaults to "field")
|
|
12
|
+
*
|
|
13
|
+
* @returns The value of the specified field from the appropriate source
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* // In a validation rule with scope support:
|
|
17
|
+
* async validate(value: any, context) {
|
|
18
|
+
* const otherFieldValue = getFieldValue(this, context);
|
|
19
|
+
* // Extracts from context.allValues if scope is "global"
|
|
20
|
+
* // Extracts from context.parent if scope is "sibling"
|
|
21
|
+
* }
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* // Using a custom field key:
|
|
25
|
+
* async validate(value: any, context) {
|
|
26
|
+
* const compareValue = getFieldValue(this, context, "compareField");
|
|
27
|
+
* // Looks for rule.context.options.compareField instead of .field
|
|
28
|
+
* }
|
|
29
|
+
*
|
|
30
|
+
* @remarks
|
|
31
|
+
* - **Global scope** (`scope: "global"`): Searches the entire input data (context.allValues)
|
|
32
|
+
* - **Sibling scope** (`scope: "sibling"`): Searches only within the parent object (context.parent)
|
|
33
|
+
* - Uses `@mongez/reinforcements.get()` to support nested paths (e.g., "user.email")
|
|
34
|
+
*/
|
|
35
|
+
function getFieldValue(rule, context, fieldKey = "field") {
|
|
36
|
+
const field = rule.context.options[fieldKey];
|
|
37
|
+
const scope = rule.context.options.scope || "global";
|
|
38
|
+
const source = scope === "sibling" ? context.parent : context.allValues;
|
|
39
|
+
return get(source, field);
|
|
40
|
+
}export{getFieldValue};//# sourceMappingURL=get-field-value.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-field-value.js","sources":["../../src/helpers/get-field-value.ts"],"sourcesContent":[null],"names":[],"mappings":"yCAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCG;AACG,SAAU,aAAa,CAC3B,IAA0B,EAC1B,OAAsB,EACtB,QAAQ,GAAG,OAAO,EAAA;IAElB,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC7C,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,IAAI,QAAQ,CAAC;AACrD,IAAA,MAAM,MAAM,GAAG,KAAK,KAAK,SAAS,GAAG,OAAO,CAAC,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC;AACxE,IAAA,OAAO,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;AAC5B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path-helpers.d.ts","sourceRoot":"","sources":["../../src/helpers/path-helpers.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,UAAU,SAAU,MAAM,OAAO,MAAM,KAAG,MAGtD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path-helpers.js","sources":["../../src/helpers/path-helpers.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;;AAEG;MACU,UAAU,GAAG,CAAC,IAAY,EAAE,GAAW,KAAY;AAC9D,IAAA,IAAI,CAAC,IAAI;AAAE,QAAA,OAAO,GAAG,CAAC;AACtB,IAAA,OAAO,CAAG,EAAA,IAAI,CAAI,CAAA,EAAA,GAAG,EAAE,CAAC;AAC1B"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ContextualSchemaRule, RuleResult, SchemaContext } from "../types";
|
|
2
|
+
export declare const VALID_RULE: RuleResult;
|
|
3
|
+
export declare const invalidRule: (rule: ContextualSchemaRule, context: SchemaContext) => RuleResult;
|
|
4
|
+
//# sourceMappingURL=validation-helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation-helpers.d.ts","sourceRoot":"","sources":["../../src/helpers/validation-helpers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEhF,eAAO,MAAM,UAAU,EAAE,UAExB,CAAC;AAEF,eAAO,MAAM,WAAW,SAChB,oBAAoB,WACjB,aAAa,KACrB,UA4CF,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import {getSealConfig}from'../config.js';const VALID_RULE = {
|
|
2
|
+
isValid: true,
|
|
3
|
+
};
|
|
4
|
+
const invalidRule = (rule, context) => {
|
|
5
|
+
const attributes = { ...rule.context.options, ...context.allValues };
|
|
6
|
+
attributes.input = context.path || context.key || "data";
|
|
7
|
+
attributes.path = context.path;
|
|
8
|
+
attributes.key = context.key;
|
|
9
|
+
attributes.value = context.value;
|
|
10
|
+
const translator = getSealConfig().translateAttribute;
|
|
11
|
+
if (translator) {
|
|
12
|
+
for (const key in attributes) {
|
|
13
|
+
// Special handling for the input attribute
|
|
14
|
+
if (key === "input") {
|
|
15
|
+
const translation = rule.context.attributesList?.input ||
|
|
16
|
+
translator({ attribute: "input", context, rule });
|
|
17
|
+
if (translation !== "input") {
|
|
18
|
+
attributes.input = translation;
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
const value = attributes[key];
|
|
23
|
+
attributes[key] =
|
|
24
|
+
rule.context.attributesList?.[value] ||
|
|
25
|
+
translator({ attribute: value, context, rule }) ||
|
|
26
|
+
value;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
const error = rule.context.errorMessage ||
|
|
30
|
+
rule.errorMessage ||
|
|
31
|
+
context.translateRule?.({ rule, context, attributes }) ||
|
|
32
|
+
rule.defaultErrorMessage;
|
|
33
|
+
return {
|
|
34
|
+
isValid: false,
|
|
35
|
+
error,
|
|
36
|
+
input: context.key,
|
|
37
|
+
path: context.path,
|
|
38
|
+
};
|
|
39
|
+
};export{VALID_RULE,invalidRule};//# sourceMappingURL=validation-helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation-helpers.js","sources":["../../src/helpers/validation-helpers.ts"],"sourcesContent":[null],"names":[],"mappings":"yCAGa,MAAA,UAAU,GAAe;AACpC,IAAA,OAAO,EAAE,IAAI;EACb;MAEW,WAAW,GAAG,CACzB,IAA0B,EAC1B,OAAsB,KACR;AACd,IAAA,MAAM,UAAU,GAAG,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;AAErE,IAAA,UAAU,CAAC,KAAK,GAAG,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,GAAG,IAAI,MAAM,CAAC;AACzD,IAAA,UAAU,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;AAC/B,IAAA,UAAU,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;AAC7B,IAAA,UAAU,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;AAEjC,IAAA,MAAM,UAAU,GAAG,aAAa,EAAE,CAAC,kBAAkB,CAAC;AAEtD,IAAA,IAAI,UAAU,EAAE;AACd,QAAA,KAAK,MAAM,GAAG,IAAI,UAAU,EAAE;;YAE5B,IAAI,GAAG,KAAK,OAAO,EAAE;gBACnB,MAAM,WAAW,GACf,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE,KAAK;oBAClC,UAAU,CAAC,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;gBAEpD,IAAI,WAAW,KAAK,OAAO,EAAE;AAC3B,oBAAA,UAAU,CAAC,KAAK,GAAG,WAAW,CAAC;oBAC/B,SAAS;AACV,iBAAA;AACF,aAAA;AAED,YAAA,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC;YAC9B,UAAU,CAAC,GAAG,CAAC;AACb,gBAAA,IAAI,CAAC,OAAO,CAAC,cAAc,GAAG,KAAK,CAAC;oBACpC,UAAU,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAC/C,oBAAA,KAAK,CAAC;AACT,SAAA;AACF,KAAA;AAED,IAAA,MAAM,KAAK,GACT,IAAI,CAAC,OAAO,CAAC,YAAY;AACzB,QAAA,IAAI,CAAC,YAAY;QACjB,OAAO,CAAC,aAAa,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC;QACtD,IAAI,CAAC,mBAAoB,CAAC;IAE5B,OAAO;AACL,QAAA,OAAO,EAAE,KAAK;QACd,KAAK;QACL,KAAK,EAAE,OAAO,CAAC,GAAG;QAClB,IAAI,EAAE,OAAO,CAAC,IAAI;KACnB,CAAC;AACJ"}
|
package/esm/index.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Warlock Seal - Type-Safe Validation Library
|
|
3
|
+
*
|
|
4
|
+
* A powerful, framework-agnostic validation library with TypeScript support
|
|
5
|
+
*
|
|
6
|
+
* Package: @warlock.js/seal
|
|
7
|
+
*
|
|
8
|
+
* Cast validation seals on your schemas to protect your data!
|
|
9
|
+
*
|
|
10
|
+
* Structure:
|
|
11
|
+
* - validators/ - Core validators (framework-agnostic)
|
|
12
|
+
* - rules/ - Core validation rules
|
|
13
|
+
* - types/ - Type definitions
|
|
14
|
+
* - helpers/ - Utilities
|
|
15
|
+
* - mutators/ - Data transformations
|
|
16
|
+
* - factory/ - v object and validate function
|
|
17
|
+
*
|
|
18
|
+
* Framework-specific features (FileValidator, database rules) are in:
|
|
19
|
+
* @warlock.js/core/v (src/warlock/v/)
|
|
20
|
+
*/
|
|
21
|
+
export * from "./validators";
|
|
22
|
+
export * from "./types";
|
|
23
|
+
export * from "./helpers";
|
|
24
|
+
export * from "./mutators";
|
|
25
|
+
export * from "./rules";
|
|
26
|
+
export * from "./factory";
|
|
27
|
+
export * from "./plugins";
|
|
28
|
+
export * from "./config";
|
|
29
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,cAAc,cAAc,CAAC;AAG7B,cAAc,SAAS,CAAC;AAGxB,cAAc,WAAW,CAAC;AAG1B,cAAc,YAAY,CAAC;AAG3B,cAAc,SAAS,CAAC;AAGxB,cAAc,WAAW,CAAC;AAG1B,cAAc,WAAW,CAAC;AAG1B,cAAc,UAAU,CAAC"}
|
package/esm/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{AnyValidator}from'./validators/any-validator.js';export{ArrayValidator}from'./validators/array-validator.js';export{BaseValidator}from'./validators/base-validator.js';export{BooleanValidator}from'./validators/boolean-validator.js';export{DateValidator}from'./validators/date-validator.js';export{FloatValidator}from'./validators/float-validator.js';export{IntValidator}from'./validators/int-validator.js';export{NumberValidator}from'./validators/number-validator.js';export{ObjectValidator}from'./validators/object-validator.js';export{ScalarValidator}from'./validators/scalar-validator.js';export{StringValidator}from'./validators/string-validator.js';export{WEEK_DAYS}from'./types/date-types.js';export{isDateValue}from'./helpers/date-helpers.js';export{getFieldValue}from'./helpers/get-field-value.js';export{setKeyPath}from'./helpers/path-helpers.js';export{VALID_RULE,invalidRule}from'./helpers/validation-helpers.js';export{flipArrayMutator,removeEmptyArrayElementsMutator,reverseArrayMutator,sortArrayMutator,uniqueArrayMutator}from'./mutators/array-mutators.js';export{addDaysMutator,addHoursMutator,addMonthsMutator,addYearsMutator,dateMutator,toDateOnlyMutator,toEndOfDayMutator,toEndOfMonthMutator,toEndOfYearMutator,toFormatMutator,toISOStringMutator,toStartOfDayMutator,toStartOfMonthMutator,toStartOfYearMutator,toTimeOnlyMutator,toTimestampMutator,toUTCMutator}from'./mutators/date-mutators.js';export{booleanMutator,numberMutator,roundNumberMutator}from'./mutators/number-mutators.js';export{jsonMutator,objectTrimMutator,stripUnknownMutator}from'./mutators/object-mutators.js';export{alphaOnlyMutator,alphanumericOnlyMutator,appendMutator,base64DecodeMutator,base64EncodeMutator,camelCaseMutator,capitalizeMutator,htmlEscapeMutator,kebabCaseMutator,lowercaseMutator,ltrimMutator,maskMutator,padEndMutator,padStartMutator,pascalCaseMutator,prependMutator,removeNumbersMutator,removeSpecialCharactersMutator,repeatMutator,replaceAllMutator,replaceMutator,reverseMutator,rtrimMutator,safeHtmlMutator,slugMutator,snakeCaseMutator,stringifyMutator,titleCaseMutator,trimMultipleWhitespaceMutator,trimMutator,truncateMutator,unescapeHtmlMutator,uppercaseMutator,urlDecodeMutator,urlEncodeMutator}from'./mutators/string-mutators.js';export{equalRule}from'./rules/core/equal.js';export{forbiddenRule}from'./rules/core/forbidden.js';export{presentRule,requiredRule}from'./rules/core/required.js';export{whenRule}from'./rules/core/when.js';export{alphaNumericRule,alphaRule,isNumericRule}from'./rules/string/alpha.js';export{isCreditCardRule}from'./rules/string/credit-card.js';export{emailRule}from'./rules/string/email.js';export{ip4Rule,ip6Rule,ipRule}from'./rules/string/ip.js';export{matchesRule}from'./rules/string/matches.js';export{patternRule}from'./rules/string/pattern.js';export{containsRule,endsWithRule,notContainsRule,startsWithRule}from'./rules/string/string-comparison.js';export{strongPasswordRule}from'./rules/string/strong-password-rule.js';export{urlRule}from'./rules/string/url.js';export{withoutWhitespaceRule}from'./rules/string/without-whitespace.js';export{betweenNumbersRule,evenRule,maxRule,minRule,moduloRule,negativeRule,oddRule,positiveRule}from'./rules/number/number-rules.js';export{betweenLengthRule,lengthRule,maxLengthRule,maxWordsRule,minLengthRule,minWordsRule,wordsRule}from'./rules/length/length-rules.js';export{sortedArrayRule,uniqueArrayRule}from'./rules/array/array-rules.js';export{ageRule,beforeHourRule,beforeMinuteRule,beforeTodayRule,betweenHoursRule,betweenMinutesRule,dateRule,fromHourRule,fromMinuteRule,fromTodayRule,maxAgeRule,maxDateRule,minAgeRule,minDateRule,weekDayRule}from'./rules/date/date.js';export{afterTodayRule,betweenDatesRule,futureRule,pastRule,todayRule}from'./rules/date/date-comparison-rules.js';export{businessDayRule,weekdayRule,weekdaysRule,weekendRule}from'./rules/date/date-day-rules.js';export{afterFieldRule,beforeFieldRule,sameAsFieldDateRule}from'./rules/date/date-field-comparison-rules.js';export{betweenDaysRule,betweenMonthsRule,betweenTimesRule,betweenYearsRule,maxDayRule,maxMonthRule,maxYearRule,minDayRule,minMonthRule,minYearRule,monthRule,quarterRule,yearRule}from'./rules/date/date-period-rules.js';export{withinDaysRule,withinFutureDaysRule,withinPastDaysRule}from'./rules/date/date-relative-rules.js';export{betweenAgeRule,birthdayRule,leapYearRule}from'./rules/date/date-special-rules.js';export{maxHeightRule,maxWidthRule,minHeightRule,minWidthRule}from'./rules/file/dimensions.js';export{maxFileSizeRule,minFileSizeRule}from'./rules/file/file-size.js';export{colorRule,darkColorRule,hexColorRule,hslColorRule,lightColorRule,rgbColorRule,rgbaColorRule}from'./rules/color/color-rules.js';export{requiredIfEmptyRule,requiredIfInRule,requiredIfNotEmptyRule,requiredIfNotInRule,requiredIfRule}from'./rules/conditional/required-if-rules.js';export{requiredUnlessRule}from'./rules/conditional/required-unless-rules.js';export{requiredWithAllRule,requiredWithAnyRule,requiredWithRule}from'./rules/conditional/required-with-rules.js';export{requiredWithoutAllRule,requiredWithoutAnyRule,requiredWithoutRule}from'./rules/conditional/required-without-rules.js';export{presentIfEmptyRule,presentIfInRule,presentIfNotEmptyRule,presentIfNotInRule,presentIfRule}from'./rules/conditional/present-if-rules.js';export{presentUnlessRule}from'./rules/conditional/present-unless-rules.js';export{presentWithAllRule,presentWithAnyRule,presentWithRule}from'./rules/conditional/present-with-rules.js';export{presentWithoutAllRule,presentWithoutAnyRule,presentWithoutRule}from'./rules/conditional/present-without-rules.js';export{allowedValuesRule,enumRule,inRule,notAllowedValuesRule}from'./rules/common/enum.js';export{equalsFieldRule,notEqualsFieldRule}from'./rules/common/equals-field-rules.js';export{arrayRule,booleanRule,floatRule,intRule,numberRule,objectRule,scalarRule,stringRule}from'./rules/common/type-rules.js';export{unknownKeyRule}from'./rules/common/unknown-key.js';export{validate}from'./factory/validate.js';export{v}from'./factory/validators.js';export{getInstalledPlugins,hasPlugin,registerPlugin,unregisterPlugin}from'./plugins/plugin-system.js';export{configureSeal,getSealConfig,resetSealConfig}from'./config.js';//# sourceMappingURL=index.js.map
|
package/esm/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Mutator } from "../types";
|
|
2
|
+
/** Reverse array order */
|
|
3
|
+
export declare const flipArrayMutator: Mutator;
|
|
4
|
+
/** Reverse array order (alias) */
|
|
5
|
+
export declare const reverseArrayMutator: Mutator;
|
|
6
|
+
/** Sort array */
|
|
7
|
+
export declare const sortArrayMutator: Mutator;
|
|
8
|
+
/** Make array have only unique values */
|
|
9
|
+
export declare const uniqueArrayMutator: Mutator;
|
|
10
|
+
/** Remove empty elements from array */
|
|
11
|
+
export declare const removeEmptyArrayElementsMutator: Mutator;
|
|
12
|
+
//# sourceMappingURL=array-mutators.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array-mutators.d.ts","sourceRoot":"","sources":["../../src/mutators/array-mutators.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAExC,0BAA0B;AAC1B,eAAO,MAAM,gBAAgB,EAAE,OAE9B,CAAC;AAEF,kCAAkC;AAClC,eAAO,MAAM,mBAAmB,EAAE,OAEjC,CAAC;AAEF,iBAAiB;AACjB,eAAO,MAAM,gBAAgB,EAAE,OAsB9B,CAAC;AAEF,yCAAyC;AACzC,eAAO,MAAM,kBAAkB,EAAE,OAEhC,CAAC;AAEF,uCAAuC;AACvC,eAAO,MAAM,+BAA+B,EAAE,OAE7C,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import {get}from'@mongez/reinforcements';import {isEmpty}from'@mongez/supportive-is';/** Reverse array order */
|
|
2
|
+
const flipArrayMutator = async (value) => {
|
|
3
|
+
return value.reverse();
|
|
4
|
+
};
|
|
5
|
+
/** Reverse array order (alias) */
|
|
6
|
+
const reverseArrayMutator = async (value) => {
|
|
7
|
+
return value.reverse();
|
|
8
|
+
};
|
|
9
|
+
/** Sort array */
|
|
10
|
+
const sortArrayMutator = async (value, context) => {
|
|
11
|
+
if (!Array.isArray(value))
|
|
12
|
+
return value;
|
|
13
|
+
const sortDirection = context.options.direction ?? "asc";
|
|
14
|
+
const sortByKey = context.options.key ?? null;
|
|
15
|
+
return value.sort((a, b) => {
|
|
16
|
+
if (sortByKey) {
|
|
17
|
+
const aValue = get(a, sortByKey);
|
|
18
|
+
const bValue = get(b, sortByKey);
|
|
19
|
+
if (sortDirection === "asc") {
|
|
20
|
+
return aValue - bValue;
|
|
21
|
+
}
|
|
22
|
+
return bValue - aValue;
|
|
23
|
+
}
|
|
24
|
+
if (sortDirection === "asc") {
|
|
25
|
+
return a - b;
|
|
26
|
+
}
|
|
27
|
+
return b - a;
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
/** Make array have only unique values */
|
|
31
|
+
const uniqueArrayMutator = async (value) => {
|
|
32
|
+
return [...new Set(value)];
|
|
33
|
+
};
|
|
34
|
+
/** Remove empty elements from array */
|
|
35
|
+
const removeEmptyArrayElementsMutator = async (value) => {
|
|
36
|
+
return value.filter((item) => !isEmpty(item));
|
|
37
|
+
};export{flipArrayMutator,removeEmptyArrayElementsMutator,reverseArrayMutator,sortArrayMutator,uniqueArrayMutator};//# sourceMappingURL=array-mutators.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array-mutators.js","sources":["../../src/mutators/array-mutators.ts"],"sourcesContent":[null],"names":[],"mappings":"qFAIA;MACa,gBAAgB,GAAY,OAAM,KAAK,KAAG;AACrD,IAAA,OAAO,KAAK,CAAC,OAAO,EAAE,CAAC;AACzB,EAAE;AAEF;MACa,mBAAmB,GAAY,OAAM,KAAK,KAAG;AACxD,IAAA,OAAO,KAAK,CAAC,OAAO,EAAE,CAAC;AACzB,EAAE;AAEF;AACa,MAAA,gBAAgB,GAAY,OAAO,KAAK,EAAE,OAAO,KAAI;AAChE,IAAA,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;AAAE,QAAA,OAAO,KAAK,CAAC;IAExC,MAAM,aAAa,GAAG,OAAO,CAAC,OAAO,CAAC,SAAS,IAAI,KAAK,CAAC;IACzD,MAAM,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,IAAI,IAAI,CAAC;IAE9C,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC,CAAM,EAAE,CAAM,KAAI;AACnC,QAAA,IAAI,SAAS,EAAE;YACb,MAAM,MAAM,GAAG,GAAG,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC;YACjC,MAAM,MAAM,GAAG,GAAG,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC;YAEjC,IAAI,aAAa,KAAK,KAAK,EAAE;gBAC3B,OAAO,MAAM,GAAG,MAAM,CAAC;AACxB,aAAA;YACD,OAAO,MAAM,GAAG,MAAM,CAAC;AACxB,SAAA;QAED,IAAI,aAAa,KAAK,KAAK,EAAE;YAC3B,OAAO,CAAC,GAAG,CAAC,CAAC;AACd,SAAA;QACD,OAAO,CAAC,GAAG,CAAC,CAAC;AACf,KAAC,CAAC,CAAC;AACL,EAAE;AAEF;MACa,kBAAkB,GAAY,OAAM,KAAK,KAAG;IACvD,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;AAC7B,EAAE;AAEF;MACa,+BAA+B,GAAY,OAAM,KAAK,KAAG;AACpE,IAAA,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,IAAS,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;AACrD"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { Mutator } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* Convert value to Date object
|
|
4
|
+
* Returns Invalid Date if value cannot be converted
|
|
5
|
+
*/
|
|
6
|
+
export declare const dateMutator: Mutator;
|
|
7
|
+
/** Convert date to ISO string format */
|
|
8
|
+
export declare const toISOStringMutator: Mutator;
|
|
9
|
+
/** Convert date to Unix timestamp (milliseconds) */
|
|
10
|
+
export declare const toTimestampMutator: Mutator;
|
|
11
|
+
/** Convert date to start of day (00:00:00) */
|
|
12
|
+
export declare const toStartOfDayMutator: Mutator;
|
|
13
|
+
/** Convert date to end of day (23:59:59.999) */
|
|
14
|
+
export declare const toEndOfDayMutator: Mutator;
|
|
15
|
+
/** Add or subtract days from date */
|
|
16
|
+
export declare const addDaysMutator: Mutator;
|
|
17
|
+
/** Add or subtract months from date */
|
|
18
|
+
export declare const addMonthsMutator: Mutator;
|
|
19
|
+
/** Add or subtract years from date */
|
|
20
|
+
export declare const addYearsMutator: Mutator;
|
|
21
|
+
/** Add or subtract hours from date */
|
|
22
|
+
export declare const addHoursMutator: Mutator;
|
|
23
|
+
/** Convert date to UTC */
|
|
24
|
+
export declare const toUTCMutator: Mutator;
|
|
25
|
+
/** Convert date to specific format using dayjs */
|
|
26
|
+
export declare const toFormatMutator: Mutator;
|
|
27
|
+
/** Convert to date only (remove time) */
|
|
28
|
+
export declare const toDateOnlyMutator: Mutator;
|
|
29
|
+
/** Convert to time only (HH:MM:SS) */
|
|
30
|
+
export declare const toTimeOnlyMutator: Mutator;
|
|
31
|
+
/** Set to start of month */
|
|
32
|
+
export declare const toStartOfMonthMutator: Mutator;
|
|
33
|
+
/** Set to end of month */
|
|
34
|
+
export declare const toEndOfMonthMutator: Mutator;
|
|
35
|
+
/** Set to start of year */
|
|
36
|
+
export declare const toStartOfYearMutator: Mutator;
|
|
37
|
+
/** Set to end of year */
|
|
38
|
+
export declare const toEndOfYearMutator: Mutator;
|
|
39
|
+
//# sourceMappingURL=date-mutators.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date-mutators.d.ts","sourceRoot":"","sources":["../../src/mutators/date-mutators.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAExC;;;GAGG;AACH,eAAO,MAAM,WAAW,EAAE,OAiBzB,CAAC;AAEF,wCAAwC;AACxC,eAAO,MAAM,kBAAkB,EAAE,OAGhC,CAAC;AAEF,oDAAoD;AACpD,eAAO,MAAM,kBAAkB,EAAE,OAGhC,CAAC;AAEF,8CAA8C;AAC9C,eAAO,MAAM,mBAAmB,EAAE,OAIjC,CAAC;AAEF,gDAAgD;AAChD,eAAO,MAAM,iBAAiB,EAAE,OAI/B,CAAC;AAEF,qCAAqC;AACrC,eAAO,MAAM,cAAc,EAAE,OAK5B,CAAC;AAEF,uCAAuC;AACvC,eAAO,MAAM,gBAAgB,EAAE,OAK9B,CAAC;AAEF,sCAAsC;AACtC,eAAO,MAAM,eAAe,EAAE,OAK7B,CAAC;AAEF,sCAAsC;AACtC,eAAO,MAAM,eAAe,EAAE,OAK7B,CAAC;AAEF,0BAA0B;AAC1B,eAAO,MAAM,YAAY,EAAE,OAG1B,CAAC;AAEF,kDAAkD;AAClD,eAAO,MAAM,eAAe,EAAE,OAG7B,CAAC;AAEF,yCAAyC;AACzC,eAAO,MAAM,iBAAiB,EAAE,OAG/B,CAAC;AAEF,sCAAsC;AACtC,eAAO,MAAM,iBAAiB,EAAE,OAG/B,CAAC;AAEF,4BAA4B;AAC5B,eAAO,MAAM,qBAAqB,EAAE,OAKnC,CAAC;AAEF,0BAA0B;AAC1B,eAAO,MAAM,mBAAmB,EAAE,OAMjC,CAAC;AAEF,2BAA2B;AAC3B,eAAO,MAAM,oBAAoB,EAAE,OAMlC,CAAC;AAEF,yBAAyB;AACzB,eAAO,MAAM,kBAAkB,EAAE,OAMhC,CAAC"}
|