@warlock.js/seal 5.30.0 → 5.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +46 -7
- package/README.md +57 -9
- package/cjs/index.cjs +41 -29
- package/cjs/index.cjs.map +1 -1
- package/cjs/{object--LXRt5RF.cjs → object-BoVGJ68E.cjs} +43 -24
- package/cjs/object-BoVGJ68E.cjs.map +1 -0
- package/cjs/object.cjs +2 -2
- package/cjs/{required-methods-DYsRO9aZ.cjs → required-methods-BJlnLnwa.cjs} +343 -258
- package/cjs/required-methods-BJlnLnwa.cjs.map +1 -0
- package/cjs/{string-DsqnKoSB.cjs → string-CM8x0u2w.cjs} +46 -44
- package/cjs/string-CM8x0u2w.cjs.map +1 -0
- package/cjs/string.cjs +2 -2
- package/esm/config.d.mts +7 -8
- package/esm/config.d.mts.map +1 -1
- package/esm/config.mjs.map +1 -1
- package/esm/factory/index.d.mts +2 -1
- package/esm/factory/index.mjs +1 -1
- package/esm/factory/validate.d.mts +3 -6
- package/esm/factory/validate.d.mts.map +1 -1
- package/esm/factory/validators.d.mts +16 -13
- package/esm/factory/validators.d.mts.map +1 -1
- package/esm/factory/validators.mjs +7 -1
- package/esm/factory/validators.mjs.map +1 -1
- package/esm/helpers/date-helpers.d.mts +1 -2
- package/esm/helpers/date-helpers.d.mts.map +1 -1
- package/esm/helpers/file.utils.d.mts +2 -4
- package/esm/helpers/file.utils.d.mts.map +1 -1
- package/esm/helpers/get-field-value.d.mts +2 -3
- package/esm/helpers/get-field-value.d.mts.map +1 -1
- package/esm/helpers/get-field-value.mjs +2 -1
- package/esm/helpers/get-field-value.mjs.map +1 -1
- package/esm/helpers/index.d.mts +6 -0
- package/esm/helpers/index.mjs +1 -1
- package/esm/helpers/path-helpers.d.mts +1 -2
- package/esm/helpers/path-helpers.d.mts.map +1 -1
- package/esm/helpers/validation-helpers.d.mts +4 -10
- package/esm/helpers/validation-helpers.d.mts.map +1 -1
- package/esm/index.d.mts +7 -0
- package/esm/mutators/array-mutators.d.mts +6 -7
- package/esm/mutators/array-mutators.d.mts.map +1 -1
- package/esm/mutators/boolean-mutators.d.mts +3 -4
- package/esm/mutators/boolean-mutators.d.mts.map +1 -1
- package/esm/mutators/date-mutators.d.mts +18 -19
- package/esm/mutators/date-mutators.d.mts.map +1 -1
- package/esm/mutators/index.d.mts +8 -0
- package/esm/mutators/index.mjs +1 -1
- package/esm/mutators/number-mutators.d.mts +10 -11
- package/esm/mutators/number-mutators.d.mts.map +1 -1
- package/esm/mutators/object-mutators.d.mts +4 -5
- package/esm/mutators/object-mutators.d.mts.map +1 -1
- package/esm/mutators/object-mutators.mjs +5 -4
- package/esm/mutators/object-mutators.mjs.map +1 -1
- package/esm/mutators/scalar-mutators.d.mts +2 -3
- package/esm/mutators/scalar-mutators.d.mts.map +1 -1
- package/esm/mutators/string-mutators.d.mts +37 -38
- package/esm/mutators/string-mutators.d.mts.map +1 -1
- package/esm/mutators/string-mutators.mjs +5 -3
- package/esm/mutators/string-mutators.mjs.map +1 -1
- package/esm/object.d.mts +3 -5
- package/esm/object.d.mts.map +1 -1
- package/esm/object.mjs.map +1 -1
- package/esm/plugins/plugin-system.d.mts +11 -9
- package/esm/plugins/plugin-system.d.mts.map +1 -1
- package/esm/rules/array/array-rules.d.mts +3 -4
- package/esm/rules/array/array-rules.d.mts.map +1 -1
- package/esm/rules/array/index.d.mts +2 -0
- package/esm/rules/array/index.mjs +1 -1
- package/esm/rules/color/color-rules.d.mts +8 -9
- package/esm/rules/color/color-rules.d.mts.map +1 -1
- package/esm/rules/color/index.d.mts +2 -0
- package/esm/rules/color/index.mjs +1 -1
- package/esm/rules/common/enum.d.mts +5 -6
- package/esm/rules/common/enum.d.mts.map +1 -1
- package/esm/rules/common/equals-field-rules.d.mts +3 -4
- package/esm/rules/common/equals-field-rules.d.mts.map +1 -1
- package/esm/rules/common/index.d.mts +7 -0
- package/esm/rules/common/index.mjs +1 -1
- package/esm/rules/common/instanceof.d.mts +2 -3
- package/esm/rules/common/instanceof.d.mts.map +1 -1
- package/esm/rules/common/literal.d.mts +2 -3
- package/esm/rules/common/literal.d.mts.map +1 -1
- package/esm/rules/common/literal.mjs.map +1 -1
- package/esm/rules/common/type-rules.d.mts +10 -11
- package/esm/rules/common/type-rules.d.mts.map +1 -1
- package/esm/rules/common/unknown-key.d.mts +2 -3
- package/esm/rules/common/unknown-key.d.mts.map +1 -1
- package/esm/rules/conditional/forbidden-if-rules.d.mts +7 -8
- package/esm/rules/conditional/forbidden-if-rules.d.mts.map +1 -1
- package/esm/rules/conditional/index.d.mts +11 -0
- package/esm/rules/conditional/index.mjs +1 -1
- package/esm/rules/conditional/present-if-rules.d.mts +6 -7
- package/esm/rules/conditional/present-if-rules.d.mts.map +1 -1
- package/esm/rules/conditional/present-unless-rules.d.mts +2 -3
- package/esm/rules/conditional/present-unless-rules.d.mts.map +1 -1
- package/esm/rules/conditional/present-with-rules.d.mts +4 -5
- package/esm/rules/conditional/present-with-rules.d.mts.map +1 -1
- package/esm/rules/conditional/present-without-rules.d.mts +4 -5
- package/esm/rules/conditional/present-without-rules.d.mts.map +1 -1
- package/esm/rules/conditional/required-if-rules.d.mts +10 -11
- package/esm/rules/conditional/required-if-rules.d.mts.map +1 -1
- package/esm/rules/conditional/required-unless-rules.d.mts +2 -3
- package/esm/rules/conditional/required-unless-rules.d.mts.map +1 -1
- package/esm/rules/conditional/required-when-rule.d.mts +2 -3
- package/esm/rules/conditional/required-when-rule.d.mts.map +1 -1
- package/esm/rules/conditional/required-with-rules.d.mts +4 -5
- package/esm/rules/conditional/required-with-rules.d.mts.map +1 -1
- package/esm/rules/conditional/required-without-rules.d.mts +4 -5
- package/esm/rules/conditional/required-without-rules.d.mts.map +1 -1
- package/esm/rules/core/equal.d.mts +2 -3
- package/esm/rules/core/equal.d.mts.map +1 -1
- package/esm/rules/core/forbidden.d.mts +2 -3
- package/esm/rules/core/forbidden.d.mts.map +1 -1
- package/esm/rules/core/index.d.mts +6 -0
- package/esm/rules/core/index.mjs +1 -1
- package/esm/rules/core/required.d.mts +3 -4
- package/esm/rules/core/required.d.mts.map +1 -1
- package/esm/rules/core/union.d.mts +10 -4
- package/esm/rules/core/union.d.mts.map +1 -1
- package/esm/rules/core/union.mjs +56 -10
- package/esm/rules/core/union.mjs.map +1 -1
- package/esm/rules/core/when.d.mts +2 -3
- package/esm/rules/core/when.d.mts.map +1 -1
- package/esm/rules/core/when.mjs.map +1 -1
- package/esm/rules/date/date-comparison-rules.d.mts +6 -7
- package/esm/rules/date/date-comparison-rules.d.mts.map +1 -1
- package/esm/rules/date/date-day-rules.d.mts +5 -6
- package/esm/rules/date/date-day-rules.d.mts.map +1 -1
- package/esm/rules/date/date-field-comparison-rules.d.mts +4 -5
- package/esm/rules/date/date-field-comparison-rules.d.mts.map +1 -1
- package/esm/rules/date/date-field-comparison-rules.mjs +6 -3
- package/esm/rules/date/date-field-comparison-rules.mjs.map +1 -1
- package/esm/rules/date/date-period-rules.d.mts +16 -16
- package/esm/rules/date/date-period-rules.d.mts.map +1 -1
- package/esm/rules/date/date-period-rules.mjs +24 -12
- package/esm/rules/date/date-period-rules.mjs.map +1 -1
- package/esm/rules/date/date-relative-rules.d.mts +4 -5
- package/esm/rules/date/date-relative-rules.d.mts.map +1 -1
- package/esm/rules/date/date-relative-rules.mjs +3 -3
- package/esm/rules/date/date-relative-rules.mjs.map +1 -1
- package/esm/rules/date/date-special-rules.d.mts +4 -5
- package/esm/rules/date/date-special-rules.d.mts.map +1 -1
- package/esm/rules/date/date.d.mts +16 -17
- package/esm/rules/date/date.d.mts.map +1 -1
- package/esm/rules/date/date.mjs +4 -2
- package/esm/rules/date/date.mjs.map +1 -1
- package/esm/rules/date/index.d.mts +8 -0
- package/esm/rules/date/index.mjs +1 -1
- package/esm/rules/file/dimensions.d.mts +5 -6
- package/esm/rules/file/dimensions.d.mts.map +1 -1
- package/esm/rules/file/file-size.d.mts +3 -4
- package/esm/rules/file/file-size.d.mts.map +1 -1
- package/esm/rules/file/index.d.mts +3 -0
- package/esm/rules/file/index.mjs +1 -1
- package/esm/rules/index.d.mts +56 -0
- package/esm/rules/index.mjs +1 -1
- package/esm/rules/length/index.d.mts +2 -0
- package/esm/rules/length/index.mjs +1 -1
- package/esm/rules/length/length-rules.d.mts +8 -9
- package/esm/rules/length/length-rules.d.mts.map +1 -1
- package/esm/rules/number/index.d.mts +2 -0
- package/esm/rules/number/index.mjs +1 -1
- package/esm/rules/number/number-rules.d.mts +11 -12
- package/esm/rules/number/number-rules.d.mts.map +1 -1
- package/esm/rules/number/number-rules.mjs +12 -6
- package/esm/rules/number/number-rules.mjs.map +1 -1
- package/esm/rules/scalar/index.mjs +1 -1
- package/esm/rules/string/alpha.d.mts +4 -5
- package/esm/rules/string/alpha.d.mts.map +1 -1
- package/esm/rules/string/credit-card.d.mts +2 -3
- package/esm/rules/string/credit-card.d.mts.map +1 -1
- package/esm/rules/string/email.d.mts +2 -3
- package/esm/rules/string/email.d.mts.map +1 -1
- package/esm/rules/string/id-formats.d.mts +6 -7
- package/esm/rules/string/id-formats.d.mts.map +1 -1
- package/esm/rules/string/index.d.mts +12 -0
- package/esm/rules/string/index.mjs +1 -1
- package/esm/rules/string/ip.d.mts +7 -8
- package/esm/rules/string/ip.d.mts.map +1 -1
- package/esm/rules/string/matches.d.mts +2 -3
- package/esm/rules/string/matches.d.mts.map +1 -1
- package/esm/rules/string/pattern.d.mts +2 -3
- package/esm/rules/string/pattern.d.mts.map +1 -1
- package/esm/rules/string/string-comparison.d.mts +5 -6
- package/esm/rules/string/string-comparison.d.mts.map +1 -1
- package/esm/rules/string/strong-password-rule.d.mts +2 -3
- package/esm/rules/string/strong-password-rule.d.mts.map +1 -1
- package/esm/rules/string/url.d.mts +2 -3
- package/esm/rules/string/url.d.mts.map +1 -1
- package/esm/rules/string/without-whitespace.d.mts +2 -3
- package/esm/rules/string/without-whitespace.d.mts.map +1 -1
- package/esm/standard-schema/index.d.mts +4 -0
- package/esm/standard-schema/json-schema.d.mts +5 -7
- package/esm/standard-schema/json-schema.d.mts.map +1 -1
- package/esm/standard-schema/json-schema.mjs.map +1 -1
- package/esm/standard-schema/map-result.d.mts +2 -3
- package/esm/standard-schema/map-result.d.mts.map +1 -1
- package/esm/standard-schema/map-result.mjs.map +1 -1
- package/esm/standard-schema/types.d.mts +4 -5
- package/esm/standard-schema/types.d.mts.map +1 -1
- package/esm/string.d.mts +2 -3
- package/esm/string.d.mts.map +1 -1
- package/esm/types/conditional-types.d.mts +8 -6
- package/esm/types/conditional-types.d.mts.map +1 -1
- package/esm/types/context-types.d.mts +24 -15
- package/esm/types/context-types.d.mts.map +1 -1
- package/esm/types/data-transformer-types.d.mts +3 -5
- package/esm/types/data-transformer-types.d.mts.map +1 -1
- package/esm/types/date-types.d.mts +2 -3
- package/esm/types/date-types.d.mts.map +1 -1
- package/esm/types/file.types.d.mts +1 -2
- package/esm/types/file.types.d.mts.map +1 -1
- package/esm/types/index.d.mts +11 -0
- package/esm/types/inference-types.d.mts +15 -14
- package/esm/types/inference-types.d.mts.map +1 -1
- package/esm/types/mutator-types.d.mts +9 -7
- package/esm/types/mutator-types.d.mts.map +1 -1
- package/esm/types/result-types.d.mts +12 -7
- package/esm/types/result-types.d.mts.map +1 -1
- package/esm/types/rule-types.d.mts +33 -15
- package/esm/types/rule-types.d.mts.map +1 -1
- package/esm/types/schema-types.d.mts +1 -3
- package/esm/types/schema-types.d.mts.map +1 -1
- package/esm/validators/any-validator.d.mts +1 -3
- package/esm/validators/any-validator.d.mts.map +1 -1
- package/esm/validators/array-validator.d.mts +2 -3
- package/esm/validators/array-validator.d.mts.map +1 -1
- package/esm/validators/array-validator.mjs +3 -3
- package/esm/validators/array-validator.mjs.map +1 -1
- package/esm/validators/base-validator.d.mts +10 -11
- package/esm/validators/base-validator.d.mts.map +1 -1
- package/esm/validators/base-validator.mjs +52 -21
- package/esm/validators/base-validator.mjs.map +1 -1
- package/esm/validators/boolean-validator.d.mts +1 -3
- package/esm/validators/boolean-validator.d.mts.map +1 -1
- package/esm/validators/computed-validator.d.mts +3 -4
- package/esm/validators/computed-validator.d.mts.map +1 -1
- package/esm/validators/computed-validator.mjs +4 -4
- package/esm/validators/computed-validator.mjs.map +1 -1
- package/esm/validators/date-validator.d.mts +2 -3
- package/esm/validators/date-validator.d.mts.map +1 -1
- package/esm/validators/discriminated-union-validator.d.mts +3 -3
- package/esm/validators/discriminated-union-validator.d.mts.map +1 -1
- package/esm/validators/discriminated-union-validator.mjs +1 -1
- package/esm/validators/discriminated-union-validator.mjs.map +1 -1
- package/esm/validators/float-validator.d.mts +1 -3
- package/esm/validators/float-validator.d.mts.map +1 -1
- package/esm/validators/index.d.mts +2 -1
- package/esm/validators/index.mjs +1 -1
- package/esm/validators/instanceof-validator.d.mts +1 -3
- package/esm/validators/instanceof-validator.d.mts.map +1 -1
- package/esm/validators/int-validator.d.mts +1 -3
- package/esm/validators/int-validator.d.mts.map +1 -1
- package/esm/validators/lazy-validator.d.mts +2 -3
- package/esm/validators/lazy-validator.d.mts.map +1 -1
- package/esm/validators/lazy-validator.mjs +1 -1
- package/esm/validators/lazy-validator.mjs.map +1 -1
- package/esm/validators/literal-validator.d.mts +1 -3
- package/esm/validators/literal-validator.d.mts.map +1 -1
- package/esm/validators/managed-validator.d.mts +3 -4
- package/esm/validators/managed-validator.d.mts.map +1 -1
- package/esm/validators/methods/equality-conditional-methods.d.mts +3 -4
- package/esm/validators/methods/equality-conditional-methods.d.mts.map +1 -1
- package/esm/validators/methods/forbidden-methods.d.mts +2 -3
- package/esm/validators/methods/forbidden-methods.d.mts.map +1 -1
- package/esm/validators/methods/present-methods.d.mts +2 -3
- package/esm/validators/methods/present-methods.d.mts.map +1 -1
- package/esm/validators/methods/required-methods.d.mts +3 -4
- package/esm/validators/methods/required-methods.d.mts.map +1 -1
- package/esm/validators/number-validator.d.mts +1 -3
- package/esm/validators/number-validator.d.mts.map +1 -1
- package/esm/validators/number-validator.mjs +12 -8
- package/esm/validators/number-validator.mjs.map +1 -1
- package/esm/validators/numeric-validator.d.mts +1 -3
- package/esm/validators/numeric-validator.d.mts.map +1 -1
- package/esm/validators/object-validator.d.mts +2 -3
- package/esm/validators/object-validator.d.mts.map +1 -1
- package/esm/validators/object-validator.mjs +9 -7
- package/esm/validators/object-validator.mjs.map +1 -1
- package/esm/validators/primitive-validator.d.mts +1 -3
- package/esm/validators/primitive-validator.d.mts.map +1 -1
- package/esm/validators/record-validator.d.mts +2 -3
- package/esm/validators/record-validator.d.mts.map +1 -1
- package/esm/validators/record-validator.mjs +3 -3
- package/esm/validators/record-validator.mjs.map +1 -1
- package/esm/validators/scalar-validator.d.mts +1 -3
- package/esm/validators/scalar-validator.d.mts.map +1 -1
- package/esm/validators/scalar-validator.mjs.map +1 -1
- package/esm/validators/string-validator.d.mts +1 -3
- package/esm/validators/string-validator.d.mts.map +1 -1
- package/esm/validators/tuple-validator.d.mts +2 -3
- package/esm/validators/tuple-validator.d.mts.map +1 -1
- package/esm/validators/tuple-validator.mjs +3 -3
- package/esm/validators/tuple-validator.mjs.map +1 -1
- package/esm/validators/union-validator.d.mts +4 -4
- package/esm/validators/union-validator.d.mts.map +1 -1
- package/esm/validators/union-validator.mjs +3 -1
- package/esm/validators/union-validator.mjs.map +1 -1
- package/llms-full.txt +656 -527
- package/llms.txt +1 -1
- package/package.json +1 -1
- package/skills/bridge-standard-schema/SKILL.md +60 -36
- package/skills/compose-seal-modifiers/SKILL.md +89 -53
- package/skills/define-structural-shape/SKILL.md +41 -27
- package/skills/define-structural-shape/array-methods.md +27 -27
- package/skills/define-structural-shape/object-methods.md +38 -30
- package/skills/extend-seal-with-plugins/SKILL.md +39 -5
- package/skills/generate-json-schema/SKILL.md +13 -13
- package/skills/handle-seal-errors/SKILL.md +23 -23
- package/skills/index.md +4 -1
- package/skills/overview/SKILL.md +10 -2
- package/skills/pick-seal-primitive/SKILL.md +45 -45
- package/skills/pick-seal-primitive/date-methods.md +96 -96
- package/skills/pick-seal-primitive/number-methods.md +55 -55
- package/skills/pick-seal-primitive/string-methods.md +107 -102
- package/skills/seal-basics/SKILL.md +14 -14
- package/cjs/object--LXRt5RF.cjs.map +0 -1
- package/cjs/required-methods-DYsRO9aZ.cjs.map +0 -1
- package/cjs/string-DsqnKoSB.cjs.map +0 -1
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { equalRule } from "./core/equal.mjs";
|
|
2
|
+
import { forbiddenRule } from "./core/forbidden.mjs";
|
|
3
|
+
import { presentRule, requiredRule } from "./core/required.mjs";
|
|
4
|
+
import { unionRule } from "./core/union.mjs";
|
|
5
|
+
import { whenRule } from "./core/when.mjs";
|
|
6
|
+
import "./core/index.mjs";
|
|
7
|
+
import { alphaNumericRule, alphaRule, isNumericRule } from "./string/alpha.mjs";
|
|
8
|
+
import { isCreditCardRule } from "./string/credit-card.mjs";
|
|
9
|
+
import { emailRule } from "./string/email.mjs";
|
|
10
|
+
import { UUIDVersion, cuidRule, nanoidRule, ulidRule, uuidRule } from "./string/id-formats.mjs";
|
|
11
|
+
import { ip4Rule, ip6Rule, ipRule, isIP, isIPv4, isIPv6 } from "./string/ip.mjs";
|
|
12
|
+
import { matchesRule } from "./string/matches.mjs";
|
|
13
|
+
import { patternRule } from "./string/pattern.mjs";
|
|
14
|
+
import { containsRule, endsWithRule, notContainsRule, startsWithRule } from "./string/string-comparison.mjs";
|
|
15
|
+
import { strongPasswordRule } from "./string/strong-password-rule.mjs";
|
|
16
|
+
import { urlRule } from "./string/url.mjs";
|
|
17
|
+
import { withoutWhitespaceRule } from "./string/without-whitespace.mjs";
|
|
18
|
+
import "./string/index.mjs";
|
|
19
|
+
import { betweenNumbersRule, evenRule, greaterThanRule, lessThanRule, maxRule, minRule, moduloRule, negativeRule, oddRule, positiveRule } from "./number/number-rules.mjs";
|
|
20
|
+
import "./number/index.mjs";
|
|
21
|
+
import { betweenLengthRule, lengthRule, maxLengthRule, maxWordsRule, minLengthRule, minWordsRule, wordsRule } from "./length/length-rules.mjs";
|
|
22
|
+
import "./length/index.mjs";
|
|
23
|
+
import { sortedArrayRule, uniqueArrayRule } from "./array/array-rules.mjs";
|
|
24
|
+
import "./array/index.mjs";
|
|
25
|
+
import { ageRule, beforeHourRule, beforeMinuteRule, beforeTodayRule, betweenHoursRule, betweenMinutesRule, dateRule, fromHourRule, fromMinuteRule, fromTodayRule, maxAgeRule, maxDateRule, minAgeRule, minDateRule, weekDayRule } from "./date/date.mjs";
|
|
26
|
+
import { afterTodayRule, betweenDatesRule, futureRule, pastRule, todayRule } from "./date/date-comparison-rules.mjs";
|
|
27
|
+
import { businessDayRule, weekdayRule, weekdaysRule, weekendRule } from "./date/date-day-rules.mjs";
|
|
28
|
+
import { afterFieldRule, beforeFieldRule, sameAsFieldDateRule } from "./date/date-field-comparison-rules.mjs";
|
|
29
|
+
import { Month, betweenDaysRule, betweenMonthsRule, betweenTimesRule, betweenYearsRule, maxDayRule, maxMonthRule, maxYearRule, minDayRule, minMonthRule, minYearRule, monthRule, quarterRule, yearRule } from "./date/date-period-rules.mjs";
|
|
30
|
+
import { withinDaysRule, withinFutureDaysRule, withinPastDaysRule } from "./date/date-relative-rules.mjs";
|
|
31
|
+
import { betweenAgeRule, birthdayRule, leapYearRule } from "./date/date-special-rules.mjs";
|
|
32
|
+
import "./date/index.mjs";
|
|
33
|
+
import { maxHeightRule, maxWidthRule, minHeightRule, minWidthRule } from "./file/dimensions.mjs";
|
|
34
|
+
import { maxFileSizeRule, minFileSizeRule } from "./file/file-size.mjs";
|
|
35
|
+
import "./file/index.mjs";
|
|
36
|
+
import { colorRule, darkColorRule, hexColorRule, hslColorRule, lightColorRule, rgbColorRule, rgbaColorRule } from "./color/color-rules.mjs";
|
|
37
|
+
import "./color/index.mjs";
|
|
38
|
+
import { requiredIfAllEmptyRule, requiredIfAllNotEmptyRule, requiredIfAnyEmptyRule, requiredIfAnyNotEmptyRule, requiredIfEmptyRule, requiredIfInRule, requiredIfNotEmptyRule, requiredIfNotInRule, requiredIfRule } from "./conditional/required-if-rules.mjs";
|
|
39
|
+
import { requiredUnlessRule } from "./conditional/required-unless-rules.mjs";
|
|
40
|
+
import { requiredWhenRule } from "./conditional/required-when-rule.mjs";
|
|
41
|
+
import { requiredWithAllRule, requiredWithAnyRule, requiredWithRule } from "./conditional/required-with-rules.mjs";
|
|
42
|
+
import { requiredWithoutAllRule, requiredWithoutAnyRule, requiredWithoutRule } from "./conditional/required-without-rules.mjs";
|
|
43
|
+
import { presentIfEmptyRule, presentIfInRule, presentIfNotEmptyRule, presentIfNotInRule, presentIfRule } from "./conditional/present-if-rules.mjs";
|
|
44
|
+
import { presentUnlessRule } from "./conditional/present-unless-rules.mjs";
|
|
45
|
+
import { presentWithAllRule, presentWithAnyRule, presentWithRule } from "./conditional/present-with-rules.mjs";
|
|
46
|
+
import { presentWithoutAllRule, presentWithoutAnyRule, presentWithoutRule } from "./conditional/present-without-rules.mjs";
|
|
47
|
+
import { forbiddenIfEmptyRule, forbiddenIfInRule, forbiddenIfNotEmptyRule, forbiddenIfNotInRule, forbiddenIfNotRule, forbiddenIfRule } from "./conditional/forbidden-if-rules.mjs";
|
|
48
|
+
import "./conditional/index.mjs";
|
|
49
|
+
import { allowedValuesRule, enumRule, inRule, notAllowedValuesRule } from "./common/enum.mjs";
|
|
50
|
+
import { equalsFieldRule, notEqualsFieldRule } from "./common/equals-field-rules.mjs";
|
|
51
|
+
import { instanceofRule } from "./common/instanceof.mjs";
|
|
52
|
+
import { literalRule } from "./common/literal.mjs";
|
|
53
|
+
import { arrayRule, booleanRule, floatRule, intRule, numberRule, objectRule, plainObjectRule, scalarRule, stringRule } from "./common/type-rules.mjs";
|
|
54
|
+
import { unknownKeyRule } from "./common/unknown-key.mjs";
|
|
55
|
+
import "./common/index.mjs";
|
|
56
|
+
export { Month, UUIDVersion, afterFieldRule, afterTodayRule, ageRule, allowedValuesRule, alphaNumericRule, alphaRule, arrayRule, beforeFieldRule, beforeHourRule, beforeMinuteRule, beforeTodayRule, betweenAgeRule, betweenDatesRule, betweenDaysRule, betweenHoursRule, betweenLengthRule, betweenMinutesRule, betweenMonthsRule, betweenNumbersRule, betweenTimesRule, betweenYearsRule, birthdayRule, booleanRule, businessDayRule, colorRule, containsRule, cuidRule, darkColorRule, dateRule, emailRule, endsWithRule, enumRule, equalRule, equalsFieldRule, evenRule, floatRule, forbiddenIfEmptyRule, forbiddenIfInRule, forbiddenIfNotEmptyRule, forbiddenIfNotInRule, forbiddenIfNotRule, forbiddenIfRule, forbiddenRule, fromHourRule, fromMinuteRule, fromTodayRule, futureRule, greaterThanRule, hexColorRule, hslColorRule, inRule, instanceofRule, intRule, ip4Rule, ip6Rule, ipRule, isCreditCardRule, isIP, isIPv4, isIPv6, isNumericRule, leapYearRule, lengthRule, lessThanRule, lightColorRule, literalRule, matchesRule, maxAgeRule, maxDateRule, maxDayRule, maxFileSizeRule, maxHeightRule, maxLengthRule, maxMonthRule, maxRule, maxWidthRule, maxWordsRule, maxYearRule, minAgeRule, minDateRule, minDayRule, minFileSizeRule, minHeightRule, minLengthRule, minMonthRule, minRule, minWidthRule, minWordsRule, minYearRule, moduloRule, monthRule, nanoidRule, negativeRule, notAllowedValuesRule, notContainsRule, notEqualsFieldRule, numberRule, objectRule, oddRule, pastRule, patternRule, plainObjectRule, positiveRule, presentIfEmptyRule, presentIfInRule, presentIfNotEmptyRule, presentIfNotInRule, presentIfRule, presentRule, presentUnlessRule, presentWithAllRule, presentWithAnyRule, presentWithRule, presentWithoutAllRule, presentWithoutAnyRule, presentWithoutRule, quarterRule, requiredIfAllEmptyRule, requiredIfAllNotEmptyRule, requiredIfAnyEmptyRule, requiredIfAnyNotEmptyRule, requiredIfEmptyRule, requiredIfInRule, requiredIfNotEmptyRule, requiredIfNotInRule, requiredIfRule, requiredRule, requiredUnlessRule, requiredWhenRule, requiredWithAllRule, requiredWithAnyRule, requiredWithRule, requiredWithoutAllRule, requiredWithoutAnyRule, requiredWithoutRule, rgbColorRule, rgbaColorRule, sameAsFieldDateRule, scalarRule, sortedArrayRule, startsWithRule, stringRule, strongPasswordRule, todayRule, ulidRule, unionRule, uniqueArrayRule, unknownKeyRule, urlRule, uuidRule, weekDayRule, weekdayRule, weekdaysRule, weekendRule, whenRule, withinDaysRule, withinFutureDaysRule, withinPastDaysRule, withoutWhitespaceRule, wordsRule, yearRule };
|
package/esm/rules/index.mjs
CHANGED
|
@@ -54,4 +54,4 @@ import { arrayRule, booleanRule, floatRule, intRule, numberRule, objectRule, pla
|
|
|
54
54
|
import { unknownKeyRule } from "./common/unknown-key.mjs";
|
|
55
55
|
import "./common/index.mjs";
|
|
56
56
|
|
|
57
|
-
export {
|
|
57
|
+
export { afterFieldRule, afterTodayRule, ageRule, allowedValuesRule, alphaNumericRule, alphaRule, arrayRule, beforeFieldRule, beforeHourRule, beforeMinuteRule, beforeTodayRule, betweenAgeRule, betweenDatesRule, betweenDaysRule, betweenHoursRule, betweenLengthRule, betweenMinutesRule, betweenMonthsRule, betweenNumbersRule, betweenTimesRule, betweenYearsRule, birthdayRule, booleanRule, businessDayRule, colorRule, containsRule, cuidRule, darkColorRule, dateRule, emailRule, endsWithRule, enumRule, equalRule, equalsFieldRule, evenRule, floatRule, forbiddenIfEmptyRule, forbiddenIfInRule, forbiddenIfNotEmptyRule, forbiddenIfNotInRule, forbiddenIfNotRule, forbiddenIfRule, forbiddenRule, fromHourRule, fromMinuteRule, fromTodayRule, futureRule, greaterThanRule, hexColorRule, hslColorRule, inRule, instanceofRule, intRule, ip4Rule, ip6Rule, ipRule, isCreditCardRule, isIP, isIPv4, isIPv6, isNumericRule, leapYearRule, lengthRule, lessThanRule, lightColorRule, literalRule, matchesRule, maxAgeRule, maxDateRule, maxDayRule, maxFileSizeRule, maxHeightRule, maxLengthRule, maxMonthRule, maxRule, maxWidthRule, maxWordsRule, maxYearRule, minAgeRule, minDateRule, minDayRule, minFileSizeRule, minHeightRule, minLengthRule, minMonthRule, minRule, minWidthRule, minWordsRule, minYearRule, moduloRule, monthRule, nanoidRule, negativeRule, notAllowedValuesRule, notContainsRule, notEqualsFieldRule, numberRule, objectRule, oddRule, pastRule, patternRule, plainObjectRule, positiveRule, presentIfEmptyRule, presentIfInRule, presentIfNotEmptyRule, presentIfNotInRule, presentIfRule, presentRule, presentUnlessRule, presentWithAllRule, presentWithAnyRule, presentWithRule, presentWithoutAllRule, presentWithoutAnyRule, presentWithoutRule, quarterRule, requiredIfAllEmptyRule, requiredIfAllNotEmptyRule, requiredIfAnyEmptyRule, requiredIfAnyNotEmptyRule, requiredIfEmptyRule, requiredIfInRule, requiredIfNotEmptyRule, requiredIfNotInRule, requiredIfRule, requiredRule, requiredUnlessRule, requiredWhenRule, requiredWithAllRule, requiredWithAnyRule, requiredWithRule, requiredWithoutAllRule, requiredWithoutAnyRule, requiredWithoutRule, rgbColorRule, rgbaColorRule, sameAsFieldDateRule, scalarRule, sortedArrayRule, startsWithRule, stringRule, strongPasswordRule, todayRule, ulidRule, unionRule, uniqueArrayRule, unknownKeyRule, urlRule, uuidRule, weekDayRule, weekdayRule, weekdaysRule, weekendRule, whenRule, withinDaysRule, withinFutureDaysRule, withinPastDaysRule, withoutWhitespaceRule, wordsRule, yearRule };
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
import { SchemaRule } from "../../types/rule-types.mjs";
|
|
2
|
-
|
|
2
|
+
import "../../types/index.mjs";
|
|
3
3
|
//#region ../../packages/seal/src/rules/length/length-rules.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* Min length rule - validates minimum length
|
|
6
6
|
* Works for any value with a length property (strings, arrays, etc.)
|
|
7
7
|
*/
|
|
8
|
-
declare const minLengthRule: SchemaRule<{
|
|
8
|
+
export declare const minLengthRule: SchemaRule<{
|
|
9
9
|
minLength: number;
|
|
10
10
|
}>;
|
|
11
11
|
/**
|
|
12
12
|
* Max length rule - validates maximum length
|
|
13
13
|
* Works for any value with a length property (strings, arrays, etc.)
|
|
14
14
|
*/
|
|
15
|
-
declare const maxLengthRule: SchemaRule<{
|
|
15
|
+
export declare const maxLengthRule: SchemaRule<{
|
|
16
16
|
maxLength: number;
|
|
17
17
|
}>;
|
|
18
18
|
/**
|
|
19
19
|
* Between length rule - validates length is between min and max (inclusive)
|
|
20
20
|
* Works for any value with a length property (strings, arrays, etc.)
|
|
21
21
|
*/
|
|
22
|
-
declare const betweenLengthRule: SchemaRule<{
|
|
22
|
+
export declare const betweenLengthRule: SchemaRule<{
|
|
23
23
|
minLength: number;
|
|
24
24
|
maxLength: number;
|
|
25
25
|
}>;
|
|
@@ -27,27 +27,26 @@ declare const betweenLengthRule: SchemaRule<{
|
|
|
27
27
|
* Length rule - validates exact length
|
|
28
28
|
* Works for any value with a length property (strings, arrays, etc.)
|
|
29
29
|
*/
|
|
30
|
-
declare const lengthRule: SchemaRule<{
|
|
30
|
+
export declare const lengthRule: SchemaRule<{
|
|
31
31
|
length: number;
|
|
32
32
|
}>;
|
|
33
33
|
/**
|
|
34
34
|
* Min words rule - validates minimum word count
|
|
35
35
|
*/
|
|
36
|
-
declare const minWordsRule: SchemaRule<{
|
|
36
|
+
export declare const minWordsRule: SchemaRule<{
|
|
37
37
|
minWords: number;
|
|
38
38
|
}>;
|
|
39
39
|
/**
|
|
40
40
|
* Max words rule - validates maximum word count
|
|
41
41
|
*/
|
|
42
|
-
declare const maxWordsRule: SchemaRule<{
|
|
42
|
+
export declare const maxWordsRule: SchemaRule<{
|
|
43
43
|
maxWords: number;
|
|
44
44
|
}>;
|
|
45
45
|
/**
|
|
46
46
|
* Words rule - validates exact word count
|
|
47
47
|
*/
|
|
48
|
-
declare const wordsRule: SchemaRule<{
|
|
48
|
+
export declare const wordsRule: SchemaRule<{
|
|
49
49
|
words: number;
|
|
50
50
|
}>;
|
|
51
51
|
//#endregion
|
|
52
|
-
export { betweenLengthRule, lengthRule, maxLengthRule, maxWordsRule, minLengthRule, minWordsRule, wordsRule };
|
|
53
52
|
//# sourceMappingURL=length-rules.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"length-rules.d.mts","names":[],"sources":["../../../../../../../../../packages/seal/src/rules/length/length-rules.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"length-rules.d.mts","names":[],"sources":["../../../../../../../../../packages/seal/src/rules/length/length-rules.ts"],"mappings":";;;;;;;qBAOa,eAAe;EAAa;;;;;;qBAoB5B,eAAe;EAAa;;;;;;qBAoB5B,mBAAmB;EAC9B;EACA;;;;;;qBAsBW,YAAY;EAAa;;;;;qBAmBzB,cAAc;EAAa;;;;;qBAiB3B,cAAc;EAAa;;;;;qBAiB3B,WAAW;EAAa"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { betweenNumbersRule, evenRule, greaterThanRule, lessThanRule, maxRule, minRule, moduloRule, negativeRule, oddRule, positiveRule } from "./number-rules.mjs";
|
|
2
|
+
export { betweenNumbersRule, evenRule, greaterThanRule, lessThanRule, maxRule, minRule, moduloRule, negativeRule, oddRule, positiveRule };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { betweenNumbersRule, evenRule, greaterThanRule, lessThanRule, maxRule, minRule, moduloRule, negativeRule, oddRule, positiveRule } from "./number-rules.mjs";
|
|
2
2
|
|
|
3
|
-
export {
|
|
3
|
+
export { betweenNumbersRule, evenRule, greaterThanRule, lessThanRule, maxRule, minRule, moduloRule, negativeRule, oddRule, positiveRule };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { SchemaRule } from "../../types/rule-types.mjs";
|
|
2
|
-
|
|
2
|
+
import "../../types/index.mjs";
|
|
3
3
|
//#region ../../packages/seal/src/rules/number/number-rules.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* Min rule - value must be equal or greater than minimum
|
|
6
6
|
* Supports field names with sibling scope
|
|
7
7
|
*/
|
|
8
|
-
declare const minRule: SchemaRule<{
|
|
8
|
+
export declare const minRule: SchemaRule<{
|
|
9
9
|
min: number | string;
|
|
10
10
|
scope?: "global" | "sibling";
|
|
11
11
|
}>;
|
|
@@ -13,7 +13,7 @@ declare const minRule: SchemaRule<{
|
|
|
13
13
|
* Max rule - value must be equal or less than maximum
|
|
14
14
|
* Supports field names with sibling scope
|
|
15
15
|
*/
|
|
16
|
-
declare const maxRule: SchemaRule<{
|
|
16
|
+
export declare const maxRule: SchemaRule<{
|
|
17
17
|
max: number | string;
|
|
18
18
|
scope?: "global" | "sibling";
|
|
19
19
|
}>;
|
|
@@ -21,7 +21,7 @@ declare const maxRule: SchemaRule<{
|
|
|
21
21
|
* Greater than rule - value must be strictly greater than minimum
|
|
22
22
|
* Supports field names with sibling scope
|
|
23
23
|
*/
|
|
24
|
-
declare const greaterThanRule: SchemaRule<{
|
|
24
|
+
export declare const greaterThanRule: SchemaRule<{
|
|
25
25
|
value: number | string;
|
|
26
26
|
scope?: "global" | "sibling";
|
|
27
27
|
}>;
|
|
@@ -29,41 +29,40 @@ declare const greaterThanRule: SchemaRule<{
|
|
|
29
29
|
* Less than rule - value must be strictly less than maximum
|
|
30
30
|
* Supports field names with sibling scope
|
|
31
31
|
*/
|
|
32
|
-
declare const lessThanRule: SchemaRule<{
|
|
32
|
+
export declare const lessThanRule: SchemaRule<{
|
|
33
33
|
value: number | string;
|
|
34
34
|
scope?: "global" | "sibling";
|
|
35
35
|
}>;
|
|
36
36
|
/**
|
|
37
37
|
* Positive rule - value must be greater than 0
|
|
38
38
|
*/
|
|
39
|
-
declare const positiveRule: SchemaRule;
|
|
39
|
+
export declare const positiveRule: SchemaRule;
|
|
40
40
|
/**
|
|
41
41
|
* Negative rule - value must be less than 0
|
|
42
42
|
*/
|
|
43
|
-
declare const negativeRule: SchemaRule;
|
|
43
|
+
export declare const negativeRule: SchemaRule;
|
|
44
44
|
/**
|
|
45
45
|
* Odd rule - value must be an odd number
|
|
46
46
|
*/
|
|
47
|
-
declare const oddRule: SchemaRule;
|
|
47
|
+
export declare const oddRule: SchemaRule;
|
|
48
48
|
/**
|
|
49
49
|
* Even rule - value must be an even number
|
|
50
50
|
*/
|
|
51
|
-
declare const evenRule: SchemaRule;
|
|
51
|
+
export declare const evenRule: SchemaRule;
|
|
52
52
|
/**
|
|
53
53
|
* Modulo rule - value must be divisible by given number
|
|
54
54
|
*/
|
|
55
|
-
declare const moduloRule: SchemaRule<{
|
|
55
|
+
export declare const moduloRule: SchemaRule<{
|
|
56
56
|
value: number;
|
|
57
57
|
}>;
|
|
58
58
|
/**
|
|
59
59
|
* Between rule - value must be between the given two numbers (Inclusive)
|
|
60
60
|
* Supports field names with sibling scope
|
|
61
61
|
*/
|
|
62
|
-
declare const betweenNumbersRule: SchemaRule<{
|
|
62
|
+
export declare const betweenNumbersRule: SchemaRule<{
|
|
63
63
|
min: number | string;
|
|
64
64
|
max: number | string;
|
|
65
65
|
scope?: "global" | "sibling";
|
|
66
66
|
}>;
|
|
67
67
|
//#endregion
|
|
68
|
-
export { betweenNumbersRule, evenRule, greaterThanRule, lessThanRule, maxRule, minRule, moduloRule, negativeRule, oddRule, positiveRule };
|
|
69
68
|
//# sourceMappingURL=number-rules.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"number-rules.d.mts","names":[],"sources":["../../../../../../../../../packages/seal/src/rules/number/number-rules.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"number-rules.d.mts","names":[],"sources":["../../../../../../../../../packages/seal/src/rules/number/number-rules.ts"],"mappings":";;;;;;;qBAQa,SAAS;EACpB;EACA;;;;;;qBAwCW,SAAS;EACpB;EACA;;;;;;qBAwCW,iBAAiB;EAC5B;EACA;;;;;;qBAwCW,cAAc;EACzB;EACA;;;;;qBAuCW,cAAc;;;;qBAed,cAAc;;;;qBAed,SAAS;;;;qBAeT,UAAU;;;;qBAeV,YAAY;EAAa;;;;;;qBAkBzB,oBAAoB;EAC/B;EACA;EACA"}
|
|
@@ -17,7 +17,8 @@ const minRule = {
|
|
|
17
17
|
compareMin = min;
|
|
18
18
|
this.context.translationParams.min = min;
|
|
19
19
|
} else {
|
|
20
|
-
const
|
|
20
|
+
const source = scope === "sibling" ? context.parent : context.allValues;
|
|
21
|
+
const fieldValue = get(source, min);
|
|
21
22
|
if (fieldValue === void 0) return VALID_RULE;
|
|
22
23
|
this.context.translatableParams.min = min;
|
|
23
24
|
compareMin = Number(fieldValue);
|
|
@@ -41,7 +42,8 @@ const maxRule = {
|
|
|
41
42
|
compareMax = max;
|
|
42
43
|
this.context.translationParams.max = max;
|
|
43
44
|
} else {
|
|
44
|
-
const
|
|
45
|
+
const source = scope === "sibling" ? context.parent : context.allValues;
|
|
46
|
+
const fieldValue = get(source, max);
|
|
45
47
|
if (fieldValue === void 0) return VALID_RULE;
|
|
46
48
|
this.context.translatableParams.max = max;
|
|
47
49
|
compareMax = Number(fieldValue);
|
|
@@ -65,7 +67,8 @@ const greaterThanRule = {
|
|
|
65
67
|
compareNumber = compareValue;
|
|
66
68
|
this.context.translationParams.value = compareValue;
|
|
67
69
|
} else {
|
|
68
|
-
const
|
|
70
|
+
const source = scope === "sibling" ? context.parent : context.allValues;
|
|
71
|
+
const fieldValue = get(source, compareValue);
|
|
69
72
|
if (fieldValue === void 0) return VALID_RULE;
|
|
70
73
|
this.context.translatableParams.value = compareValue;
|
|
71
74
|
compareNumber = Number(fieldValue);
|
|
@@ -89,7 +92,8 @@ const lessThanRule = {
|
|
|
89
92
|
compareNumber = compareValue;
|
|
90
93
|
this.context.translationParams.value = compareValue;
|
|
91
94
|
} else {
|
|
92
|
-
const
|
|
95
|
+
const source = scope === "sibling" ? context.parent : context.allValues;
|
|
96
|
+
const fieldValue = get(source, compareValue);
|
|
93
97
|
if (fieldValue === void 0) return VALID_RULE;
|
|
94
98
|
this.context.translatableParams.value = compareValue;
|
|
95
99
|
compareNumber = Number(fieldValue);
|
|
@@ -169,7 +173,8 @@ const betweenNumbersRule = {
|
|
|
169
173
|
compareMin = min;
|
|
170
174
|
this.context.translationParams.min = min;
|
|
171
175
|
} else {
|
|
172
|
-
const
|
|
176
|
+
const source = scope === "sibling" ? context.parent : context.allValues;
|
|
177
|
+
const fieldValue = get(source, min);
|
|
173
178
|
if (fieldValue === void 0) return VALID_RULE;
|
|
174
179
|
this.context.translatableParams.min = min;
|
|
175
180
|
compareMin = Number(fieldValue);
|
|
@@ -180,7 +185,8 @@ const betweenNumbersRule = {
|
|
|
180
185
|
compareMax = max;
|
|
181
186
|
this.context.translationParams.max = max;
|
|
182
187
|
} else {
|
|
183
|
-
const
|
|
188
|
+
const source = scope === "sibling" ? context.parent : context.allValues;
|
|
189
|
+
const fieldValue = get(source, max);
|
|
184
190
|
if (fieldValue === void 0) return VALID_RULE;
|
|
185
191
|
this.context.translatableParams.max = max;
|
|
186
192
|
compareMax = Number(fieldValue);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"number-rules.mjs","names":[],"sources":["../../../../../../../../../packages/seal/src/rules/number/number-rules.ts"],"sourcesContent":["import { get } from \"@mongez/reinforcements\";\nimport { invalidRule, VALID_RULE } from \"../../helpers\";\nimport type { SchemaRule } from \"../../types\";\n\n/**\n * Min rule - value must be equal or greater than minimum\n * Supports field names with sibling scope\n */\nexport const minRule: SchemaRule<{\n min: number | string;\n scope?: \"global\" | \"sibling\";\n}> = {\n name: \"min\",\n defaultErrorMessage: \"The :input must be at least :min\",\n async validate(value: any, context) {\n const { min, scope = \"global\" } = this.context.options;\n let compareMin: number;\n\n if (typeof min === \"number\") {\n compareMin = min;\n this.context.translationParams.min = min;\n } else {\n const source = scope === \"sibling\" ? context.parent : context.allValues;\n const fieldValue = get(source, min);\n\n if (fieldValue === undefined) {\n return VALID_RULE;\n }\n\n this.context.translatableParams.min = min;\n\n compareMin = Number(fieldValue);\n\n if (isNaN(compareMin)) {\n return VALID_RULE;\n }\n }\n\n if (value >= compareMin) {\n return VALID_RULE;\n }\n\n return invalidRule(this, context);\n },\n};\n\n/**\n * Max rule - value must be equal or less than maximum\n * Supports field names with sibling scope\n */\nexport const maxRule: SchemaRule<{\n max: number | string;\n scope?: \"global\" | \"sibling\";\n}> = {\n name: \"max\",\n defaultErrorMessage: \"The :input must equal to or less than :max\",\n async validate(value: any, context) {\n const { max, scope = \"global\" } = this.context.options;\n let compareMax: number;\n\n if (typeof max === \"number\") {\n compareMax = max;\n this.context.translationParams.max = max;\n } else {\n const source = scope === \"sibling\" ? context.parent : context.allValues;\n const fieldValue = get(source, max);\n\n if (fieldValue === undefined) {\n return VALID_RULE;\n }\n\n this.context.translatableParams.max = max;\n\n compareMax = Number(fieldValue);\n\n if (isNaN(compareMax)) {\n return VALID_RULE;\n }\n }\n\n if (value <= compareMax) {\n return VALID_RULE;\n }\n\n return invalidRule(this, context);\n },\n};\n\n/**\n * Greater than rule - value must be strictly greater than minimum\n * Supports field names with sibling scope\n */\nexport const greaterThanRule: SchemaRule<{\n value: number | string;\n scope?: \"global\" | \"sibling\";\n}> = {\n name: \"greaterThan\",\n defaultErrorMessage: \"The :input must be greater than :value\",\n async validate(value: any, context) {\n const { value: compareValue, scope = \"global\" } = this.context.options;\n let compareNumber: number;\n\n if (typeof compareValue === \"number\") {\n compareNumber = compareValue;\n this.context.translationParams.value = compareValue;\n } else {\n const source = scope === \"sibling\" ? context.parent : context.allValues;\n const fieldValue = get(source, compareValue);\n\n if (fieldValue === undefined) {\n return VALID_RULE;\n }\n\n this.context.translatableParams.value = compareValue;\n\n compareNumber = Number(fieldValue);\n\n if (isNaN(compareNumber)) {\n return VALID_RULE;\n }\n }\n\n if (value > compareNumber) {\n return VALID_RULE;\n }\n\n return invalidRule(this, context);\n },\n};\n\n/**\n * Less than rule - value must be strictly less than maximum\n * Supports field names with sibling scope\n */\nexport const lessThanRule: SchemaRule<{\n value: number | string;\n scope?: \"global\" | \"sibling\";\n}> = {\n name: \"lessThan\",\n defaultErrorMessage: \"The :input must be less than :value\",\n async validate(value: any, context) {\n const { value: compareValue, scope = \"global\" } = this.context.options;\n let compareNumber: number;\n\n if (typeof compareValue === \"number\") {\n compareNumber = compareValue;\n this.context.translationParams.value = compareValue;\n } else {\n const source = scope === \"sibling\" ? context.parent : context.allValues;\n const fieldValue = get(source, compareValue);\n\n if (fieldValue === undefined) {\n return VALID_RULE;\n }\n\n this.context.translatableParams.value = compareValue;\n\n compareNumber = Number(fieldValue);\n\n if (isNaN(compareNumber)) {\n return VALID_RULE;\n }\n }\n\n if (value < compareNumber) {\n return VALID_RULE;\n }\n\n return invalidRule(this, context);\n },\n};\n\n/**\n * Positive rule - value must be greater than 0\n */\nexport const positiveRule: SchemaRule = {\n name: \"positive\",\n defaultErrorMessage: \"The :input must be a positive number\",\n async validate(value: any, context) {\n if (value > 0) {\n return VALID_RULE;\n }\n\n return invalidRule(this, context);\n },\n};\n\n/**\n * Negative rule - value must be less than 0\n */\nexport const negativeRule: SchemaRule = {\n name: \"negative\",\n defaultErrorMessage: \"The :input must be a negative number\",\n async validate(value: any, context) {\n if (value < 0) {\n return VALID_RULE;\n }\n\n return invalidRule(this, context);\n },\n};\n\n/**\n * Odd rule - value must be an odd number\n */\nexport const oddRule: SchemaRule = {\n name: \"odd\",\n defaultErrorMessage: \"The :input must be an odd number\",\n async validate(value: any, context) {\n if (value % 2 !== 0) {\n return VALID_RULE;\n }\n\n return invalidRule(this, context);\n },\n};\n\n/**\n * Even rule - value must be an even number\n */\nexport const evenRule: SchemaRule = {\n name: \"even\",\n defaultErrorMessage: \"The :input must be an even number\",\n async validate(value: any, context) {\n if (value % 2 === 0) {\n return VALID_RULE;\n }\n\n return invalidRule(this, context);\n },\n};\n\n/**\n * Modulo rule - value must be divisible by given number\n */\nexport const moduloRule: SchemaRule<{ value: number }> = {\n name: \"modulo\",\n defaultErrorMessage: \"The :input must be divisible by :value\",\n async validate(value: any, context) {\n if (value % this.context.options.value === 0) {\n return VALID_RULE;\n }\n\n this.context.translationParams.value = this.context.options.value;\n\n return invalidRule(this, context);\n },\n};\n\n/**\n * Between rule - value must be between the given two numbers (Inclusive)\n * Supports field names with sibling scope\n */\nexport const betweenNumbersRule: SchemaRule<{\n min: number | string;\n max: number | string;\n scope?: \"global\" | \"sibling\";\n}> = {\n name: \"betweenNumbers\",\n defaultErrorMessage: \"The :input must be between :min and :max\",\n async validate(value: any, context) {\n const { min, max, scope = \"global\" } = this.context.options;\n\n // Extract min value\n let compareMin: number;\n if (typeof min === \"number\") {\n compareMin = min;\n this.context.translationParams.min = min;\n } else {\n const source = scope === \"sibling\" ? context.parent : context.allValues;\n const fieldValue = get(source, min);\n\n if (fieldValue === undefined) {\n return VALID_RULE;\n }\n\n this.context.translatableParams.min = min;\n\n compareMin = Number(fieldValue);\n if (isNaN(compareMin)) {\n return VALID_RULE;\n }\n }\n\n // Extract max value\n let compareMax: number;\n if (typeof max === \"number\") {\n compareMax = max;\n this.context.translationParams.max = max;\n } else {\n const source = scope === \"sibling\" ? context.parent : context.allValues;\n const fieldValue = get(source, max);\n\n if (fieldValue === undefined) {\n return VALID_RULE;\n }\n\n this.context.translatableParams.max = max;\n\n compareMax = Number(fieldValue);\n if (isNaN(compareMax)) {\n return VALID_RULE;\n }\n }\n\n if (value >= compareMin && value <= compareMax) {\n return VALID_RULE;\n }\n\n return invalidRule(this, context);\n },\n};\n"],"mappings":";;;;;;;;;AAQA,MAAa,UAGR;CACH,MAAM;CACN,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAClC,MAAM,EAAE,KAAK,QAAQ,aAAa,KAAK,QAAQ;EAC/C,IAAI;EAEJ,IAAI,OAAO,QAAQ,UAAU;GAC3B,aAAa;GACb,KAAK,QAAQ,kBAAkB,MAAM;EACvC,OAAO;GAEL,MAAM,aAAa,IADJ,UAAU,YAAY,QAAQ,SAAS,QAAQ,WAC/B,GAAG;GAElC,IAAI,eAAe,QACjB,OAAO;GAGT,KAAK,QAAQ,mBAAmB,MAAM;GAEtC,aAAa,OAAO,UAAU;GAE9B,IAAI,MAAM,UAAU,GAClB,OAAO;EAEX;EAEA,IAAI,SAAS,YACX,OAAO;EAGT,OAAO,YAAY,MAAM,OAAO;CAClC;AACF;;;;;AAMA,MAAa,UAGR;CACH,MAAM;CACN,qBAAqB;CACrB,MAAM,SA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D,IAAI;EACJ,IAAI,OAAO,QAAQ,UAAU;GAC3B,aAAa;GACb,KAAK,QAAQ,kBAAkB,MAAM;EACvC,OAAO;GAEL,MAAM,aAAa,IADJ,UAAU,YAAY,QAAQ,SAAS,QAAQ,WAC/B,GAAG;GAElC,IAAI,eAAe,QACjB,OAAO;GAGT,KAAK,QAAQ,mBAAmB,MAAM;GAEtC,aAAa,OAAO,UAAU;GAC9B,IAAI,MAAM,UAAU,GAClB,OAAO;EAEX;EAGA,IAAI;EACJ,IAAI,OAAO,QAAQ,UAAU;GAC3B,aAAa;GACb,KAAK,QAAQ,kBAAkB,MAAM;EACvC,OAAO;GAEL,MAAM,aAAa,IADJ,UAAU,YAAY,QAAQ,SAAS,QAAQ,WAC/B,GAAG;GAElC,IAAI,eAAe,QACjB,OAAO;GAGT,KAAK,QAAQ,mBAAmB,MAAM;GAEtC,aAAa,OAAO,UAAU;GAC9B,IAAI,MAAM,UAAU,GAClB,OAAO;EAEX;EAEA,IAAI,SAAS,cAAc,SAAS,YAClC,OAAO;EAGT,OAAO,YAAY,MAAM,OAAO;CAClC;AACF"}
|
|
1
|
+
{"version":3,"file":"number-rules.mjs","names":[],"sources":["../../../../../../../../../packages/seal/src/rules/number/number-rules.ts"],"sourcesContent":["import { get } from \"@mongez/reinforcements\";\nimport { invalidRule, VALID_RULE } from \"../../helpers\";\nimport type { SchemaRule } from \"../../types\";\n\n/**\n * Min rule - value must be equal or greater than minimum\n * Supports field names with sibling scope\n */\nexport const minRule: SchemaRule<{\n min: number | string;\n scope?: \"global\" | \"sibling\";\n}> = {\n name: \"min\",\n defaultErrorMessage: \"The :input must be at least :min\",\n async validate(value: any, context) {\n const { min, scope = \"global\" } = this.context.options;\n let compareMin: number;\n\n if (typeof min === \"number\") {\n compareMin = min;\n this.context.translationParams.min = min;\n } else {\n const source = scope === \"sibling\" ? context.parent : context.allValues;\n const fieldValue = get(source, min);\n\n if (fieldValue === undefined) {\n return VALID_RULE;\n }\n\n this.context.translatableParams.min = min;\n\n compareMin = Number(fieldValue);\n\n if (isNaN(compareMin)) {\n return VALID_RULE;\n }\n }\n\n if (value >= compareMin) {\n return VALID_RULE;\n }\n\n return invalidRule(this, context);\n },\n};\n\n/**\n * Max rule - value must be equal or less than maximum\n * Supports field names with sibling scope\n */\nexport const maxRule: SchemaRule<{\n max: number | string;\n scope?: \"global\" | \"sibling\";\n}> = {\n name: \"max\",\n defaultErrorMessage: \"The :input must equal to or less than :max\",\n async validate(value: any, context) {\n const { max, scope = \"global\" } = this.context.options;\n let compareMax: number;\n\n if (typeof max === \"number\") {\n compareMax = max;\n this.context.translationParams.max = max;\n } else {\n const source = scope === \"sibling\" ? context.parent : context.allValues;\n const fieldValue = get(source, max);\n\n if (fieldValue === undefined) {\n return VALID_RULE;\n }\n\n this.context.translatableParams.max = max;\n\n compareMax = Number(fieldValue);\n\n if (isNaN(compareMax)) {\n return VALID_RULE;\n }\n }\n\n if (value <= compareMax) {\n return VALID_RULE;\n }\n\n return invalidRule(this, context);\n },\n};\n\n/**\n * Greater than rule - value must be strictly greater than minimum\n * Supports field names with sibling scope\n */\nexport const greaterThanRule: SchemaRule<{\n value: number | string;\n scope?: \"global\" | \"sibling\";\n}> = {\n name: \"greaterThan\",\n defaultErrorMessage: \"The :input must be greater than :value\",\n async validate(value: any, context) {\n const { value: compareValue, scope = \"global\" } = this.context.options;\n let compareNumber: number;\n\n if (typeof compareValue === \"number\") {\n compareNumber = compareValue;\n this.context.translationParams.value = compareValue;\n } else {\n const source = scope === \"sibling\" ? context.parent : context.allValues;\n const fieldValue = get(source, compareValue);\n\n if (fieldValue === undefined) {\n return VALID_RULE;\n }\n\n this.context.translatableParams.value = compareValue;\n\n compareNumber = Number(fieldValue);\n\n if (isNaN(compareNumber)) {\n return VALID_RULE;\n }\n }\n\n if (value > compareNumber) {\n return VALID_RULE;\n }\n\n return invalidRule(this, context);\n },\n};\n\n/**\n * Less than rule - value must be strictly less than maximum\n * Supports field names with sibling scope\n */\nexport const lessThanRule: SchemaRule<{\n value: number | string;\n scope?: \"global\" | \"sibling\";\n}> = {\n name: \"lessThan\",\n defaultErrorMessage: \"The :input must be less than :value\",\n async validate(value: any, context) {\n const { value: compareValue, scope = \"global\" } = this.context.options;\n let compareNumber: number;\n\n if (typeof compareValue === \"number\") {\n compareNumber = compareValue;\n this.context.translationParams.value = compareValue;\n } else {\n const source = scope === \"sibling\" ? context.parent : context.allValues;\n const fieldValue = get(source, compareValue);\n\n if (fieldValue === undefined) {\n return VALID_RULE;\n }\n\n this.context.translatableParams.value = compareValue;\n\n compareNumber = Number(fieldValue);\n\n if (isNaN(compareNumber)) {\n return VALID_RULE;\n }\n }\n\n if (value < compareNumber) {\n return VALID_RULE;\n }\n\n return invalidRule(this, context);\n },\n};\n\n/**\n * Positive rule - value must be greater than 0\n */\nexport const positiveRule: SchemaRule = {\n name: \"positive\",\n defaultErrorMessage: \"The :input must be a positive number\",\n async validate(value: any, context) {\n if (value > 0) {\n return VALID_RULE;\n }\n\n return invalidRule(this, context);\n },\n};\n\n/**\n * Negative rule - value must be less than 0\n */\nexport const negativeRule: SchemaRule = {\n name: \"negative\",\n defaultErrorMessage: \"The :input must be a negative number\",\n async validate(value: any, context) {\n if (value < 0) {\n return VALID_RULE;\n }\n\n return invalidRule(this, context);\n },\n};\n\n/**\n * Odd rule - value must be an odd number\n */\nexport const oddRule: SchemaRule = {\n name: \"odd\",\n defaultErrorMessage: \"The :input must be an odd number\",\n async validate(value: any, context) {\n if (value % 2 !== 0) {\n return VALID_RULE;\n }\n\n return invalidRule(this, context);\n },\n};\n\n/**\n * Even rule - value must be an even number\n */\nexport const evenRule: SchemaRule = {\n name: \"even\",\n defaultErrorMessage: \"The :input must be an even number\",\n async validate(value: any, context) {\n if (value % 2 === 0) {\n return VALID_RULE;\n }\n\n return invalidRule(this, context);\n },\n};\n\n/**\n * Modulo rule - value must be divisible by given number\n */\nexport const moduloRule: SchemaRule<{ value: number }> = {\n name: \"modulo\",\n defaultErrorMessage: \"The :input must be divisible by :value\",\n async validate(value: any, context) {\n if (value % this.context.options.value === 0) {\n return VALID_RULE;\n }\n\n this.context.translationParams.value = this.context.options.value;\n\n return invalidRule(this, context);\n },\n};\n\n/**\n * Between rule - value must be between the given two numbers (Inclusive)\n * Supports field names with sibling scope\n */\nexport const betweenNumbersRule: SchemaRule<{\n min: number | string;\n max: number | string;\n scope?: \"global\" | \"sibling\";\n}> = {\n name: \"betweenNumbers\",\n defaultErrorMessage: \"The :input must be between :min and :max\",\n async validate(value: any, context) {\n const { min, max, scope = \"global\" } = this.context.options;\n\n // Extract min value\n let compareMin: number;\n if (typeof min === \"number\") {\n compareMin = min;\n this.context.translationParams.min = min;\n } else {\n const source = scope === \"sibling\" ? context.parent : context.allValues;\n const fieldValue = get(source, min);\n\n if (fieldValue === undefined) {\n return VALID_RULE;\n }\n\n this.context.translatableParams.min = min;\n\n compareMin = Number(fieldValue);\n if (isNaN(compareMin)) {\n return VALID_RULE;\n }\n }\n\n // Extract max value\n let compareMax: number;\n if (typeof max === \"number\") {\n compareMax = max;\n this.context.translationParams.max = max;\n } else {\n const source = scope === \"sibling\" ? context.parent : context.allValues;\n const fieldValue = get(source, max);\n\n if (fieldValue === undefined) {\n return VALID_RULE;\n }\n\n this.context.translatableParams.max = max;\n\n compareMax = Number(fieldValue);\n if (isNaN(compareMax)) {\n return VALID_RULE;\n }\n }\n\n if (value >= compareMin && value <= compareMax) {\n return VALID_RULE;\n }\n\n return invalidRule(this, context);\n },\n};\n"],"mappings":";;;;;;;;;AAQA,MAAa,UAGR;CACH,MAAM;CACN,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAClC,MAAM,EAAE,KAAK,QAAQ,aAAa,KAAK,QAAQ;EAC/C,IAAI;EAEJ,IAAI,OAAO,QAAQ,UAAU;GAC3B,aAAa;GACb,KAAK,QAAQ,kBAAkB,MAAM;EACvC,OAAO;GACL,MAAM,SAAS,UAAU,YAAY,QAAQ,SAAS,QAAQ;GAC9D,MAAM,aA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LINED_VALUES, declinedIfPresentRule, declinedIfRequiredRule, declinedIfRule, declinedRule, declinedUnlessRule, declinedWithoutRule } from "./declined-rule.mjs";
|
|
3
3
|
|
|
4
|
-
export {
|
|
4
|
+
export { ACCEPTED_VALUES, DECLINED_VALUES, acceptedIfPresentRule, acceptedIfRequiredRule, acceptedIfRule, acceptedRule, acceptedUnlessRule, acceptedWithoutRule, declinedIfPresentRule, declinedIfRequiredRule, declinedIfRule, declinedRule, declinedUnlessRule, declinedWithoutRule };
|
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
import { SchemaRule } from "../../types/rule-types.mjs";
|
|
2
|
-
|
|
2
|
+
import "../../types/index.mjs";
|
|
3
3
|
//#region ../../packages/seal/src/rules/string/alpha.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* Alpha rule - allows only alphabetic characters
|
|
6
6
|
*/
|
|
7
|
-
declare const alphaRule: SchemaRule;
|
|
7
|
+
export declare const alphaRule: SchemaRule;
|
|
8
8
|
/**
|
|
9
9
|
* AlphaNumeric rule - allows only alphanumeric characters
|
|
10
10
|
*/
|
|
11
|
-
declare const alphaNumericRule: SchemaRule;
|
|
11
|
+
export declare const alphaNumericRule: SchemaRule;
|
|
12
12
|
/**
|
|
13
13
|
* Numeric string rule - allows only numeric characters
|
|
14
14
|
*/
|
|
15
|
-
declare const isNumericRule: SchemaRule;
|
|
15
|
+
export declare const isNumericRule: SchemaRule;
|
|
16
16
|
//#endregion
|
|
17
|
-
export { alphaNumericRule, alphaRule, isNumericRule };
|
|
18
17
|
//# sourceMappingURL=alpha.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alpha.d.mts","names":[],"sources":["../../../../../../../../../packages/seal/src/rules/string/alpha.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"alpha.d.mts","names":[],"sources":["../../../../../../../../../packages/seal/src/rules/string/alpha.ts"],"mappings":";;;;;;qBAMa,WAAW;;;;qBAcX,kBAAkB;;;;qBAclB,eAAe"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { SchemaRule } from "../../types/rule-types.mjs";
|
|
2
|
-
|
|
2
|
+
import "../../types/index.mjs";
|
|
3
3
|
//#region ../../packages/seal/src/rules/string/credit-card.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* Credit card rule - validates credit card number
|
|
6
6
|
*/
|
|
7
|
-
declare const isCreditCardRule: SchemaRule;
|
|
7
|
+
export declare const isCreditCardRule: SchemaRule;
|
|
8
8
|
//#endregion
|
|
9
|
-
export { isCreditCardRule };
|
|
10
9
|
//# sourceMappingURL=credit-card.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"credit-card.d.mts","names":[],"sources":["../../../../../../../../../packages/seal/src/rules/string/credit-card.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"credit-card.d.mts","names":[],"sources":["../../../../../../../../../packages/seal/src/rules/string/credit-card.ts"],"mappings":";;;;;;qBAMa,kBAAkB"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { SchemaRule } from "../../types/rule-types.mjs";
|
|
2
|
-
|
|
2
|
+
import "../../types/index.mjs";
|
|
3
3
|
//#region ../../packages/seal/src/rules/string/email.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* Email rule - validates email format
|
|
6
6
|
*/
|
|
7
|
-
declare const emailRule: SchemaRule;
|
|
7
|
+
export declare const emailRule: SchemaRule;
|
|
8
8
|
//#endregion
|
|
9
|
-
export { emailRule };
|
|
10
9
|
//# sourceMappingURL=email.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"email.d.mts","names":[],"sources":["../../../../../../../../../packages/seal/src/rules/string/email.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"email.d.mts","names":[],"sources":["../../../../../../../../../packages/seal/src/rules/string/email.ts"],"mappings":";;;;;;qBAOa,WAAW"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SchemaRule } from "../../types/rule-types.mjs";
|
|
2
|
-
|
|
2
|
+
import "../../types/index.mjs";
|
|
3
3
|
//#region ../../packages/seal/src/rules/string/id-formats.d.ts
|
|
4
|
-
type UUIDVersion = 1 | 3 | 4 | 5 | 6 | 7;
|
|
4
|
+
export type UUIDVersion = 1 | 3 | 4 | 5 | 6 | 7;
|
|
5
5
|
/**
|
|
6
6
|
* UUID rule — value must be a valid UUID. Optionally restrict to a specific version.
|
|
7
7
|
*
|
|
@@ -10,7 +10,7 @@ type UUIDVersion = 1 | 3 | 4 | 5 | 6 | 7;
|
|
|
10
10
|
* v.string().uuid(4) // only v4 (random)
|
|
11
11
|
* v.string().uuid(7) // only v7 (timestamp-ordered)
|
|
12
12
|
*/
|
|
13
|
-
declare const uuidRule: SchemaRule<{
|
|
13
|
+
export declare const uuidRule: SchemaRule<{
|
|
14
14
|
version?: UUIDVersion;
|
|
15
15
|
}>;
|
|
16
16
|
/**
|
|
@@ -24,7 +24,7 @@ declare const uuidRule: SchemaRule<{
|
|
|
24
24
|
* v.string().cuid() // CUID2
|
|
25
25
|
* v.string().cuid({ version: 1 }) // legacy CUID1
|
|
26
26
|
*/
|
|
27
|
-
declare const cuidRule: SchemaRule<{
|
|
27
|
+
export declare const cuidRule: SchemaRule<{
|
|
28
28
|
version?: 1 | 2;
|
|
29
29
|
}>;
|
|
30
30
|
/**
|
|
@@ -35,7 +35,7 @@ declare const cuidRule: SchemaRule<{
|
|
|
35
35
|
* @example
|
|
36
36
|
* v.string().ulid()
|
|
37
37
|
*/
|
|
38
|
-
declare const ulidRule: SchemaRule;
|
|
38
|
+
export declare const ulidRule: SchemaRule;
|
|
39
39
|
/**
|
|
40
40
|
* nanoid rule — value must be a valid nanoid string.
|
|
41
41
|
*
|
|
@@ -46,9 +46,8 @@ declare const ulidRule: SchemaRule;
|
|
|
46
46
|
* v.string().nanoid() // 21 chars (default)
|
|
47
47
|
* v.string().nanoid(10) // 10 chars
|
|
48
48
|
*/
|
|
49
|
-
declare const nanoidRule: SchemaRule<{
|
|
49
|
+
export declare const nanoidRule: SchemaRule<{
|
|
50
50
|
length?: number;
|
|
51
51
|
}>;
|
|
52
52
|
//#endregion
|
|
53
|
-
export { UUIDVersion, cuidRule, nanoidRule, ulidRule, uuidRule };
|
|
54
53
|
//# sourceMappingURL=id-formats.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"id-formats.d.mts","names":[],"sources":["../../../../../../../../../packages/seal/src/rules/string/id-formats.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"id-formats.d.mts","names":[],"sources":["../../../../../../../../../packages/seal/src/rules/string/id-formats.ts"],"mappings":";;;YAuBY;;;;;;;;;qBAUC,UAAU;EAAa,UAAU;;;;;;;;;;;;;qBA8BjC,UAAU;EAAa;;;;;;;;;;qBAqBvB,UAAU;;;;;;;;;;;qBAoBV,YAAY;EAAa"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { alphaNumericRule, alphaRule, isNumericRule } from "./alpha.mjs";
|
|
2
|
+
import { isCreditCardRule } from "./credit-card.mjs";
|
|
3
|
+
import { emailRule } from "./email.mjs";
|
|
4
|
+
import { UUIDVersion, cuidRule, nanoidRule, ulidRule, uuidRule } from "./id-formats.mjs";
|
|
5
|
+
import { ip4Rule, ip6Rule, ipRule, isIP, isIPv4, isIPv6 } from "./ip.mjs";
|
|
6
|
+
import { matchesRule } from "./matches.mjs";
|
|
7
|
+
import { patternRule } from "./pattern.mjs";
|
|
8
|
+
import { containsRule, endsWithRule, notContainsRule, startsWithRule } from "./string-comparison.mjs";
|
|
9
|
+
import { strongPasswordRule } from "./strong-password-rule.mjs";
|
|
10
|
+
import { urlRule } from "./url.mjs";
|
|
11
|
+
import { withoutWhitespaceRule } from "./without-whitespace.mjs";
|
|
12
|
+
export { UUIDVersion, alphaNumericRule, alphaRule, containsRule, cuidRule, emailRule, endsWithRule, ip4Rule, ip6Rule, ipRule, isCreditCardRule, isIP, isIPv4, isIPv6, isNumericRule, matchesRule, nanoidRule, notContainsRule, patternRule, startsWithRule, strongPasswordRule, ulidRule, urlRule, uuidRule, withoutWhitespaceRule };
|
|
@@ -10,4 +10,4 @@ import { strongPasswordRule } from "./strong-password-rule.mjs";
|
|
|
10
10
|
import { urlRule } from "./url.mjs";
|
|
11
11
|
import { withoutWhitespaceRule } from "./without-whitespace.mjs";
|
|
12
12
|
|
|
13
|
-
export {
|
|
13
|
+
export { alphaNumericRule, alphaRule, containsRule, cuidRule, emailRule, endsWithRule, ip4Rule, ip6Rule, ipRule, isCreditCardRule, isIP, isIPv4, isIPv6, isNumericRule, matchesRule, nanoidRule, notContainsRule, patternRule, startsWithRule, strongPasswordRule, ulidRule, urlRule, uuidRule, withoutWhitespaceRule };
|
|
@@ -1,25 +1,24 @@
|
|
|
1
1
|
import { SchemaRule } from "../../types/rule-types.mjs";
|
|
2
|
-
|
|
2
|
+
import "../../types/index.mjs";
|
|
3
3
|
//#region ../../packages/seal/src/rules/string/ip.d.ts
|
|
4
|
-
declare function isIPv4(value: string): boolean;
|
|
5
|
-
declare function isIPv6(value: string): boolean;
|
|
4
|
+
export declare function isIPv4(value: string): boolean;
|
|
5
|
+
export declare function isIPv6(value: string): boolean;
|
|
6
6
|
/**
|
|
7
7
|
* Returns 4 or 6 when `value` is a valid IPv4/IPv6 address, otherwise 0.
|
|
8
8
|
* Signature mirrors Node's `net.isIP` for drop-in behavior parity.
|
|
9
9
|
*/
|
|
10
|
-
declare function isIP(value: string): 0 | 4 | 6;
|
|
10
|
+
export declare function isIP(value: string): 0 | 4 | 6;
|
|
11
11
|
/**
|
|
12
12
|
* IP rule - validates IP address (v4 or v6)
|
|
13
13
|
*/
|
|
14
|
-
declare const ipRule: SchemaRule;
|
|
14
|
+
export declare const ipRule: SchemaRule;
|
|
15
15
|
/**
|
|
16
16
|
* IPv4 rule - validates IPv4 address
|
|
17
17
|
*/
|
|
18
|
-
declare const ip4Rule: SchemaRule;
|
|
18
|
+
export declare const ip4Rule: SchemaRule;
|
|
19
19
|
/**
|
|
20
20
|
* IPv6 rule - validates IPv6 address
|
|
21
21
|
*/
|
|
22
|
-
declare const ip6Rule: SchemaRule;
|
|
22
|
+
export declare const ip6Rule: SchemaRule;
|
|
23
23
|
//#endregion
|
|
24
|
-
export { ip4Rule, ip6Rule, ipRule, isIP, isIPv4, isIPv6 };
|
|
25
24
|
//# sourceMappingURL=ip.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ip.d.mts","names":[],"sources":["../../../../../../../../../packages/seal/src/rules/string/ip.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"ip.d.mts","names":[],"sources":["../../../../../../../../../packages/seal/src/rules/string/ip.ts"],"mappings":";;;wBA0BgB,OAAO;wBAIP,OAAO;;;;;wBAQP,KAAK;;;;qBASR,QAAQ;;;;qBAcR,SAAS;;;;qBAcT,SAAS"}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { SchemaRule } from "../../types/rule-types.mjs";
|
|
2
|
-
|
|
2
|
+
import "../../types/index.mjs";
|
|
3
3
|
//#region ../../packages/seal/src/rules/string/matches.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* Matches rule - value must match another field value
|
|
6
6
|
*/
|
|
7
|
-
declare const matchesRule: SchemaRule<{
|
|
7
|
+
export declare const matchesRule: SchemaRule<{
|
|
8
8
|
field: string;
|
|
9
9
|
}>;
|
|
10
10
|
//#endregion
|
|
11
|
-
export { matchesRule };
|
|
12
11
|
//# sourceMappingURL=matches.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"matches.d.mts","names":[],"sources":["../../../../../../../../../packages/seal/src/rules/string/matches.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"matches.d.mts","names":[],"sources":["../../../../../../../../../packages/seal/src/rules/string/matches.ts"],"mappings":";;;;;;qBAOa,aAAa;EAAa"}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { SchemaRule } from "../../types/rule-types.mjs";
|
|
2
|
-
|
|
2
|
+
import "../../types/index.mjs";
|
|
3
3
|
//#region ../../packages/seal/src/rules/string/pattern.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* Pattern rule - validates against regex pattern
|
|
6
6
|
*/
|
|
7
|
-
declare const patternRule: SchemaRule<{
|
|
7
|
+
export declare const patternRule: SchemaRule<{
|
|
8
8
|
pattern: RegExp;
|
|
9
9
|
}>;
|
|
10
10
|
//#endregion
|
|
11
|
-
export { patternRule };
|
|
12
11
|
//# sourceMappingURL=pattern.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pattern.d.mts","names":[],"sources":["../../../../../../../../../packages/seal/src/rules/string/pattern.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"pattern.d.mts","names":[],"sources":["../../../../../../../../../packages/seal/src/rules/string/pattern.ts"],"mappings":";;;;;;qBAMa,aAAa;EAAa,SAAS"}
|