@warlock.js/seal 4.0.47 → 4.0.59
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/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 +23 -0
- package/cjs/factory/validate.js.map +1 -0
- package/cjs/factory/validators.d.ts +41 -0
- package/cjs/factory/validators.d.ts.map +1 -0
- package/cjs/factory/validators.js +45 -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 +20 -0
- package/cjs/helpers/date-helpers.js.map +1 -0
- package/cjs/helpers/file.utils.d.ts +8 -0
- package/cjs/helpers/file.utils.d.ts.map +1 -0
- package/cjs/helpers/file.utils.js +29 -0
- package/cjs/helpers/file.utils.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 +6 -0
- package/cjs/helpers/index.d.ts.map +1 -0
- package/cjs/helpers/is-empty-value.d.ts +2 -0
- package/cjs/helpers/is-empty-value.d.ts.map +1 -0
- package/cjs/helpers/is-empty-value.js +3 -0
- package/cjs/helpers/is-empty-value.js.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 +48 -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 -63
- package/cjs/index.js.map +1 -1
- 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 +7 -0
- package/cjs/mutators/index.d.ts.map +1 -0
- package/cjs/mutators/number-mutators.d.ts +9 -0
- package/cjs/mutators/number-mutators.d.ts.map +1 -0
- package/cjs/mutators/number-mutators.js +23 -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/scalar-mutators.d.ts +3 -0
- package/cjs/mutators/scalar-mutators.d.ts.map +1 -0
- package/cjs/mutators/scalar-mutators.js +6 -0
- package/cjs/mutators/scalar-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 +18 -0
- package/cjs/rules/common/unknown-key.js.map +1 -0
- package/cjs/rules/conditional/forbidden-if-rules.d.ts +54 -0
- package/cjs/rules/conditional/forbidden-if-rules.d.ts.map +1 -0
- package/cjs/rules/conditional/forbidden-if-rules.js +112 -0
- package/cjs/rules/conditional/forbidden-if-rules.js.map +1 -0
- package/cjs/rules/conditional/index.d.ts +10 -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 +6 -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/union.d.ts +9 -0
- package/cjs/rules/core/union.d.ts.map +1 -0
- package/cjs/rules/core/union.js +40 -0
- package/cjs/rules/core/union.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 +48 -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 +65 -0
- package/cjs/rules/number/number-rules.d.ts.map +1 -0
- package/cjs/rules/number/number-rules.js +234 -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 +48 -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/file.types.d.ts +5 -0
- package/cjs/types/file.types.d.ts.map +1 -0
- package/cjs/types/index.d.ts +11 -0
- package/cjs/types/index.d.ts.map +1 -0
- package/cjs/types/inference-types.d.ts +27 -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 +54 -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 +59 -0
- package/cjs/validators/array-validator.d.ts.map +1 -0
- package/cjs/validators/array-validator.js +134 -0
- package/cjs/validators/array-validator.js.map +1 -0
- package/cjs/validators/base-validator.d.ts +610 -0
- package/cjs/validators/base-validator.d.ts.map +1 -0
- package/cjs/validators/base-validator.js +1160 -0
- package/cjs/validators/base-validator.js.map +1 -0
- package/cjs/validators/boolean-validator.d.ts +47 -0
- package/cjs/validators/boolean-validator.d.ts.map +1 -0
- package/cjs/validators/boolean-validator.js +54 -0
- package/cjs/validators/boolean-validator.js.map +1 -0
- package/cjs/validators/computed-validator.d.ts +64 -0
- package/cjs/validators/computed-validator.d.ts.map +1 -0
- package/cjs/validators/computed-validator.js +109 -0
- package/cjs/validators/computed-validator.js.map +1 -0
- package/cjs/validators/date-validator.d.ts +307 -0
- package/cjs/validators/date-validator.d.ts.map +1 -0
- package/cjs/validators/date-validator.js +645 -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 +26 -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/managed-validator.d.ts +38 -0
- package/cjs/validators/managed-validator.d.ts.map +1 -0
- package/cjs/validators/managed-validator.js +34 -0
- package/cjs/validators/managed-validator.js.map +1 -0
- package/cjs/validators/number-validator.d.ts +113 -0
- package/cjs/validators/number-validator.d.ts.map +1 -0
- package/cjs/validators/number-validator.js +192 -0
- package/cjs/validators/number-validator.js.map +1 -0
- package/cjs/validators/numeric-validator.d.ts +15 -0
- package/cjs/validators/numeric-validator.d.ts.map +1 -0
- package/cjs/validators/numeric-validator.js +18 -0
- package/cjs/validators/numeric-validator.js.map +1 -0
- package/cjs/validators/object-validator.d.ts +187 -0
- package/cjs/validators/object-validator.d.ts.map +1 -0
- package/cjs/validators/object-validator.js +416 -0
- package/cjs/validators/object-validator.js.map +1 -0
- package/cjs/validators/record-validator.d.ts +33 -0
- package/cjs/validators/record-validator.d.ts.map +1 -0
- package/cjs/validators/record-validator.js +70 -0
- package/cjs/validators/record-validator.js.map +1 -0
- package/cjs/validators/scalar-validator.d.ts +82 -0
- package/cjs/validators/scalar-validator.d.ts.map +1 -0
- package/cjs/validators/scalar-validator.js +160 -0
- package/cjs/validators/scalar-validator.js.map +1 -0
- package/cjs/validators/string-validator.d.ts +191 -0
- package/cjs/validators/string-validator.d.ts.map +1 -0
- package/cjs/validators/string-validator.js +410 -0
- package/cjs/validators/string-validator.js.map +1 -0
- package/cjs/validators/tuple-validator.d.ts +34 -0
- package/cjs/validators/tuple-validator.d.ts.map +1 -0
- package/cjs/validators/tuple-validator.js +79 -0
- package/cjs/validators/tuple-validator.js.map +1 -0
- package/cjs/validators/union-validator.d.ts +42 -0
- package/cjs/validators/union-validator.d.ts.map +1 -0
- package/cjs/validators/union-validator.js +44 -0
- package/cjs/validators/union-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 +23 -0
- package/esm/factory/validate.js.map +1 -0
- package/esm/factory/validators.d.ts +41 -0
- package/esm/factory/validators.d.ts.map +1 -0
- package/esm/factory/validators.js +45 -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 +20 -0
- package/esm/helpers/date-helpers.js.map +1 -0
- package/esm/helpers/file.utils.d.ts +8 -0
- package/esm/helpers/file.utils.d.ts.map +1 -0
- package/esm/helpers/file.utils.js +29 -0
- package/esm/helpers/file.utils.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 +6 -0
- package/esm/helpers/index.d.ts.map +1 -0
- package/esm/helpers/is-empty-value.d.ts +2 -0
- package/esm/helpers/is-empty-value.d.ts.map +1 -0
- package/esm/helpers/is-empty-value.js +3 -0
- package/esm/helpers/is-empty-value.js.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 +48 -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 -10
- package/esm/index.js.map +1 -1
- 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 +7 -0
- package/esm/mutators/index.d.ts.map +1 -0
- package/esm/mutators/number-mutators.d.ts +9 -0
- package/esm/mutators/number-mutators.d.ts.map +1 -0
- package/esm/mutators/number-mutators.js +23 -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/scalar-mutators.d.ts +3 -0
- package/esm/mutators/scalar-mutators.d.ts.map +1 -0
- package/esm/mutators/scalar-mutators.js +6 -0
- package/esm/mutators/scalar-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 +18 -0
- package/esm/rules/common/unknown-key.js.map +1 -0
- package/esm/rules/conditional/forbidden-if-rules.d.ts +54 -0
- package/esm/rules/conditional/forbidden-if-rules.d.ts.map +1 -0
- package/esm/rules/conditional/forbidden-if-rules.js +112 -0
- package/esm/rules/conditional/forbidden-if-rules.js.map +1 -0
- package/esm/rules/conditional/index.d.ts +10 -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 +6 -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/union.d.ts +9 -0
- package/esm/rules/core/union.d.ts.map +1 -0
- package/esm/rules/core/union.js +40 -0
- package/esm/rules/core/union.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 +48 -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 +65 -0
- package/esm/rules/number/number-rules.d.ts.map +1 -0
- package/esm/rules/number/number-rules.js +234 -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 +48 -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/file.types.d.ts +5 -0
- package/esm/types/file.types.d.ts.map +1 -0
- package/esm/types/index.d.ts +11 -0
- package/esm/types/index.d.ts.map +1 -0
- package/esm/types/inference-types.d.ts +27 -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 +54 -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 +59 -0
- package/esm/validators/array-validator.d.ts.map +1 -0
- package/esm/validators/array-validator.js +134 -0
- package/esm/validators/array-validator.js.map +1 -0
- package/esm/validators/base-validator.d.ts +610 -0
- package/esm/validators/base-validator.d.ts.map +1 -0
- package/esm/validators/base-validator.js +1160 -0
- package/esm/validators/base-validator.js.map +1 -0
- package/esm/validators/boolean-validator.d.ts +47 -0
- package/esm/validators/boolean-validator.d.ts.map +1 -0
- package/esm/validators/boolean-validator.js +54 -0
- package/esm/validators/boolean-validator.js.map +1 -0
- package/esm/validators/computed-validator.d.ts +64 -0
- package/esm/validators/computed-validator.d.ts.map +1 -0
- package/esm/validators/computed-validator.js +109 -0
- package/esm/validators/computed-validator.js.map +1 -0
- package/esm/validators/date-validator.d.ts +307 -0
- package/esm/validators/date-validator.d.ts.map +1 -0
- package/esm/validators/date-validator.js +645 -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 +26 -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/managed-validator.d.ts +38 -0
- package/esm/validators/managed-validator.d.ts.map +1 -0
- package/esm/validators/managed-validator.js +34 -0
- package/esm/validators/managed-validator.js.map +1 -0
- package/esm/validators/number-validator.d.ts +113 -0
- package/esm/validators/number-validator.d.ts.map +1 -0
- package/esm/validators/number-validator.js +192 -0
- package/esm/validators/number-validator.js.map +1 -0
- package/esm/validators/numeric-validator.d.ts +15 -0
- package/esm/validators/numeric-validator.d.ts.map +1 -0
- package/esm/validators/numeric-validator.js +18 -0
- package/esm/validators/numeric-validator.js.map +1 -0
- package/esm/validators/object-validator.d.ts +187 -0
- package/esm/validators/object-validator.d.ts.map +1 -0
- package/esm/validators/object-validator.js +416 -0
- package/esm/validators/object-validator.js.map +1 -0
- package/esm/validators/record-validator.d.ts +33 -0
- package/esm/validators/record-validator.d.ts.map +1 -0
- package/esm/validators/record-validator.js +70 -0
- package/esm/validators/record-validator.js.map +1 -0
- package/esm/validators/scalar-validator.d.ts +82 -0
- package/esm/validators/scalar-validator.d.ts.map +1 -0
- package/esm/validators/scalar-validator.js +160 -0
- package/esm/validators/scalar-validator.js.map +1 -0
- package/esm/validators/string-validator.d.ts +191 -0
- package/esm/validators/string-validator.d.ts.map +1 -0
- package/esm/validators/string-validator.js +410 -0
- package/esm/validators/string-validator.js.map +1 -0
- package/esm/validators/tuple-validator.d.ts +34 -0
- package/esm/validators/tuple-validator.d.ts.map +1 -0
- package/esm/validators/tuple-validator.js +79 -0
- package/esm/validators/tuple-validator.js.map +1 -0
- package/esm/validators/union-validator.d.ts +42 -0
- package/esm/validators/union-validator.d.ts.map +1 -0
- package/esm/validators/union-validator.js +44 -0
- package/esm/validators/union-validator.js.map +1 -0
- package/package.json +47 -36
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
'use strict';var getFieldValue=require('../../helpers/get-field-value.js'),validationHelpers=require('../../helpers/validation-helpers.js'),isEmptyValue=require('../../helpers/is-empty-value.js');/**
|
|
2
|
+
* Present if rule - field must be present if another field equals a specific value
|
|
3
|
+
* Supports both global and sibling scope
|
|
4
|
+
*/
|
|
5
|
+
const presentIfRule = {
|
|
6
|
+
name: "presentIf",
|
|
7
|
+
description: "The field must be present if another field equals a specific value",
|
|
8
|
+
sortOrder: -2,
|
|
9
|
+
requiresValue: false,
|
|
10
|
+
defaultErrorMessage: "The :input field must be present",
|
|
11
|
+
async validate(value, context) {
|
|
12
|
+
const { value: expectedValue } = this.context.options;
|
|
13
|
+
const fieldValue = getFieldValue.getFieldValue(this, context);
|
|
14
|
+
// Field must be present if the other field equals the expected value
|
|
15
|
+
if (value === undefined && fieldValue === expectedValue) {
|
|
16
|
+
return validationHelpers.invalidRule(this, context);
|
|
17
|
+
}
|
|
18
|
+
return validationHelpers.VALID_RULE;
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Present if empty rule - field must be present if another field is empty
|
|
23
|
+
* Supports both global and sibling scope
|
|
24
|
+
*/
|
|
25
|
+
const presentIfEmptyRule = {
|
|
26
|
+
name: "presentIfEmpty",
|
|
27
|
+
description: "The field must be present if another field is empty",
|
|
28
|
+
sortOrder: -2,
|
|
29
|
+
requiresValue: false,
|
|
30
|
+
defaultErrorMessage: "The :input field must be present",
|
|
31
|
+
async validate(value, context) {
|
|
32
|
+
const fieldValue = getFieldValue.getFieldValue(this, context);
|
|
33
|
+
// Field must be present if the other field is empty
|
|
34
|
+
if (value === undefined && isEmptyValue.isEmptyValue(fieldValue)) {
|
|
35
|
+
return validationHelpers.invalidRule(this, context);
|
|
36
|
+
}
|
|
37
|
+
return validationHelpers.VALID_RULE;
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Present if not empty rule - field must be present if another field is not empty
|
|
42
|
+
* Supports both global and sibling scope
|
|
43
|
+
*/
|
|
44
|
+
const presentIfNotEmptyRule = {
|
|
45
|
+
name: "presentIfNotEmpty",
|
|
46
|
+
description: "The field must be present if another field is not empty",
|
|
47
|
+
sortOrder: -2,
|
|
48
|
+
requiresValue: false,
|
|
49
|
+
defaultErrorMessage: "The :input field must be present",
|
|
50
|
+
async validate(value, context) {
|
|
51
|
+
const fieldValue = getFieldValue.getFieldValue(this, context);
|
|
52
|
+
// Field must be present if the other field is not empty
|
|
53
|
+
if (value === undefined && !isEmptyValue.isEmptyValue(fieldValue)) {
|
|
54
|
+
return validationHelpers.invalidRule(this, context);
|
|
55
|
+
}
|
|
56
|
+
return validationHelpers.VALID_RULE;
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Present if in rule - field must be present if another field's value is in the given array
|
|
61
|
+
* Supports both global and sibling scope
|
|
62
|
+
*/
|
|
63
|
+
const presentIfInRule = {
|
|
64
|
+
name: "presentIfIn",
|
|
65
|
+
description: "The field must be present if another field's value is in the given array",
|
|
66
|
+
sortOrder: -2,
|
|
67
|
+
requiresValue: false,
|
|
68
|
+
defaultErrorMessage: "The :input field must be present",
|
|
69
|
+
async validate(value, context) {
|
|
70
|
+
const { values } = this.context.options;
|
|
71
|
+
const fieldValue = getFieldValue.getFieldValue(this, context);
|
|
72
|
+
// Field must be present if the other field's value is in the array
|
|
73
|
+
if (value === undefined && values.includes(fieldValue)) {
|
|
74
|
+
return validationHelpers.invalidRule(this, context);
|
|
75
|
+
}
|
|
76
|
+
return validationHelpers.VALID_RULE;
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* Present if not in rule - field must be present if another field's value is NOT in the given array
|
|
81
|
+
* Supports both global and sibling scope
|
|
82
|
+
*/
|
|
83
|
+
const presentIfNotInRule = {
|
|
84
|
+
name: "presentIfNotIn",
|
|
85
|
+
description: "The field must be present if another field's value is NOT in the given array",
|
|
86
|
+
sortOrder: -2,
|
|
87
|
+
requiresValue: false,
|
|
88
|
+
defaultErrorMessage: "The :input field must be present",
|
|
89
|
+
async validate(value, context) {
|
|
90
|
+
const { values } = this.context.options;
|
|
91
|
+
const fieldValue = getFieldValue.getFieldValue(this, context);
|
|
92
|
+
// Field must be present if the other field's value is NOT in the array
|
|
93
|
+
if (value === undefined && !values.includes(fieldValue)) {
|
|
94
|
+
return validationHelpers.invalidRule(this, context);
|
|
95
|
+
}
|
|
96
|
+
return validationHelpers.VALID_RULE;
|
|
97
|
+
},
|
|
98
|
+
};exports.presentIfEmptyRule=presentIfEmptyRule;exports.presentIfInRule=presentIfInRule;exports.presentIfNotEmptyRule=presentIfNotEmptyRule;exports.presentIfNotInRule=presentIfNotInRule;exports.presentIfRule=presentIfRule;//# sourceMappingURL=present-if-rules.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"present-if-rules.js","sources":["../../../src/rules/conditional/present-if-rules.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C;AACvD,IAAA,MAAM,QAAQ,CAAC,KAAU,EAAE,OAAO,EAAA;QAChC,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;QACxC,MAAM,UAAU,GAAGF,2BAAa,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;;QAGhD,IAAI,KAAK,KAAK,SAAS,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE;AACvD,YAAA,OAAOC,6BAAW,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AACnC,SAAA;AAED,QAAA,OAAOC,4BAAU,CAAC;KACnB;"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { SchemaRule } from "../../types";
|
|
2
|
+
/**
|
|
3
|
+
* Present unless rule - field must be present unless another field equals a specific value
|
|
4
|
+
* Supports both global and sibling scope
|
|
5
|
+
*/
|
|
6
|
+
export declare const presentUnlessRule: SchemaRule<{
|
|
7
|
+
field: string;
|
|
8
|
+
value: any;
|
|
9
|
+
scope?: "global" | "sibling";
|
|
10
|
+
}>;
|
|
11
|
+
//# sourceMappingURL=present-unless-rules.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"present-unless-rules.d.ts","sourceRoot":"","sources":["../../../src/rules/conditional/present-unless-rules.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C;;;GAGG;AACH,eAAO,MAAM,iBAAiB,EAAE,UAAU,CAAC;IACzC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,GAAG,CAAC;IACX,KAAK,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;CAC9B,CAkBA,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use strict';var getFieldValue=require('../../helpers/get-field-value.js'),validationHelpers=require('../../helpers/validation-helpers.js');/**
|
|
2
|
+
* Present unless rule - field must be present unless another field equals a specific value
|
|
3
|
+
* Supports both global and sibling scope
|
|
4
|
+
*/
|
|
5
|
+
const presentUnlessRule = {
|
|
6
|
+
name: "presentUnless",
|
|
7
|
+
description: "The field must be present unless another field equals a specific value",
|
|
8
|
+
sortOrder: -2,
|
|
9
|
+
requiresValue: false,
|
|
10
|
+
defaultErrorMessage: "The :input field must be present",
|
|
11
|
+
async validate(value, context) {
|
|
12
|
+
const { value: expectedValue } = this.context.options;
|
|
13
|
+
const fieldValue = getFieldValue.getFieldValue(this, context);
|
|
14
|
+
// Field must be present unless the other field equals the expected value
|
|
15
|
+
if (value === undefined && fieldValue !== expectedValue) {
|
|
16
|
+
return validationHelpers.invalidRule(this, context);
|
|
17
|
+
}
|
|
18
|
+
return validationHelpers.VALID_RULE;
|
|
19
|
+
},
|
|
20
|
+
};exports.presentUnlessRule=presentUnlessRule;//# sourceMappingURL=present-unless-rules.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"present-unless-rules.js","sources":["../../../src/rules/conditional/present-unless-rules.ts"],"sourcesContent":[null],"names":["getFieldValue","invalidRule","VALID_RULE"],"mappings":"4IAGA;;;AAGG;AACU,MAAA,iBAAiB,GAIzB;AACH,IAAA,IAAI,EAAE,eAAe;AACrB,IAAA,WAAW,EACT,wEAAwE;IAC1E,SAAS,EAAE,CAAC,CAAC;AACb,IAAA,aAAa,EAAE,KAAK;AACpB,IAAA,mBAAmB,EAAE,kCAAkC;AACvD,IAAA,MAAM,QAAQ,CAAC,KAAU,EAAE,OAAO,EAAA;QAChC,MAAM,EAAE,KAAK,EAAE,aAAa,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;QACtD,MAAM,UAAU,GAAGA,2BAAa,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;;AAGhD,QAAA,IAAI,KAAK,KAAK,SAAS,IAAI,UAAU,KAAK,aAAa,EAAE;AACvD,YAAA,OAAOC,6BAAW,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AACnC,SAAA;AAED,QAAA,OAAOC,4BAAU,CAAC;KACnB;"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { SchemaRule } from "../../types";
|
|
2
|
+
/**
|
|
3
|
+
* Present with rule - field must be present if another field is present
|
|
4
|
+
* Supports both global and sibling scope
|
|
5
|
+
*/
|
|
6
|
+
export declare const presentWithRule: SchemaRule<{
|
|
7
|
+
field: string;
|
|
8
|
+
scope?: "global" | "sibling";
|
|
9
|
+
}>;
|
|
10
|
+
/**
|
|
11
|
+
* Present with all rule - field must be present if all specified fields are present
|
|
12
|
+
* Supports both global and sibling scope
|
|
13
|
+
*/
|
|
14
|
+
export declare const presentWithAllRule: SchemaRule<{
|
|
15
|
+
fields: string[];
|
|
16
|
+
scope?: "global" | "sibling";
|
|
17
|
+
}>;
|
|
18
|
+
/**
|
|
19
|
+
* Present with any rule - field must be present if any of the specified fields is present
|
|
20
|
+
* Supports both global and sibling scope
|
|
21
|
+
*/
|
|
22
|
+
export declare const presentWithAnyRule: SchemaRule<{
|
|
23
|
+
fields: string[];
|
|
24
|
+
scope?: "global" | "sibling";
|
|
25
|
+
}>;
|
|
26
|
+
//# sourceMappingURL=present-with-rules.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"present-with-rules.d.ts","sourceRoot":"","sources":["../../../src/rules/conditional/present-with-rules.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C;;;GAGG;AACH,eAAO,MAAM,eAAe,EAAE,UAAU,CAAC;IACvC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;CAC9B,CAgBA,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,kBAAkB,EAAE,UAAU,CAAC;IAC1C,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,KAAK,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;CAC9B,CAoBA,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,kBAAkB,EAAE,UAAU,CAAC;IAC1C,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,KAAK,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;CAC9B,CAqBA,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
'use strict';var reinforcements=require('@mongez/reinforcements'),getFieldValue=require('../../helpers/get-field-value.js'),validationHelpers=require('../../helpers/validation-helpers.js');/**
|
|
2
|
+
* Present with rule - field must be present if another field is present
|
|
3
|
+
* Supports both global and sibling scope
|
|
4
|
+
*/
|
|
5
|
+
const presentWithRule = {
|
|
6
|
+
name: "presentWith",
|
|
7
|
+
description: "The field must be present if another field is present",
|
|
8
|
+
sortOrder: -2,
|
|
9
|
+
requiresValue: false,
|
|
10
|
+
defaultErrorMessage: "The :input field must be present",
|
|
11
|
+
async validate(value, context) {
|
|
12
|
+
const fieldValue = getFieldValue.getFieldValue(this, context);
|
|
13
|
+
// The field must be present if the other field is present
|
|
14
|
+
if (value === undefined && fieldValue !== undefined) {
|
|
15
|
+
return validationHelpers.invalidRule(this, context);
|
|
16
|
+
}
|
|
17
|
+
return validationHelpers.VALID_RULE;
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Present with all rule - field must be present if all specified fields are present
|
|
22
|
+
* Supports both global and sibling scope
|
|
23
|
+
*/
|
|
24
|
+
const presentWithAllRule = {
|
|
25
|
+
name: "presentWithAll",
|
|
26
|
+
description: "The field must be present if all specified fields are present",
|
|
27
|
+
sortOrder: -2,
|
|
28
|
+
requiresValue: false,
|
|
29
|
+
defaultErrorMessage: "The :input field must be present",
|
|
30
|
+
async validate(value, context) {
|
|
31
|
+
const { fields, scope = "global" } = this.context.options;
|
|
32
|
+
const source = scope === "sibling" ? context.parent : context.allValues;
|
|
33
|
+
// Check if all fields are present
|
|
34
|
+
const allPresent = fields.every(field => reinforcements.get(source, field) !== undefined);
|
|
35
|
+
// Field must be present if all other fields are present
|
|
36
|
+
if (value === undefined && allPresent) {
|
|
37
|
+
return validationHelpers.invalidRule(this, context);
|
|
38
|
+
}
|
|
39
|
+
return validationHelpers.VALID_RULE;
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Present with any rule - field must be present if any of the specified fields is present
|
|
44
|
+
* Supports both global and sibling scope
|
|
45
|
+
*/
|
|
46
|
+
const presentWithAnyRule = {
|
|
47
|
+
name: "presentWithAny",
|
|
48
|
+
description: "The field must be present if any of the specified fields is present",
|
|
49
|
+
sortOrder: -2,
|
|
50
|
+
requiresValue: false,
|
|
51
|
+
defaultErrorMessage: "The :input field must be present",
|
|
52
|
+
async validate(value, context) {
|
|
53
|
+
const { fields, scope = "global" } = this.context.options;
|
|
54
|
+
const source = scope === "sibling" ? context.parent : context.allValues;
|
|
55
|
+
// Check if any field is present
|
|
56
|
+
const anyPresent = fields.some(field => reinforcements.get(source, field) !== undefined);
|
|
57
|
+
// Field must be present if any other field is present
|
|
58
|
+
if (value === undefined && anyPresent) {
|
|
59
|
+
return validationHelpers.invalidRule(this, context);
|
|
60
|
+
}
|
|
61
|
+
return validationHelpers.VALID_RULE;
|
|
62
|
+
},
|
|
63
|
+
};exports.presentWithAllRule=presentWithAllRule;exports.presentWithAnyRule=presentWithAnyRule;exports.presentWithRule=presentWithRule;//# sourceMappingURL=present-with-rules.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"present-with-rules.js","sources":["../../../src/rules/conditional/present-with-rules.ts"],"sourcesContent":[null],"names":["getFieldValue","invalidRule","VALID_RULE","get"],"mappings":"6LAIA;;;AAGG;AACU,MAAA,eAAe,GAGvB;AACH,IAAA,IAAI,EAAE,aAAa;AACnB,IAAA,WAAW,EAAE,uDAAuD;IACpE,SAAS,EAAE,CAAC,CAAC;AACb,IAAA,aAAa,EAAE,KAAK;AACpB,IAAA,mBAAmB,EAAE,kCAAkC;AACvD,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AACpB,IAAA,mBAAmB,EAAE,kCAAkC;AACvD,IAAA,MAAM,QAAQ,CAAC,KAAU,EAAE,OAAO,EAAA;AAChC,QAAA,MAAM,EAAE,MAAM,EAAE,KAAK,GAAG,QAAQ,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;AAC1D,QAAA,MAAM,MAAM,GAAG,KAAK,KAAK,SAAS,GAAG,OAAO,CAAC,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC;;AAGxE,QAAA,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,IAAIC,kBAAG,CAAC,MAAM,EAAE,KAAK,CAAC,KAAK,SAAS,CAAC,CAAC;;AAG1E,QAAA,IAAI,KAAK,KAAK,SAAS,IAAI,UAAU,EAAE;AACrC,YAAA,OAAOF,6BAAW,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AACnC,SAAA;AAED,QAAA,OAAOC,4BAAU,CAAC;KACnB;"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { SchemaRule } from "../../types";
|
|
2
|
+
/**
|
|
3
|
+
* Present without rule - field must be present if another field is missing
|
|
4
|
+
* Supports both global and sibling scope
|
|
5
|
+
*/
|
|
6
|
+
export declare const presentWithoutRule: SchemaRule<{
|
|
7
|
+
field: string;
|
|
8
|
+
scope?: "global" | "sibling";
|
|
9
|
+
}>;
|
|
10
|
+
/**
|
|
11
|
+
* Present without all rule - field must be present if all specified fields are missing
|
|
12
|
+
* Supports both global and sibling scope
|
|
13
|
+
*/
|
|
14
|
+
export declare const presentWithoutAllRule: SchemaRule<{
|
|
15
|
+
fields: string[];
|
|
16
|
+
scope?: "global" | "sibling";
|
|
17
|
+
}>;
|
|
18
|
+
/**
|
|
19
|
+
* Present without any rule - field must be present if any of the specified fields is missing
|
|
20
|
+
* Supports both global and sibling scope
|
|
21
|
+
*/
|
|
22
|
+
export declare const presentWithoutAnyRule: SchemaRule<{
|
|
23
|
+
fields: string[];
|
|
24
|
+
scope?: "global" | "sibling";
|
|
25
|
+
}>;
|
|
26
|
+
//# sourceMappingURL=present-without-rules.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"present-without-rules.d.ts","sourceRoot":"","sources":["../../../src/rules/conditional/present-without-rules.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C;;;GAGG;AACH,eAAO,MAAM,kBAAkB,EAAE,UAAU,CAAC;IAC1C,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;CAC9B,CAgBA,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,qBAAqB,EAAE,UAAU,CAAC;IAC7C,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,KAAK,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;CAC9B,CAoBA,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,qBAAqB,EAAE,UAAU,CAAC;IAC7C,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,KAAK,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;CAC9B,CAqBA,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
'use strict';var reinforcements=require('@mongez/reinforcements'),getFieldValue=require('../../helpers/get-field-value.js'),validationHelpers=require('../../helpers/validation-helpers.js');/**
|
|
2
|
+
* Present without rule - field must be present if another field is missing
|
|
3
|
+
* Supports both global and sibling scope
|
|
4
|
+
*/
|
|
5
|
+
const presentWithoutRule = {
|
|
6
|
+
name: "presentWithout",
|
|
7
|
+
description: "The field must be present if another field is missing",
|
|
8
|
+
sortOrder: -2,
|
|
9
|
+
requiresValue: false,
|
|
10
|
+
defaultErrorMessage: "The :input field must be present",
|
|
11
|
+
async validate(value, context) {
|
|
12
|
+
const fieldValue = getFieldValue.getFieldValue(this, context);
|
|
13
|
+
// Field must be present if the other field is missing
|
|
14
|
+
if (value === undefined && fieldValue === undefined) {
|
|
15
|
+
return validationHelpers.invalidRule(this, context);
|
|
16
|
+
}
|
|
17
|
+
return validationHelpers.VALID_RULE;
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Present without all rule - field must be present if all specified fields are missing
|
|
22
|
+
* Supports both global and sibling scope
|
|
23
|
+
*/
|
|
24
|
+
const presentWithoutAllRule = {
|
|
25
|
+
name: "presentWithoutAll",
|
|
26
|
+
description: "The field must be present if all specified fields are missing",
|
|
27
|
+
sortOrder: -2,
|
|
28
|
+
requiresValue: false,
|
|
29
|
+
defaultErrorMessage: "The :input field must be present",
|
|
30
|
+
async validate(value, context) {
|
|
31
|
+
const { fields, scope = "global" } = this.context.options;
|
|
32
|
+
const source = scope === "sibling" ? context.parent : context.allValues;
|
|
33
|
+
// Check if all fields are missing
|
|
34
|
+
const allMissing = fields.every(field => reinforcements.get(source, field) === undefined);
|
|
35
|
+
// Field must be present if all other fields are missing
|
|
36
|
+
if (value === undefined && allMissing) {
|
|
37
|
+
return validationHelpers.invalidRule(this, context);
|
|
38
|
+
}
|
|
39
|
+
return validationHelpers.VALID_RULE;
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Present without any rule - field must be present if any of the specified fields is missing
|
|
44
|
+
* Supports both global and sibling scope
|
|
45
|
+
*/
|
|
46
|
+
const presentWithoutAnyRule = {
|
|
47
|
+
name: "presentWithoutAny",
|
|
48
|
+
description: "The field must be present if any of the specified fields is missing",
|
|
49
|
+
sortOrder: -2,
|
|
50
|
+
requiresValue: false,
|
|
51
|
+
defaultErrorMessage: "The :input field must be present",
|
|
52
|
+
async validate(value, context) {
|
|
53
|
+
const { fields, scope = "global" } = this.context.options;
|
|
54
|
+
const source = scope === "sibling" ? context.parent : context.allValues;
|
|
55
|
+
// Check if any field is missing
|
|
56
|
+
const anyMissing = fields.some(field => reinforcements.get(source, field) === undefined);
|
|
57
|
+
// Field must be present if any other field is missing
|
|
58
|
+
if (value === undefined && anyMissing) {
|
|
59
|
+
return validationHelpers.invalidRule(this, context);
|
|
60
|
+
}
|
|
61
|
+
return validationHelpers.VALID_RULE;
|
|
62
|
+
},
|
|
63
|
+
};exports.presentWithoutAllRule=presentWithoutAllRule;exports.presentWithoutAnyRule=presentWithoutAnyRule;exports.presentWithoutRule=presentWithoutRule;//# sourceMappingURL=present-without-rules.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"present-without-rules.js","sources":["../../../src/rules/conditional/present-without-rules.ts"],"sourcesContent":[null],"names":["getFieldValue","invalidRule","VALID_RULE","get"],"mappings":"6LAIA;;;AAGG;AACU,MAAA,kBAAkB,GAG1B;AACH,IAAA,IAAI,EAAE,gBAAgB;AACtB,IAAA,WAAW,EAAE,uDAAuD;IACpE,SAAS,EAAE,CAAC,CAAC;AACb,IAAA,aAAa,EAAE,KAAK;AACpB,IAAA,mBAAmB,EAAE,kCAAkC;AACvD,IAAA,MAAM,QAAQ,CAAC,KAAU,EAAE,OAAO,EAAA;QAChC,MAAM,UAAU,GAAGA,2BAAa,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;;AAGhD,QAAA,IAAI,KAAK,KAAK,SAAS,IAAI,UAAU,KAAK,SAAS,EAAE;AACnD,YAAA,OAAOC,6BAAW,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AACnC,SAAA;AAED,QAAA,OAAOC,4BAAU,CAAC;KACnB;EACD;AAEF;;;AAGG;AACU,MAAA,qBAAqB,GAG7B;AACH,IAAA,IAAI,EAAE,mBAAmB;AACzB,IAAA,WAAW,EAAE,+DAA+D;IAC5E,SAAS,EAAE,CAAC,CAAC;AACb,IAAA,aAAa,EAAE,KAAK;AACpB,IAAA,mBAAmB,EAAE,kCAAkC;AACvD,IAAA,MAAM,QAAQ,CAAC,KAAU,EAAE,OAAO,EAAA;AAChC,QAAA,MAAM,EAAE,MAAM,EAAE,KAAK,GAAG,QAAQ,EAAE,GAAG,IAA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|
1
|
+
import type { SchemaRule } from "../../types";
|
|
2
|
+
/**
|
|
3
|
+
* Required if rule - field is required if another field equals a specific value
|
|
4
|
+
* Supports both global and sibling scope
|
|
5
|
+
*/
|
|
6
|
+
export declare const requiredIfRule: SchemaRule<{
|
|
7
|
+
field: string;
|
|
8
|
+
value: any;
|
|
9
|
+
scope?: "global" | "sibling";
|
|
10
|
+
}>;
|
|
11
|
+
/**
|
|
12
|
+
* Required if empty rule - field is required if another field is empty
|
|
13
|
+
* Supports both global and sibling scope
|
|
14
|
+
*/
|
|
15
|
+
export declare const requiredIfEmptyRule: SchemaRule<{
|
|
16
|
+
field: string;
|
|
17
|
+
scope?: "global" | "sibling";
|
|
18
|
+
}>;
|
|
19
|
+
/**
|
|
20
|
+
* Required if not empty rule - field is required if another field is not empty
|
|
21
|
+
* Supports both global and sibling scope
|
|
22
|
+
*/
|
|
23
|
+
export declare const requiredIfNotEmptyRule: SchemaRule<{
|
|
24
|
+
field: string;
|
|
25
|
+
scope?: "global" | "sibling";
|
|
26
|
+
}>;
|
|
27
|
+
/**
|
|
28
|
+
* Required if in rule - field is required if another field's value is in the given array
|
|
29
|
+
* Supports both global and sibling scope
|
|
30
|
+
*/
|
|
31
|
+
export declare const requiredIfInRule: SchemaRule<{
|
|
32
|
+
field: string;
|
|
33
|
+
values: any[];
|
|
34
|
+
scope?: "global" | "sibling";
|
|
35
|
+
}>;
|
|
36
|
+
/**
|
|
37
|
+
* Required if not in rule - field is required if another field's value is NOT in the given array
|
|
38
|
+
* Supports both global and sibling scope
|
|
39
|
+
*/
|
|
40
|
+
export declare const requiredIfNotInRule: SchemaRule<{
|
|
41
|
+
field: string;
|
|
42
|
+
values: any[];
|
|
43
|
+
scope?: "global" | "sibling";
|
|
44
|
+
}>;
|
|
45
|
+
//# sourceMappingURL=required-if-rules.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"required-if-rules.d.ts","sourceRoot":"","sources":["../../../src/rules/conditional/required-if-rules.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C;;;GAGG;AACH,eAAO,MAAM,cAAc,EAAE,UAAU,CAAC;IACtC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,GAAG,CAAC;IACX,KAAK,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;CAC9B,CAiBA,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,mBAAmB,EAAE,UAAU,CAAC;IAC3C,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;CAC9B,CAgBA,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,sBAAsB,EAAE,UAAU,CAAC;IAC9C,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;CAC9B,CAgBA,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,gBAAgB,EAAE,UAAU,CAAC;IACxC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,GAAG,EAAE,CAAC;IACd,KAAK,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;CAC9B,CAiBA,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,mBAAmB,EAAE,UAAU,CAAC;IAC3C,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,GAAG,EAAE,CAAC;IACd,KAAK,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;CAC9B,CAiBA,CAAC"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
'use strict';var getFieldValue=require('../../helpers/get-field-value.js'),validationHelpers=require('../../helpers/validation-helpers.js'),isEmptyValue=require('../../helpers/is-empty-value.js');/**
|
|
2
|
+
* Required if rule - field is required if another field equals a specific value
|
|
3
|
+
* Supports both global and sibling scope
|
|
4
|
+
*/
|
|
5
|
+
const requiredIfRule = {
|
|
6
|
+
name: "requiredIf",
|
|
7
|
+
description: "The field is required if another field equals a specific value",
|
|
8
|
+
sortOrder: -2,
|
|
9
|
+
requiresValue: false,
|
|
10
|
+
defaultErrorMessage: "The :input is required",
|
|
11
|
+
async validate(value, context) {
|
|
12
|
+
const { value: expectedValue } = this.context.options;
|
|
13
|
+
const fieldValue = getFieldValue.getFieldValue(this, context);
|
|
14
|
+
// Field is required if the other field equals the expected value
|
|
15
|
+
if (isEmptyValue.isEmptyValue(value) && fieldValue === expectedValue) {
|
|
16
|
+
return validationHelpers.invalidRule(this, context);
|
|
17
|
+
}
|
|
18
|
+
return validationHelpers.VALID_RULE;
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Required if empty rule - field is required if another field is empty
|
|
23
|
+
* Supports both global and sibling scope
|
|
24
|
+
*/
|
|
25
|
+
const requiredIfEmptyRule = {
|
|
26
|
+
name: "requiredIfEmpty",
|
|
27
|
+
description: "The field is required if another field is empty",
|
|
28
|
+
sortOrder: -2,
|
|
29
|
+
requiresValue: false,
|
|
30
|
+
defaultErrorMessage: "The :input is required",
|
|
31
|
+
async validate(value, context) {
|
|
32
|
+
const fieldValue = getFieldValue.getFieldValue(this, context);
|
|
33
|
+
// Field is required if the other field is empty
|
|
34
|
+
if (isEmptyValue.isEmptyValue(value) && isEmptyValue.isEmptyValue(fieldValue)) {
|
|
35
|
+
return validationHelpers.invalidRule(this, context);
|
|
36
|
+
}
|
|
37
|
+
return validationHelpers.VALID_RULE;
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Required if not empty rule - field is required if another field is not empty
|
|
42
|
+
* Supports both global and sibling scope
|
|
43
|
+
*/
|
|
44
|
+
const requiredIfNotEmptyRule = {
|
|
45
|
+
name: "requiredIfNotEmpty",
|
|
46
|
+
description: "The field is required if another field is not empty",
|
|
47
|
+
sortOrder: -2,
|
|
48
|
+
requiresValue: false,
|
|
49
|
+
defaultErrorMessage: "The :input is required",
|
|
50
|
+
async validate(value, context) {
|
|
51
|
+
const fieldValue = getFieldValue.getFieldValue(this, context);
|
|
52
|
+
// Field is required if the other field is not empty
|
|
53
|
+
if (isEmptyValue.isEmptyValue(value) && !isEmptyValue.isEmptyValue(fieldValue)) {
|
|
54
|
+
return validationHelpers.invalidRule(this, context);
|
|
55
|
+
}
|
|
56
|
+
return validationHelpers.VALID_RULE;
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Required if in rule - field is required if another field's value is in the given array
|
|
61
|
+
* Supports both global and sibling scope
|
|
62
|
+
*/
|
|
63
|
+
const requiredIfInRule = {
|
|
64
|
+
name: "requiredIfIn",
|
|
65
|
+
description: "The field is required if another field's value is in the given array",
|
|
66
|
+
sortOrder: -2,
|
|
67
|
+
requiresValue: false,
|
|
68
|
+
defaultErrorMessage: "The :input is required",
|
|
69
|
+
async validate(value, context) {
|
|
70
|
+
const { values } = this.context.options;
|
|
71
|
+
const fieldValue = getFieldValue.getFieldValue(this, context);
|
|
72
|
+
// Field is required if the other field's value is in the array
|
|
73
|
+
if (isEmptyValue.isEmptyValue(value) && values.includes(fieldValue)) {
|
|
74
|
+
return validationHelpers.invalidRule(this, context);
|
|
75
|
+
}
|
|
76
|
+
return validationHelpers.VALID_RULE;
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* Required if not in rule - field is required if another field's value is NOT in the given array
|
|
81
|
+
* Supports both global and sibling scope
|
|
82
|
+
*/
|
|
83
|
+
const requiredIfNotInRule = {
|
|
84
|
+
name: "requiredIfNotIn",
|
|
85
|
+
description: "The field is required if another field's value is NOT in the given array",
|
|
86
|
+
sortOrder: -2,
|
|
87
|
+
requiresValue: false,
|
|
88
|
+
defaultErrorMessage: "The :input is required",
|
|
89
|
+
async validate(value, context) {
|
|
90
|
+
const { values } = this.context.options;
|
|
91
|
+
const fieldValue = getFieldValue.getFieldValue(this, context);
|
|
92
|
+
// Field is required if the other field's value is NOT in the array
|
|
93
|
+
if (isEmptyValue.isEmptyValue(value) && !values.includes(fieldValue)) {
|
|
94
|
+
return validationHelpers.invalidRule(this, context);
|
|
95
|
+
}
|
|
96
|
+
return validationHelpers.VALID_RULE;
|
|
97
|
+
},
|
|
98
|
+
};exports.requiredIfEmptyRule=requiredIfEmptyRule;exports.requiredIfInRule=requiredIfInRule;exports.requiredIfNotEmptyRule=requiredIfNotEmptyRule;exports.requiredIfNotInRule=requiredIfNotInRule;exports.requiredIfRule=requiredIfRule;//# sourceMappingURL=required-if-rules.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"required-if-rules.js","sources":["../../../src/rules/conditional/required-if-rules.ts"],"sourcesContent":[null],"names":["getFieldValue","isEmptyValue","invalidRule","VALID_RULE"],"mappings":"oMAIA;;;AAGG;AACU,MAAA,cAAc,GAItB;AACH,IAAA,IAAI,EAAE,YAAY;AAClB,IAAA,WAAW,EAAE,gEAAgE;IAC7E,SAAS,EAAE,CAAC,CAAC;AACb,IAAA,aAAa,EAAE,KAAK;AACpB,IAAA,mBAAmB,EAAE,wBAAwB;AAC7C,IAAA,MAAM,QAAQ,CAAC,KAAU,EAAE,OAAO,EAAA;QAChC,MAAM,EAAE,KAAK,EAAE,aAAa,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;QACtD,MAAM,UAAU,GAAGA,2BAAa,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;;QAGhD,IAAIC,yBAAY,CAAC,KAAK,CAAC,IAAI,UAAU,KAAK,aAAa,EAAE;AACvD,YAAA,OAAOC,6BAAW,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AACnC,SAAA;AAED,QAAA,OAAOC,4BAAU,CAAC;KACnB;EACD;AAEF;;;AAGG;AACU,MAAA,mBAAmB,GAG3B;AACH,IAAA,IAAI,EAAE,iBAAiB;AACvB,IAAA,WAAW,EAAE,iDAAiD;IAC9D,SAAS,EAAE,CAAC,CAAC;AACb,IAAA,aAAa,EA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U,GAAGH,2BAAa,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;;QAGhD,IAAIC,yBAAY,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE;AACtD,YAAA,OAAOC,6BAAW,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AACnC,SAAA;AAED,QAAA,OAAOC,4BAAU,CAAC;KACnB;EACD;AAEF;;;AAGG;AACU,MAAA,mBAAmB,GAI3B;AACH,IAAA,IAAI,EAAE,iBAAiB;AACvB,IAAA,WAAW,EAAE,0EAA0E;IACvF,SAAS,EAAE,CAAC,CAAC;AACb,IAAA,aAAa,EAAE,KAAK;AACpB,IAAA,mBAAmB,EAAE,wBAAwB;AAC7C,IAAA,MAAM,QAAQ,CAAC,KAAU,EAAE,OAAO,EAAA;QAChC,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;QACxC,MAAM,UAAU,GAAGH,2BAAa,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;;AAGhD,QAAA,IAAIC,yBAAY,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE;AACvD,YAAA,OAAOC,6BAAW,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AACnC,SAAA;AAED,QAAA,OAAOC,4BAAU,CAAC;KACnB;"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { SchemaRule } from "../../types";
|
|
2
|
+
/**
|
|
3
|
+
* Required unless rule - field is required unless another field equals a specific value
|
|
4
|
+
* Supports both global and sibling scope
|
|
5
|
+
*/
|
|
6
|
+
export declare const requiredUnlessRule: SchemaRule<{
|
|
7
|
+
field: string;
|
|
8
|
+
value: any;
|
|
9
|
+
scope?: "global" | "sibling";
|
|
10
|
+
}>;
|
|
11
|
+
//# sourceMappingURL=required-unless-rules.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"required-unless-rules.d.ts","sourceRoot":"","sources":["../../../src/rules/conditional/required-unless-rules.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAG9C;;;GAGG;AACH,eAAO,MAAM,kBAAkB,EAAE,UAAU,CAAC;IAC1C,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,GAAG,CAAC;IACX,KAAK,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;CAC9B,CAiBA,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use strict';var getFieldValue=require('../../helpers/get-field-value.js'),validationHelpers=require('../../helpers/validation-helpers.js'),isEmptyValue=require('../../helpers/is-empty-value.js');/**
|
|
2
|
+
* Required unless rule - field is required unless another field equals a specific value
|
|
3
|
+
* Supports both global and sibling scope
|
|
4
|
+
*/
|
|
5
|
+
const requiredUnlessRule = {
|
|
6
|
+
name: "requiredUnless",
|
|
7
|
+
description: "The field is required unless another field equals a specific value",
|
|
8
|
+
sortOrder: -2,
|
|
9
|
+
requiresValue: false,
|
|
10
|
+
defaultErrorMessage: "The :input is required",
|
|
11
|
+
async validate(value, context) {
|
|
12
|
+
const { value: expectedValue } = this.context.options;
|
|
13
|
+
const fieldValue = getFieldValue.getFieldValue(this, context);
|
|
14
|
+
// Field is required unless the other field equals the expected value
|
|
15
|
+
if (isEmptyValue.isEmptyValue(value) && fieldValue !== expectedValue) {
|
|
16
|
+
return validationHelpers.invalidRule(this, context);
|
|
17
|
+
}
|
|
18
|
+
return validationHelpers.VALID_RULE;
|
|
19
|
+
},
|
|
20
|
+
};exports.requiredUnlessRule=requiredUnlessRule;//# sourceMappingURL=required-unless-rules.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"required-unless-rules.js","sources":["../../../src/rules/conditional/required-unless-rules.ts"],"sourcesContent":[null],"names":["getFieldValue","isEmptyValue","invalidRule","VALID_RULE"],"mappings":"oMAIA;;;AAGG;AACU,MAAA,kBAAkB,GAI1B;AACH,IAAA,IAAI,EAAE,gBAAgB;AACtB,IAAA,WAAW,EAAE,oEAAoE;IACjF,SAAS,EAAE,CAAC,CAAC;AACb,IAAA,aAAa,EAAE,KAAK;AACpB,IAAA,mBAAmB,EAAE,wBAAwB;AAC7C,IAAA,MAAM,QAAQ,CAAC,KAAU,EAAE,OAAO,EAAA;QAChC,MAAM,EAAE,KAAK,EAAE,aAAa,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;QACtD,MAAM,UAAU,GAAGA,2BAAa,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;;QAGhD,IAAIC,yBAAY,CAAC,KAAK,CAAC,IAAI,UAAU,KAAK,aAAa,EAAE;AACvD,YAAA,OAAOC,6BAAW,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AACnC,SAAA;AAED,QAAA,OAAOC,4BAAU,CAAC;KACnB;"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { SchemaRule } from "../../types";
|
|
2
|
+
/**
|
|
3
|
+
* Required with rule - field is required if another field is present
|
|
4
|
+
* Supports both global and sibling scope
|
|
5
|
+
*/
|
|
6
|
+
export declare const requiredWithRule: SchemaRule<{
|
|
7
|
+
field: string;
|
|
8
|
+
scope?: "global" | "sibling";
|
|
9
|
+
}>;
|
|
10
|
+
/**
|
|
11
|
+
* Required with all rule - field is required if all specified fields are present
|
|
12
|
+
* Supports both global and sibling scope
|
|
13
|
+
*/
|
|
14
|
+
export declare const requiredWithAllRule: SchemaRule<{
|
|
15
|
+
fields: string[];
|
|
16
|
+
scope?: "global" | "sibling";
|
|
17
|
+
}>;
|
|
18
|
+
/**
|
|
19
|
+
* Required with any rule - field is required if any of the specified fields is present
|
|
20
|
+
* Supports both global and sibling scope
|
|
21
|
+
*/
|
|
22
|
+
export declare const requiredWithAnyRule: SchemaRule<{
|
|
23
|
+
fields: string[];
|
|
24
|
+
scope?: "global" | "sibling";
|
|
25
|
+
}>;
|
|
26
|
+
//# sourceMappingURL=required-with-rules.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"required-with-rules.d.ts","sourceRoot":"","sources":["../../../src/rules/conditional/required-with-rules.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C;;;GAGG;AACH,eAAO,MAAM,gBAAgB,EAAE,UAAU,CAAC;IACxC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;CAC9B,CAgBA,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,mBAAmB,EAAE,UAAU,CAAC;IAC3C,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,KAAK,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;CAC9B,CAoBA,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,mBAAmB,EAAE,UAAU,CAAC;IAC3C,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,KAAK,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;CAC9B,CAoBA,CAAC"}
|