@warlock.js/notifications 5.24.0 → 5.26.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 +12 -0
- package/cjs/index.cjs +1 -1
- package/cjs/rabbitmq-driver-DvWaCPES.cjs +3 -0
- package/cjs/{src-DbAWktJm.cjs → src-BVlqtCR2.cjs} +22 -6
- package/cjs/src-BVlqtCR2.cjs.map +1 -0
- package/esm/herald/src/communicators/broker-registry.mjs.map +1 -1
- package/esm/herald/src/communicators/broker.mjs.map +1 -1
- package/esm/herald/src/drivers/rabbitmq/rabbitmq-channel.mjs.map +1 -1
- package/esm/herald/src/drivers/rabbitmq/rabbitmq-driver.mjs.map +1 -1
- package/esm/herald/src/message-managers/prepare-consumer-subscription.mjs.map +1 -1
- package/esm/herald/src/utils/connect-to-broker.mjs.map +1 -1
- package/esm/seal/src/config.mjs.map +1 -1
- package/esm/seal/src/factory/validate.mjs.map +1 -1
- package/esm/seal/src/factory/validators.mjs +1 -1
- package/esm/seal/src/factory/validators.mjs.map +1 -1
- package/esm/seal/src/helpers/date-helpers.mjs.map +1 -1
- package/esm/seal/src/helpers/get-field-value.mjs.map +1 -1
- package/esm/seal/src/helpers/path-helpers.mjs.map +1 -1
- package/esm/seal/src/mutators/array-mutators.mjs.map +1 -1
- package/esm/seal/src/mutators/date-mutators.mjs.map +1 -1
- package/esm/seal/src/mutators/number-mutators.mjs.map +1 -1
- package/esm/seal/src/mutators/object-mutators.mjs.map +1 -1
- package/esm/seal/src/mutators/scalar-mutators.mjs.map +1 -1
- package/esm/seal/src/mutators/string-mutators.mjs.map +1 -1
- package/esm/seal/src/rules/array/array-rules.mjs.map +1 -1
- package/esm/seal/src/rules/color/color-rules.mjs.map +1 -1
- package/esm/seal/src/rules/common/enum.mjs.map +1 -1
- package/esm/seal/src/rules/common/equals-field-rules.mjs.map +1 -1
- package/esm/seal/src/rules/common/type-rules.mjs.map +1 -1
- package/esm/seal/src/rules/conditional/forbidden-if-rules.mjs.map +1 -1
- package/esm/seal/src/rules/conditional/present-if-rules.mjs.map +1 -1
- package/esm/seal/src/rules/conditional/present-unless-rules.mjs.map +1 -1
- package/esm/seal/src/rules/conditional/present-with-rules.mjs.map +1 -1
- package/esm/seal/src/rules/conditional/present-without-rules.mjs.map +1 -1
- package/esm/seal/src/rules/conditional/required-if-rules.mjs.map +1 -1
- package/esm/seal/src/rules/conditional/required-unless-rules.mjs.map +1 -1
- package/esm/seal/src/rules/conditional/required-with-rules.mjs.map +1 -1
- package/esm/seal/src/rules/conditional/required-without-rules.mjs.map +1 -1
- package/esm/seal/src/rules/core/equal.mjs.map +1 -1
- package/esm/seal/src/rules/core/forbidden.mjs.map +1 -1
- package/esm/seal/src/rules/core/required.mjs.map +1 -1
- package/esm/seal/src/rules/core/union.mjs.map +1 -1
- package/esm/seal/src/rules/core/when.mjs.map +1 -1
- package/esm/seal/src/rules/date/date-comparison-rules.mjs.map +1 -1
- package/esm/seal/src/rules/date/date-day-rules.mjs.map +1 -1
- package/esm/seal/src/rules/date/date-field-comparison-rules.mjs.map +1 -1
- package/esm/seal/src/rules/date/date-period-rules.mjs.map +1 -1
- package/esm/seal/src/rules/date/date-relative-rules.mjs.map +1 -1
- package/esm/seal/src/rules/date/date-special-rules.mjs.map +1 -1
- package/esm/seal/src/rules/date/date.mjs.map +1 -1
- package/esm/seal/src/rules/length/length-rules.mjs.map +1 -1
- package/esm/seal/src/rules/number/number-rules.mjs.map +1 -1
- package/esm/seal/src/rules/scalar/accepted-rule.mjs.map +1 -1
- package/esm/seal/src/rules/scalar/declined-rule.mjs.map +1 -1
- package/esm/seal/src/rules/string/alpha.mjs.map +1 -1
- package/esm/seal/src/rules/string/credit-card.mjs.map +1 -1
- package/esm/seal/src/rules/string/email.mjs.map +1 -1
- package/esm/seal/src/rules/string/pattern.mjs.map +1 -1
- package/esm/seal/src/rules/string/string-comparison.mjs.map +1 -1
- package/esm/seal/src/rules/string/strong-password-rule.mjs.map +1 -1
- package/esm/seal/src/rules/string/url.mjs.map +1 -1
- package/esm/seal/src/rules/string/without-whitespace.mjs.map +1 -1
- package/esm/seal/src/types/date-types.mjs.map +1 -1
- package/esm/seal/src/validators/any-validator.mjs.map +1 -1
- package/esm/seal/src/validators/array-validator.mjs +1 -0
- package/esm/seal/src/validators/array-validator.mjs.map +1 -1
- package/esm/seal/src/validators/base-validator.mjs +12 -1
- package/esm/seal/src/validators/base-validator.mjs.map +1 -1
- package/esm/seal/src/validators/boolean-validator.mjs +1 -0
- package/esm/seal/src/validators/boolean-validator.mjs.map +1 -1
- package/esm/seal/src/validators/date-validator.mjs +1 -0
- package/esm/seal/src/validators/date-validator.mjs.map +1 -1
- package/esm/seal/src/validators/float-validator.mjs.map +1 -1
- package/esm/seal/src/validators/int-validator.mjs.map +1 -1
- package/esm/seal/src/validators/literal-validator.mjs +1 -3
- package/esm/seal/src/validators/literal-validator.mjs.map +1 -1
- package/esm/seal/src/validators/methods/equality-conditional-methods.mjs.map +1 -1
- package/esm/seal/src/validators/methods/forbidden-methods.mjs.map +1 -1
- package/esm/seal/src/validators/methods/present-methods.mjs.map +1 -1
- package/esm/seal/src/validators/methods/required-methods.mjs.map +1 -1
- package/esm/seal/src/validators/number-validator.mjs +1 -0
- package/esm/seal/src/validators/number-validator.mjs.map +1 -1
- package/esm/seal/src/validators/numeric-validator.mjs.map +1 -1
- package/esm/seal/src/validators/object-validator.mjs +1 -1
- package/esm/seal/src/validators/object-validator.mjs.map +1 -1
- package/esm/seal/src/validators/record-validator.mjs.map +1 -1
- package/esm/seal/src/validators/scalar-validator.mjs +1 -0
- package/esm/seal/src/validators/scalar-validator.mjs.map +1 -1
- package/esm/seal/src/validators/string-validator.mjs.map +1 -1
- package/esm/seal/src/validators/tuple-validator.mjs.map +1 -1
- package/esm/seal/src/validators/union-validator.mjs.map +1 -1
- package/llms-full.txt +901 -891
- package/package.json +7 -7
- package/skills/configure-notifications/SKILL.md +138 -138
- package/skills/define-channel/SKILL.md +107 -107
- package/skills/define-notification/SKILL.md +133 -133
- package/skills/observe-notifications/SKILL.md +66 -66
- package/skills/queue-notifications/SKILL.md +110 -110
- package/skills/send-ad-hoc/SKILL.md +95 -95
- package/skills/use-in-app/SKILL.md +172 -172
- package/skills/write-notification-migration/SKILL.md +66 -66
- package/cjs/rabbitmq-driver-C0o3Pz15.cjs +0 -3
- package/cjs/src-DbAWktJm.cjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"object-mutators.mjs","names":[],"sources":["../../../../../../../../../seal/src/mutators/object-mutators.ts"],"sourcesContent":["import { trim } from \"@mongez/reinforcements\";\
|
|
1
|
+
{"version":3,"file":"object-mutators.mjs","names":[],"sources":["../../../../../../../../../seal/src/mutators/object-mutators.ts"],"sourcesContent":["import { trim } from \"@mongez/reinforcements\";\nimport { isPlainObject } from \"@mongez/supportive-is\";\nimport type { Mutator } from \"../types\";\n\n/** Strip unknown keys from object */\nexport const stripUnknownMutator: Mutator = async (value, context) => {\n const allowedKeys = [\n ...(context?.ctx.schema ? Object.keys(context.ctx.schema) : []),\n ...(context?.options.allowedKeys ?? []),\n ];\n\n const result: Record<string, any> = {};\n\n for (const key in value) {\n if (allowedKeys.includes(key)) {\n result[key] = value[key];\n }\n }\n\n return result;\n};\n\n/** Trim all string values in object */\nexport const objectTrimMutator: Mutator = async (value, context) => {\n if (!isPlainObject(value)) return value;\n\n const result: Record<string, any> = {};\n const recursive = context?.options.recursive ?? false;\n\n for (const key in value) {\n const item = value[key];\n\n if (recursive) {\n if (Array.isArray(item)) {\n result[key] = await Promise.all(\n item.map(async (i: any) =>\n typeof i === \"string\" ? trim(i) : await objectTrimMutator(i, context),\n ),\n );\n } else if (isPlainObject(item)) {\n result[key] = await objectTrimMutator(item, context);\n } else {\n result[key] = typeof item === \"string\" ? trim(item) : item;\n }\n } else {\n result[key] = typeof item === \"string\" ? trim(item) : item;\n }\n }\n\n return result;\n};\n\n/** Parse JSON string */\nexport const jsonMutator: Mutator = async (value) => {\n try {\n return JSON.parse(value);\n } catch {\n return value;\n }\n};\n"],"mappings":";;;;;;AAKA,MAAa,sBAA+B,OAAO,OAAO,YAAY;CACpE,MAAM,cAAc,CAClB,GAAI,SAAS,IAAI,SAAS,OAAO,KAAK,QAAQ,IAAI,MAAM,IAAI,CAAC,GAC7D,GAAI,SAAS,QAAQ,eAAe,CAAC,CACvC;CAEA,MAAM,SAA8B,CAAC;CAErC,KAAK,MAAM,OAAO,OAChB,IAAI,YAAY,SAAS,GAAG,GAC1B,OAAO,OAAO,MAAM;CAIxB,OAAO;AACT;;AAGA,MAAa,oBAA6B,OAAO,OAAO,YAAY;CAClE,IAAI,CAAC,cAAc,KAAK,GAAG,OAAO;CAElC,MAAM,SAA8B,CAAC;CACrC,MAAM,YAAY,SAAS,QAAQ,aAAa;CAEhD,KAAK,MAAM,OAAO,OAAO;EACvB,MAAM,OAAO,MAAM;EAEnB,IAAI,WACF,IAAI,MAAM,QAAQ,IAAI,GACpB,OAAO,OAAO,MAAM,QAAQ,IAC1B,KAAK,IAAI,OAAO,MACd,OAAO,MAAM,WAAW,KAAK,CAAC,IAAI,MAAM,kBAAkB,GAAG,OAAO,CACtE,CACF;OACK,IAAI,cAAc,IAAI,GAC3B,OAAO,OAAO,MAAM,kBAAkB,MAAM,OAAO;OAEnD,OAAO,OAAO,OAAO,SAAS,WAAW,KAAK,IAAI,IAAI;OAGxD,OAAO,OAAO,OAAO,SAAS,WAAW,KAAK,IAAI,IAAI;CAE1D;CAEA,OAAO;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scalar-mutators.mjs","names":[],"sources":["../../../../../../../../../seal/src/mutators/scalar-mutators.ts"],"sourcesContent":["import type { Mutator } from \"../types\";\
|
|
1
|
+
{"version":3,"file":"scalar-mutators.mjs","names":[],"sources":["../../../../../../../../../seal/src/mutators/scalar-mutators.ts"],"sourcesContent":["import type { Mutator } from \"../types\";\n\nexport const stringMutator: Mutator = async (value) => {\n if ([undefined, null].includes(value)) {\n return value;\n }\n\n return String(value);\n};\n"],"mappings":";AAEA,MAAa,gBAAyB,OAAO,UAAU;CACrD,IAAI,CAAC,QAAW,IAAI,CAAC,CAAC,SAAS,KAAK,GAClC,OAAO;CAGT,OAAO,OAAO,KAAK;AACrB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"string-mutators.mjs","names":[],"sources":["../../../../../../../../../seal/src/mutators/string-mutators.ts"],"sourcesContent":["import {\r\n capitalize,\r\n ltrim,\r\n readMoreChars,\r\n rtrim,\r\n toCamelCase,\r\n toKebabCase,\r\n toSnakeCase,\r\n toStudlyCase,\r\n trim,\r\n} from \"@mongez/reinforcements\";\r\nimport type { Mutator } from \"../types\";\r\n\r\n/** Convert string to lowercase */\r\nexport const lowercaseMutator: Mutator = async (value) => {\r\n return value?.toString().toLowerCase();\r\n};\r\n\r\n/** Convert string to uppercase */\r\nexport const uppercaseMutator: Mutator = async (value) => {\r\n return value?.toString().toUpperCase();\r\n};\r\n\r\n/** Capitalize only the first letter of the string */\r\nexport const capitalizeMutator: Mutator = async (value) => {\r\n const str = value?.toString();\r\n return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();\r\n};\r\n\r\n/** Capitalize the first letter of each word (Title Case) */\r\nexport const titleCaseMutator: Mutator = async (value) => {\r\n return capitalize(value?.toString());\r\n};\r\n\r\n/** Convert value to string */\r\nexport const stringifyMutator: Mutator = async (value) => {\r\n if (!value && value !== 0) return \"\";\r\n // only convert numbers, boolean and strings\r\n\r\n // Handle strings (pass through)\r\n if (typeof value === \"string\") return value;\r\n\r\n // Handle scalar types (number, boolean)\r\n if (typeof value === \"number\" || typeof value === \"boolean\") {\r\n return String(value);\r\n }\r\n};\r\n\r\n/** Trim whitespace */\r\nexport const trimMutator: Mutator = async (value, context) => {\r\n return trim(value?.toString(), context?.options?.needle ?? \" \");\r\n};\r\n\r\n/**\r\n * Strip HTML tags with a naive `<...>` regex.\r\n *\r\n * This is a **tag stripper, not an XSS sanitizer**: it is not a parser, so\r\n * malformed/nested markup, attribute payloads, or content re-introduced\r\n * later in a pipeline can defeat it. Do not rely on this alone to make\r\n * untrusted rich text safe to render — use a real parser-based sanitizer\r\n * (e.g. DOMPurify / sanitize-html) for that.\r\n */\r\nexport const stripTagsMutator: Mutator = async (value) => {\r\n return value?.toString().replace(/<[^>]*>?/gm, \"\");\r\n};\r\n\r\n/**\r\n * @deprecated Renamed to {@link stripTagsMutator} — the old name implied\r\n * XSS safety this tag-stripping regex does not provide. Kept as an alias\r\n * for backward compatibility; switch to `stripTagsMutator`.\r\n */\r\nexport const safeHtmlMutator: Mutator = stripTagsMutator;\r\n\r\n/** HTML escape */\r\nexport const htmlEscapeMutator: Mutator = async (value) => {\r\n return value\r\n ?.toString()\r\n .replace(/&/g, \"&\")\r\n .replace(/</g, \"<\")\r\n .replace(/>/g, \">\")\r\n .replace(/\"/g, \""\")\r\n .replace(/'/g, \"'\");\r\n};\r\n\r\n/** Remove special characters */\r\nexport const removeSpecialCharactersMutator: Mutator = async (value) => {\r\n return value?.toString().replace(/[^a-zA-Z0-9]/g, \"\");\r\n};\r\n\r\n/** URL decode */\r\nexport const urlDecodeMutator: Mutator = async (value) => {\r\n return decodeURIComponent(value);\r\n};\r\n\r\n/** URL encode */\r\nexport const urlEncodeMutator: Mutator = async (value) => {\r\n return encodeURIComponent(value);\r\n};\r\n\r\n/** Convert to camelCase */\r\nexport const camelCaseMutator: Mutator = async (value) => {\r\n return toCamelCase(value?.toString());\r\n};\r\n\r\n/** Convert to PascalCase */\r\nexport const pascalCaseMutator: Mutator = async (value) => {\r\n return toStudlyCase(value?.toString());\r\n};\r\n\r\n/** Convert to snake_case */\r\nexport const snakeCaseMutator: Mutator = async (value) => {\r\n return toSnakeCase(value?.toString());\r\n};\r\n\r\n/** Convert to kebab-case */\r\nexport const kebabCaseMutator: Mutator = async (value) => {\r\n return toKebabCase(value?.toString());\r\n};\r\n\r\n/** Convert to URL-friendly slug */\r\nexport const slugMutator: Mutator = async (value) => {\r\n return value\r\n ?.toString()\r\n .toLowerCase()\r\n .trim()\r\n .replace(/[^\\w\\s-]/g, \"\")\r\n .replace(/[\\s_]+/g, \"-\")\r\n .replace(/--+/g, \"-\")\r\n .replace(/^-+|-+$/g, \"\");\r\n};\r\n\r\n/** Trim from the left/start */\r\nexport const ltrimMutator: Mutator = async (value, context) => {\r\n return ltrim(value?.toString(), context?.options?.needle ?? \" \");\r\n};\r\n\r\n/** Trim from the right/end */\r\nexport const rtrimMutator: Mutator = async (value, context) => {\r\n return rtrim(value?.toString(), context?.options?.needle ?? \" \");\r\n};\r\n\r\n/** Base64 encode */\r\nexport const base64EncodeMutator: Mutator = async (value) => {\r\n return Buffer.from(value?.toString()).toString(\"base64\");\r\n};\r\n\r\n/** Base64 decode */\r\nexport const base64DecodeMutator: Mutator = async (value) => {\r\n return Buffer.from(value?.toString(), \"base64\").toString(\"utf-8\");\r\n};\r\n\r\n/** Replace substring or pattern */\r\nexport const replaceMutator: Mutator = async (value, context) => {\r\n const { search, replace } = context?.options;\r\n if (!search) return value?.toString();\r\n return value?.toString().replace(search, replace ?? \"\");\r\n};\r\n\r\n/** Replace all occurrences of substring or pattern */\r\nexport const replaceAllMutator: Mutator = async (value, context) => {\r\n const { search, replace } = context?.options;\r\n if (!search) return value?.toString();\r\n const searchValue = typeof search === \"string\" ? new RegExp(search, \"g\") : search;\r\n return value?.toString().replace(searchValue, replace ?? \"\");\r\n};\r\n\r\n/** Append/suffix text to the end */\r\nexport const appendMutator: Mutator = async (value, context) => {\r\n const suffix = context?.options?.suffix ?? \"\";\r\n return value?.toString() + suffix;\r\n};\r\n\r\n/** Prepend/prefix text to the beginning */\r\nexport const prependMutator: Mutator = async (value, context) => {\r\n const prefix = context?.options?.prefix ?? \"\";\r\n return prefix + value?.toString();\r\n};\r\n\r\n/** Reverse the string */\r\nexport const reverseMutator: Mutator = async (value) => {\r\n return value?.toString().split(\"\").reverse().join(\"\");\r\n};\r\n\r\n/** Truncate to a maximum length */\r\nexport const truncateMutator: Mutator = async (value, context) => {\r\n const str = value?.toString();\r\n const maxLength = context?.options?.maxLength ?? 100;\r\n const suffix = context?.options?.suffix ?? \"...\";\r\n return readMoreChars(str, maxLength, suffix);\r\n};\r\n\r\n/** Trim multiple whitespace into single space */\r\nexport const trimMultipleWhitespaceMutator: Mutator = async (value) => {\r\n return value?.toString().replace(/\\s+/g, \" \");\r\n};\r\n\r\n/** Pad string from the start to reach target length */\r\nexport const padStartMutator: Mutator = async (value, context) => {\r\n const length = context?.options?.length ?? 0;\r\n const char = context?.options?.char ?? \" \";\r\n return value?.toString().padStart(length, char);\r\n};\r\n\r\n/** Pad string from the end to reach target length */\r\nexport const padEndMutator: Mutator = async (value, context) => {\r\n const length = context?.options?.length ?? 0;\r\n const char = context?.options?.char ?? \" \";\r\n return value?.toString().padEnd(length, char);\r\n};\r\n\r\n/** Repeat string N times */\r\nexport const repeatMutator: Mutator = async (value, context) => {\r\n const count = context?.options?.count ?? 1;\r\n return value?.toString()?.repeat(count);\r\n};\r\n\r\n/** Mask part of string */\r\nexport const maskMutator: Mutator = async (value, context) => {\r\n const str = value?.toString();\r\n const maskChar = context?.options?.char ?? \"*\";\r\n const start = context?.options?.start ?? 0;\r\n const end = context?.options?.end ?? str?.length;\r\n const visibleStart = str?.substring(0, start);\r\n const visibleEnd = str?.substring(end);\r\n const maskedLength = end - start;\r\n return visibleStart + maskChar.repeat(maskedLength) + visibleEnd;\r\n};\r\n\r\n/** Unescape HTML entities */\r\nexport const unescapeHtmlMutator: Mutator = async (value) => {\r\n return value\r\n ?.toString()\r\n .replace(/&/g, \"&\")\r\n .replace(/</g, \"<\")\r\n .replace(/>/g, \">\")\r\n .replace(/"/g, '\"')\r\n .replace(/'/g, \"'\");\r\n};\r\n\r\n/** Keep only alphabetic characters */\r\nexport const alphaOnlyMutator: Mutator = async (value) => {\r\n return value.toString().replace(/[^a-zA-Z]/g, \"\");\r\n};\r\n\r\n/** Keep only alphanumeric characters */\r\nexport const alphanumericOnlyMutator: Mutator = async (value) => {\r\n return value.toString().replace(/[^a-zA-Z0-9]/g, \"\");\r\n};\r\n\r\n/** Remove all numeric characters */\r\nexport const removeNumbersMutator: Mutator = async (value) => {\r\n return value.toString().replace(/[0-9]/g, \"\");\r\n};\r\n"],"mappings":";;;;;;;;;;;;;AAcA,MAAa,mBAA4B,OAAO,UAAU;CACxD,OAAO,OAAO,SAAS,CAAC,CAAC,YAAY;AACvC;;AAGA,MAAa,mBAA4B,OAAO,UAAU;CACxD,OAAO,OAAO,SAAS,CAAC,CAAC,YAAY;AACvC;;AAGA,MAAa,oBAA6B,OAAO,UAAU;CACzD,MAAM,MAAM,OAAO,SAAS;CAC5B,OAAO,IAAI,OAAO,CAAC,CAAC,CAAC,YAAY,IAAI,IAAI,MAAM,CAAC,CAAC,CAAC,YAAY;AAChE;;AAGA,MAAa,mBAA4B,OAAO,UAAU;CACxD,OAAO,WAAW,OAAO,SAAS,CAAC;AACrC;;AAGA,MAAa,mBAA4B,OAAO,UAAU;CACxD,IAAI,CAAC,SAAS,UAAU,GAAG,OAAO;CAIlC,IAAI,OAAO,UAAU,UAAU,OAAO;CAGtC,IAAI,OAAO,UAAU,YAAY,OAAO,UAAU,WAChD,OAAO,OAAO,KAAK;AAEvB;;AAGA,MAAa,cAAuB,OAAO,OAAO,YAAY;CAC5D,OAAO,KAAK,OAAO,SAAS,GAAG,SAAS,SAAS,UAAU,GAAG;AAChE;;;;;;;;;;AAWA,MAAa,mBAA4B,OAAO,UAAU;CACxD,OAAO,OAAO,SAAS,CAAC,CAAC,QAAQ,cAAc,EAAE;AACnD;;AAUA,MAAa,oBAA6B,OAAO,UAAU;CACzD,OAAO,OACH,SAAS,CAAC,CACX,QAAQ,MAAM,OAAO,CAAC,CACtB,QAAQ,MAAM,MAAM,CAAC,CACrB,QAAQ,MAAM,MAAM,CAAC,CACrB,QAAQ,MAAM,QAAQ,CAAC,CACvB,QAAQ,MAAM,QAAQ;A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,SAAS,SAAS,UAAU;CAC3C,MAAM,OAAO,SAAS,SAAS,QAAQ;CACvC,OAAO,OAAO,SAAS,CAAC,CAAC,OAAO,QAAQ,IAAI;AAC9C;;AAGA,MAAa,gBAAyB,OAAO,OAAO,YAAY;CAC9D,MAAM,QAAQ,SAAS,SAAS,SAAS;CACzC,OAAO,OAAO,SAAS,CAAC,EAAE,OAAO,KAAK;AACxC;;AAGA,MAAa,cAAuB,OAAO,OAAO,YAAY;CAC5D,MAAM,MAAM,OAAO,SAAS;CAC5B,MAAM,WAAW,SAAS,SAAS,QAAQ;CAC3C,MAAM,QAAQ,SAAS,SAAS,SAAS;CACzC,MAAM,MAAM,SAAS,SAAS,OAAO,KAAK;CAC1C,MAAM,eAAe,KAAK,UAAU,GAAG,KAAK;CAC5C,MAAM,aAAa,KAAK,UAAU,GAAG;CACrC,MAAM,eAAe,MAAM;CAC3B,OAAO,eAAe,SAAS,OAAO,YAAY,IAAI;AACxD;;AAGA,MAAa,sBAA+B,OAAO,UAAU;CAC3D,OAAO,OACH,SAAS,CAAC,CACX,QAAQ,UAAU,GAAG,CAAC,CACtB,QAAQ,SAAS,GAAG,CAAC,CACrB,QAAQ,SAAS,GAAG,CAAC,CACrB,QAAQ,WAAW,IAAG,CAAC,CACvB,QAAQ,WAAW,GAAG;AAC3B;;AAGA,MAAa,mBAA4B,OAAO,UAAU;CACxD,OAAO,MAAM,SAAS,CAAC,CAAC,QAAQ,cAAc,EAAE;AAClD;;AAGA,MAAa,0BAAmC,OAAO,UAAU;CAC/D,OAAO,MAAM,SAAS,CAAC,CAAC,QAAQ,iBAAiB,EAAE;AACrD;;AAGA,MAAa,uBAAgC,OAAO,UAAU;CAC5D,OAAO,MAAM,SAAS,CAAC,CAAC,QAAQ,UAAU,EAAE;AAC9C"}
|
|
1
|
+
{"version":3,"file":"string-mutators.mjs","names":[],"sources":["../../../../../../../../../seal/src/mutators/string-mutators.ts"],"sourcesContent":["import {\n capitalize,\n ltrim,\n readMoreChars,\n rtrim,\n toCamelCase,\n toKebabCase,\n toSnakeCase,\n toStudlyCase,\n trim,\n} from \"@mongez/reinforcements\";\nimport type { Mutator } from \"../types\";\n\n/** Convert string to lowercase */\nexport const lowercaseMutator: Mutator = async (value) => {\n return value?.toString().toLowerCase();\n};\n\n/** Convert string to uppercase */\nexport const uppercaseMutator: Mutator = async (value) => {\n return value?.toString().toUpperCase();\n};\n\n/** Capitalize only the first letter of the string */\nexport const capitalizeMutator: Mutator = async (value) => {\n const str = value?.toString();\n return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();\n};\n\n/** Capitalize the first letter of each word (Title Case) */\nexport const titleCaseMutator: Mutator = async (value) => {\n return capitalize(value?.toString());\n};\n\n/** Convert value to string */\nexport const stringifyMutator: Mutator = async (value) => {\n if (!value && value !== 0) return \"\";\n // only convert numbers, boolean and strings\n\n // Handle strings (pass through)\n if (typeof value === \"string\") return value;\n\n // Handle scalar types (number, boolean)\n if (typeof value === \"number\" || typeof value === \"boolean\") {\n return String(value);\n }\n};\n\n/** Trim whitespace */\nexport const trimMutator: Mutator = async (value, context) => {\n return trim(value?.toString(), context?.options?.needle ?? \" \");\n};\n\n/**\n * Strip HTML tags with a naive `<...>` regex.\n *\n * This is a **tag stripper, not an XSS sanitizer**: it is not a parser, so\n * malformed/nested markup, attribute payloads, or content re-introduced\n * later in a pipeline can defeat it. Do not rely on this alone to make\n * untrusted rich text safe to render — use a real parser-based sanitizer\n * (e.g. DOMPurify / sanitize-html) for that.\n */\nexport const stripTagsMutator: Mutator = async (value) => {\n return value?.toString().replace(/<[^>]*>?/gm, \"\");\n};\n\n/**\n * @deprecated Renamed to {@link stripTagsMutator} — the old name implied\n * XSS safety this tag-stripping regex does not provide. Kept as an alias\n * for backward compatibility; switch to `stripTagsMutator`.\n */\nexport const safeHtmlMutator: Mutator = stripTagsMutator;\n\n/** HTML escape */\nexport const htmlEscapeMutator: Mutator = async (value) => {\n return value\n ?.toString()\n .replace(/&/g, \"&\")\n .replace(/</g, \"<\")\n .replace(/>/g, \">\")\n .replace(/\"/g, \""\")\n .replace(/'/g, \"'\");\n};\n\n/** Remove special characters */\nexport const removeSpecialCharactersMutator: Mutator = async (value) => {\n return value?.toString().replace(/[^a-zA-Z0-9]/g, \"\");\n};\n\n/** URL decode */\nexport const urlDecodeMutator: Mutator = async (value) => {\n return decodeURIComponent(value);\n};\n\n/** URL encode */\nexport const urlEncodeMutator: Mutator = async (value) => {\n return encodeURIComponent(value);\n};\n\n/** Convert to camelCase */\nexport const camelCaseMutator: Mutator = async (value) => {\n return toCamelCase(value?.toString());\n};\n\n/** Convert to PascalCase */\nexport const pascalCaseMutator: Mutator = async (value) => {\n return toStudlyCase(value?.toString());\n};\n\n/** Convert to snake_case */\nexport const snakeCaseMutator: Mutator = async (value) => {\n return toSnakeCase(value?.toString());\n};\n\n/** Convert to kebab-case */\nexport const kebabCaseMutator: Mutator = async (value) => {\n return toKebabCase(value?.toString());\n};\n\n/** Convert to URL-friendly slug */\nexport const slugMutator: Mutator = async (value) => {\n return value\n ?.toString()\n .toLowerCase()\n .trim()\n .replace(/[^\\w\\s-]/g, \"\")\n .replace(/[\\s_]+/g, \"-\")\n .replace(/--+/g, \"-\")\n .replace(/^-+|-+$/g, \"\");\n};\n\n/** Trim from the left/start */\nexport const ltrimMutator: Mutator = async (value, context) => {\n return ltrim(value?.toString(), context?.options?.needle ?? \" \");\n};\n\n/** Trim from the right/end */\nexport const rtrimMutator: Mutator = async (value, context) => {\n return rtrim(value?.toString(), context?.options?.needle ?? \" \");\n};\n\n/** Base64 encode */\nexport const base64EncodeMutator: Mutator = async (value) => {\n return Buffer.from(value?.toString()).toString(\"base64\");\n};\n\n/** Base64 decode */\nexport const base64DecodeMutator: Mutator = async (value) => {\n return Buffer.from(value?.toString(), \"base64\").toString(\"utf-8\");\n};\n\n/** Replace substring or pattern */\nexport const replaceMutator: Mutator = async (value, context) => {\n const { search, replace } = context?.options;\n if (!search) return value?.toString();\n return value?.toString().replace(search, replace ?? \"\");\n};\n\n/** Replace all occurrences of substring or pattern */\nexport const replaceAllMutator: Mutator = async (value, context) => {\n const { search, replace } = context?.options;\n if (!search) return value?.toString();\n const searchValue = typeof search === \"string\" ? new RegExp(search, \"g\") : search;\n return value?.toString().replace(searchValue, replace ?? \"\");\n};\n\n/** Append/suffix text to the end */\nexport const appendMutator: Mutator = async (value, context) => {\n const suffix = context?.options?.suffix ?? \"\";\n return value?.toString() + suffix;\n};\n\n/** Prepend/prefix text to the beginning */\nexport const prependMutator: Mutator = async (value, context) => {\n const prefix = context?.options?.prefix ?? \"\";\n return prefix + value?.toString();\n};\n\n/** Reverse the string */\nexport const reverseMutator: Mutator = async (value) => {\n return value?.toString().split(\"\").reverse().join(\"\");\n};\n\n/** Truncate to a maximum length */\nexport const truncateMutator: Mutator = async (value, context) => {\n const str = value?.toString();\n const maxLength = context?.options?.maxLength ?? 100;\n const suffix = context?.options?.suffix ?? \"...\";\n return readMoreChars(str, maxLength, suffix);\n};\n\n/** Trim multiple whitespace into single space */\nexport const trimMultipleWhitespaceMutator: Mutator = async (value) => {\n return value?.toString().replace(/\\s+/g, \" \");\n};\n\n/** Pad string from the start to reach target length */\nexport const padStartMutator: Mutator = async (value, context) => {\n const length = context?.options?.length ?? 0;\n const char = context?.options?.char ?? \" \";\n return value?.toString().padStart(length, char);\n};\n\n/** Pad string from the end to reach target length */\nexport const padEndMutator: Mutator = async (value, context) => {\n const length = context?.options?.length ?? 0;\n const char = context?.options?.char ?? \" \";\n return value?.toString().padEnd(length, char);\n};\n\n/** Repeat string N times */\nexport const repeatMutator: Mutator = async (value, context) => {\n const count = context?.options?.count ?? 1;\n return value?.toString()?.repeat(count);\n};\n\n/** Mask part of string */\nexport const maskMutator: Mutator = async (value, context) => {\n const str = value?.toString();\n const maskChar = context?.options?.char ?? \"*\";\n const start = context?.options?.start ?? 0;\n const end = context?.options?.end ?? str?.length;\n const visibleStart = str?.substring(0, start);\n const visibleEnd = str?.substring(end);\n const maskedLength = end - start;\n return visibleStart + maskChar.repeat(maskedLength) + visibleEnd;\n};\n\n/** Unescape HTML entities */\nexport const unescapeHtmlMutator: Mutator = async (value) => {\n return value\n ?.toString()\n .replace(/&/g, \"&\")\n .replace(/</g, \"<\")\n .replace(/>/g, \">\")\n .replace(/"/g, '\"')\n .replace(/'/g, \"'\");\n};\n\n/** Keep only alphabetic characters */\nexport const alphaOnlyMutator: Mutator = async (value) => {\n return value.toString().replace(/[^a-zA-Z]/g, \"\");\n};\n\n/** Keep only alphanumeric characters */\nexport const alphanumericOnlyMutator: Mutator = async (value) => {\n return value.toString().replace(/[^a-zA-Z0-9]/g, \"\");\n};\n\n/** Remove all numeric characters */\nexport const removeNumbersMutator: Mutator = async (value) => {\n return value.toString().replace(/[0-9]/g, \"\");\n};\n"],"mappings":";;;;;;;;;;;;;AAcA,MAAa,mBAA4B,OAAO,UAAU;CACxD,OAAO,OAAO,SAAS,CAAC,CAAC,YAAY;AACvC;;AAGA,MAAa,mBAA4B,OAAO,UAAU;CACxD,OAAO,OAAO,SAAS,CAAC,CAAC,YAAY;AACvC;;AAGA,MAAa,oBAA6B,OAAO,UAAU;CACzD,MAAM,MAAM,OAAO,SAAS;CAC5B,OAAO,IAAI,OAAO,CAAC,CAAC,CAAC,YAAY,IAAI,IAAI,MAAM,CAAC,CAAC,CAAC,YAAY;AAChE;;AAGA,MAAa,mBAA4B,OAAO,UAAU;CACxD,OAAO,WAAW,OAAO,SAAS,CAAC;AACrC;;AAGA,MAAa,mBAA4B,OAAO,UAAU;CACxD,IAAI,CAAC,SAAS,UAAU,GAAG,OAAO;CAIlC,IAAI,OAAO,UAAU,UAAU,OAAO;CAGtC,IAAI,OAAO,UAAU,YAAY,OAAO,UAAU,WAChD,OAAO,OAAO,KAAK;AAEvB;;AAGA,MAAa,cAAuB,OAAO,OAAO,YAAY;CAC5D,OAAO,KAAK,OAAO,SAAS,GAAG,SAAS,SAAS,UAAU,GAAG;AAChE;;;;;;;;;;AAWA,MAAa,mBAA4B,OA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AC/D,OAAO,MAAM,SAAS,CAAC,CAAC,QAAQ,iBAAiB,EAAE;AACrD;;AAGA,MAAa,uBAAgC,OAAO,UAAU;CAC5D,OAAO,MAAM,SAAS,CAAC,CAAC,QAAQ,UAAU,EAAE;AAC9C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array-rules.mjs","names":[],"sources":["../../../../../../../../../../seal/src/rules/array/array-rules.ts"],"sourcesContent":["import { invalidRule, VALID_RULE } from \"../../helpers\";\
|
|
1
|
+
{"version":3,"file":"array-rules.mjs","names":[],"sources":["../../../../../../../../../../seal/src/rules/array/array-rules.ts"],"sourcesContent":["import { invalidRule, VALID_RULE } from \"../../helpers\";\nimport type { SchemaRule } from \"../../types\";\n\n/**\n * Unique array rule - array must contain unique values\n */\nexport const uniqueArrayRule: SchemaRule = {\n name: \"uniqueArray\",\n description: \"The array must contain unique values\",\n defaultErrorMessage: \"The :input must contain unique values\",\n async validate(value: any, context) {\n const uniqueValues = new Set(value);\n\n if (uniqueValues.size === value.length) {\n return VALID_RULE;\n }\n\n return invalidRule(this, context);\n },\n};\n\n/**\n * Sorted array rule - array must be sorted\n */\nexport const sortedArrayRule: SchemaRule<{\n direction?: \"asc\" | \"desc\";\n}> = {\n name: \"sortedArray\",\n description: \"The array must be sorted\",\n defaultErrorMessage: \"The :input must be sorted\",\n async validate(value: any[], context) {\n if (!Array.isArray(value) || value.length <= 1) {\n return VALID_RULE;\n }\n\n const direction = this.context.options.direction ?? \"asc\";\n this.context.translatableParams.direction = direction;\n\n for (let i = 0; i < value.length - 1; i++) {\n const current = value[i];\n const next = value[i + 1];\n\n if (direction === \"asc\") {\n if (current > next) {\n return invalidRule(this, context);\n }\n } else {\n if (current < next) {\n return invalidRule(this, context);\n }\n }\n }\n\n return VALID_RULE;\n },\n};\n"],"mappings":";;;;;;;AAMA,MAAa,kBAA8B;CACzC,MAAM;CACN,aAAa;CACb,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAGlC,IAAI,IAFqB,IAAI,KAEd,CAAC,CAAC,SAAS,MAAM,QAC9B,OAAO;EAGT,OAAO,YAAY,MAAM,OAAO;CAClC;AACF;;;;AAKA,MAAa,kBAER;CACH,MAAM;CACN,aAAa;CACb,qBAAqB;CACrB,MAAM,SAAS,OAAc,SAAS;EACpC,IAAI,CAAC,MAAM,QAAQ,KAAK,KAAK,MAAM,UAAU,GAC3C,OAAO;EAGT,MAAM,YAAY,KAAK,QAAQ,QAAQ,aAAa;EACpD,KAAK,QAAQ,mBAAmB,YAAY;EAE5C,KAAK,IAAI,IAAI,GAAG,IAAI,MAAM,SAAS,GAAG,KAAK;GACzC,MAAM,UAAU,MAAM;GACtB,MAAM,OAAO,MAAM,IAAI;GAEvB,IAAI,cAAc,OAChB;QAAI,UAAU,MACZ,OAAO,YAAY,MAAM,OAAO;GAClC,OAEA,IAAI,UAAU,MACZ,OAAO,YAAY,MAAM,OAAO;EAGtC;EAEA,OAAO;CACT;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"color-rules.mjs","names":[],"sources":["../../../../../../../../../../seal/src/rules/color/color-rules.ts"],"sourcesContent":["import { invalidRule, VALID_RULE } from \"../../helpers\";\
|
|
1
|
+
{"version":3,"file":"color-rules.mjs","names":[],"sources":["../../../../../../../../../../seal/src/rules/color/color-rules.ts"],"sourcesContent":["import { invalidRule, VALID_RULE } from \"../../helpers\";\nimport type { SchemaRule } from \"../../types\";\n\n/**\n * Color validation regex patterns\n */\nconst colorValidationRegex = {\n hex: /^#([0-9a-f]{3}){1,2}$/i,\n rgb: /^rgb\\((\\d{1,3}),\\s*(\\d{1,3}),\\s*(\\d{1,3})\\)$/,\n rgba: /^rgba\\((\\d{1,3}),\\s*(\\d{1,3}),\\s*(\\d{1,3}),\\s*(0?\\.\\d+|1)\\)$/,\n hsl: /^hsl\\((\\d{1,3}),\\s*(\\d{1,3})%?,\\s*(\\d{1,3})%?\\)$/,\n};\n\n/**\n * Generic color rule - validates any color format\n */\nexport const colorRule: SchemaRule = {\n name: \"color\",\n defaultErrorMessage: \"The :input must be a valid color\",\n async validate(value: any, context) {\n const isValidColor =\n colorValidationRegex.hex.test(value) ||\n colorValidationRegex.rgb.test(value) ||\n colorValidationRegex.rgba.test(value) ||\n colorValidationRegex.hsl.test(value);\n\n if (isValidColor) {\n return VALID_RULE;\n }\n\n return invalidRule(this, context);\n },\n};\n\n/**\n * Hex color rule\n */\nexport const hexColorRule: SchemaRule = {\n name: \"hexColor\",\n defaultErrorMessage: \"The :input must be a valid hex color\",\n async validate(value: any, context) {\n if (colorValidationRegex.hex.test(value)) {\n return VALID_RULE;\n }\n return invalidRule(this, context);\n },\n};\n\n/**\n * RGB color rule\n */\nexport const rgbColorRule: SchemaRule = {\n name: \"rgbColor\",\n defaultErrorMessage: \"The :input must be a valid RGB color\",\n async validate(value: any, context) {\n if (colorValidationRegex.rgb.test(value)) {\n return VALID_RULE;\n }\n return invalidRule(this, context);\n },\n};\n\n/**\n * RGBA color rule\n */\nexport const rgbaColorRule: SchemaRule = {\n name: \"rgbaColor\",\n defaultErrorMessage: \"The :input must be a valid RGBA color\",\n async validate(value: any, context) {\n if (colorValidationRegex.rgba.test(value)) {\n return VALID_RULE;\n }\n return invalidRule(this, context);\n },\n};\n\n/**\n * HSL color rule\n */\nexport const hslColorRule: SchemaRule = {\n name: \"hslColor\",\n defaultErrorMessage: \"The :input must be a valid HSL color\",\n async validate(value: any, context) {\n if (colorValidationRegex.hsl.test(value)) {\n return VALID_RULE;\n }\n return invalidRule(this, context);\n },\n};\n\n/**\n * Light color rule\n */\nexport const lightColorRule: SchemaRule = {\n name: \"lightColor\",\n defaultErrorMessage: \"The :input must be a light color\",\n async validate(value: any, context) {\n if (!colorValidationRegex.hex.test(value)) {\n return invalidRule(this, context);\n }\n\n const hex = value.replace(\"#\", \"\");\n const r = parseInt(hex.substring(0, 2), 16);\n const g = parseInt(hex.substring(2, 4), 16);\n const b = parseInt(hex.substring(4, 6), 16);\n const brightness = (r * 299 + g * 587 + b * 114) / 1000;\n\n if (brightness > 155) {\n return VALID_RULE;\n }\n\n return invalidRule(this, context);\n },\n};\n\n/**\n * Dark color rule\n */\nexport const darkColorRule: SchemaRule = {\n name: \"darkColor\",\n defaultErrorMessage: \"The :input must be a dark color\",\n async validate(value: any, context) {\n if (!colorValidationRegex.hex.test(value)) {\n return invalidRule(this, context);\n }\n\n const hex = value.replace(\"#\", \"\");\n const r = parseInt(hex.substring(0, 2), 16);\n const g = parseInt(hex.substring(2, 4), 16);\n const b = parseInt(hex.substring(4, 6), 16);\n const brightness = (r * 299 + g * 587 + b * 114) / 1000;\n\n if (brightness <= 155) {\n return VALID_RULE;\n }\n\n return invalidRule(this, context);\n },\n};\n"],"mappings":";;;;;;;AAMA,MAAM,uBAAuB;CAC3B,KAAK;CACL,KAAK;CACL,MAAM;CACN,KAAK;AACP;;;;AAKA,MAAa,YAAwB;CACnC,MAAM;CACN,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAOlC,IALE,qBAAqB,IAAI,KAAK,KAAK,KACnC,qBAAqB,IAAI,KAAK,KAAK,KACnC,qBAAqB,KAAK,KAAK,KAAK,KACpC,qBAAqB,IAAI,KAAK,KAAK,GAGnC,OAAO;EAGT,OAAO,YAAY,MAAM,OAAO;CAClC;AACF;;;;AAKA,MAAa,eAA2B;CACtC,MAAM;CACN,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAClC,IAAI,qBAAqB,IAAI,KAAK,KAAK,GACrC,OAAO;EAET,OAAO,YAAY,MAAM,OAAO;CAClC;AACF;;;;AAKA,MAAa,eAA2B;CACtC,MAAM;CACN,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAClC,IAAI,qBAAqB,IAAI,KAAK,KAAK,GACrC,OAAO;EAET,OAAO,YAAY,MAAM,OAAO;CAClC;AACF;;;;AAKA,MAAa,gBAA4B;CACvC,MAAM;CACN,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EACl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AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enum.mjs","names":[],"sources":["../../../../../../../../../../seal/src/rules/common/enum.ts"],"sourcesContent":["import { invalidRule, resolveTranslation, VALID_RULE } from \"../../helpers\";\
|
|
1
|
+
{"version":3,"file":"enum.mjs","names":[],"sources":["../../../../../../../../../../seal/src/rules/common/enum.ts"],"sourcesContent":["import { invalidRule, resolveTranslation, VALID_RULE } from \"../../helpers\";\nimport type { SchemaRule } from \"../../types\";\n\n/**\n * Enum rule - value must be one of the enum values\n */\nexport const enumRule: SchemaRule<{ enum: any }> = {\n name: \"enum\",\n defaultErrorMessage: \"The :input must be one of the following values: :enum\",\n async validate(value: any, context) {\n const enumValues = this.context.options.enum;\n\n if (enumValues.includes(value)) {\n return VALID_RULE;\n }\n\n // Translate each enum value individually, then join into a display string\n this.context.translationParams.enum = enumValues\n .map((v: any) =>\n resolveTranslation({ key: String(v), rawValue: String(v), rule: this, context }),\n )\n .join(\", \");\n\n return invalidRule(this, context);\n },\n};\n\n/**\n * In rule - value must be in the given array\n */\nexport const inRule: SchemaRule<{ values: any[] }> = {\n name: \"in\",\n defaultErrorMessage: \"The :input must be one of the following values: :values\",\n async validate(value: any, context) {\n if (this.context.options.values.includes(value)) {\n return VALID_RULE;\n }\n\n // Translate each value individually, then join\n this.context.translationParams.values = this.context.options.values\n .map((v: any) =>\n resolveTranslation({ key: String(v), rawValue: String(v), rule: this, context }),\n )\n .join(\", \");\n\n return invalidRule(this, context);\n },\n};\n\n/**\n * Allowed values rule - value must be one of allowed values\n */\nexport const allowedValuesRule: SchemaRule<{ allowedValues: any[] }> = {\n name: \"allowedValues\",\n defaultErrorMessage: \"The :input must be one of the allowed values\",\n async validate(value: any, context) {\n if (this.context.options.allowedValues.includes(value)) {\n return VALID_RULE;\n }\n\n // Translate each value individually, then join\n this.context.translationParams.allowedValues = this.context.options.allowedValues\n .map((v: any) =>\n resolveTranslation({ key: String(v), rawValue: String(v), rule: this, context }),\n )\n .join(\", \");\n\n return invalidRule(this, context);\n },\n};\n\n/**\n * Not allowed values rule - value must not be in forbidden list\n */\nexport const notAllowedValuesRule: SchemaRule<{ notAllowedValues: any[] }> = {\n name: \"notAllowedValues\",\n defaultErrorMessage: \"The :input contains a forbidden value\",\n async validate(value: any, context) {\n if (!this.context.options.notAllowedValues.includes(value)) {\n return VALID_RULE;\n }\n\n // Translate each value individually, then join\n this.context.translationParams.notAllowedValues = this.context.options.notAllowedValues\n .map((v: any) =>\n resolveTranslation({ key: String(v), rawValue: String(v), rule: this, context }),\n )\n .join(\", \");\n\n return invalidRule(this, context);\n },\n};\n"],"mappings":";;;;;;;AAMA,MAAa,WAAsC;CACjD,MAAM;CACN,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAClC,MAAM,aAAa,KAAK,QAAQ,QAAQ;EAExC,IAAI,WAAW,SAAS,KAAK,GAC3B,OAAO;EAIT,KAAK,QAAQ,kBAAkB,OAAO,WACnC,KAAK,MACJ,mBAAmB;GAAE,KAAK,OAAO,CAAC;GAAG,UAAU,OAAO,CAAC;GAAG,MAAM;GAAM;EAAQ,CAAC,CACjF,CAAC,CACA,KAAK,IAAI;EAEZ,OAAO,YAAY,MAAM,OAAO;CAClC;AACF;;;;AAKA,MAAa,SAAwC;CACnD,MAAM;CACN,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAClC,IAAI,KAAK,QAAQ,QAAQ,OAAO,SAAS,KAAK,GAC5C,OAAO;EAIT,KAAK,QAAQ,kBAAkB,SAAS,KAAK,QAAQ,QAAQ,OAC1D,KAAK,MACJ,mBAAmB;GAAE,KAAK,OAAO,CAAC;GAAG,UAAU,OAAO,CAAC;GAAG,MAAM;GAAM;EAAQ,CAAC,CACjF,CAAC,CACA,KAAK,IAAI;EAEZ,OAAO,YAAY,MAAM,OAAO;CAClC;AACF;;;;AAKA,MAAa,oBAA0D;CACrE,MAAM;CACN,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAClC,IAAI,KAAK,QAAQ,QAAQ,cAAc,SAAS,KAAK,GACnD,OAAO;EAIT,KAAK,QAAQ,kBAAkB,gBAAgB,KAAK,QAAQ,QAAQ,cACjE,KAAK,MACJ,mBAAmB;GAAE,KAAK,OAAO,CAAC;GAAG,UAAU,OAAO,CAAC;GAAG,MAAM;GAAM;EAAQ,CAAC,CACjF,CAAC,CACA,KAAK,IAAI;EAEZ,OAAO,YAAY,MAAM,OAAO;CAClC;AACF;;;;AAKA,MAAa,uBAAgE;CAC3E,MAAM;CACN,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAClC,IAAI,CAAC,KAAK,QAAQ,QAAQ,iBAAiB,SAAS,KAAK,GACvD,OAAO;EAIT,KAAK,QAAQ,kBAAkB,mBAAmB,KAAK,QAAQ,QAAQ,iBACpE,KAAK,MACJ,mBAAmB;GAAE,KAAK,OAAO,CAAC;GAAG,UAAU,OAAO,CAAC;GAAG,MAAM;GAAM;EAAQ,CAAC,CACjF,CAAC,CACA,KAAK,IAAI;EAEZ,OAAO,YAAY,MAAM,OAAO;CAClC;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"equals-field-rules.mjs","names":[],"sources":["../../../../../../../../../../seal/src/rules/common/equals-field-rules.ts"],"sourcesContent":["import { getFieldValue, invalidRule, VALID_RULE } from \"../../helpers\";\
|
|
1
|
+
{"version":3,"file":"equals-field-rules.mjs","names":[],"sources":["../../../../../../../../../../seal/src/rules/common/equals-field-rules.ts"],"sourcesContent":["import { getFieldValue, invalidRule, VALID_RULE } from \"../../helpers\";\nimport type { SchemaRule } from \"../../types\";\n\n/**\n * Equals field rule - value must equal another field's value\n * Supports both global and sibling scope\n */\nexport const equalsFieldRule: SchemaRule<{\n field: string;\n scope?: \"global\" | \"sibling\";\n}> = {\n name: \"equalsField\",\n description: \"The value must equal another field's value\",\n sortOrder: -1,\n requiresValue: true,\n defaultErrorMessage: \"The :input must match the :field field\",\n async validate(value: any, context) {\n const fieldValue = getFieldValue(this, context);\n\n // Value must equal the other field's value\n if (value !== fieldValue) {\n this.context.translatableParams.field = this.context.options.field;\n return invalidRule(this, context);\n }\n\n return VALID_RULE;\n },\n};\n\n/**\n * Not equals field rule - value must NOT equal another field's value\n * Supports both global and sibling scope\n */\nexport const notEqualsFieldRule: SchemaRule<{\n field: string;\n scope?: \"global\" | \"sibling\";\n}> = {\n name: \"notEqualsField\",\n description: \"The value must NOT equal another field's value\",\n sortOrder: -1,\n requiresValue: true,\n defaultErrorMessage: \"The :input must not match the :field field\",\n async validate(value: any, context) {\n const fieldValue = getFieldValue(this, context);\n\n // Value must NOT equal the other field's value\n if (value === fieldValue) {\n return invalidRule(this, context);\n }\n\n return VALID_RULE;\n },\n};\n"],"mappings":";;;;;;;;;AAOA,MAAa,kBAGR;CACH,MAAM;CACN,aAAa;CACb,WAAW;CACX,eAAe;CACf,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAIlC,IAAI,UAHe,cAAc,MAAM,OAGhB,GAAG;GACxB,KAAK,QAAQ,mBAAmB,QAAQ,KAAK,QAAQ,QAAQ;GAC7D,OAAO,YAAY,MAAM,OAAO;EAClC;EAEA,OAAO;CACT;AACF;;;;;AAMA,MAAa,qBAGR;CACH,MAAM;CACN,aAAa;CACb,WAAW;CACX,eAAe;CACf,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAIlC,IAAI,UAHe,cAAc,MAAM,OAGhB,GACrB,OAAO,YAAY,MAAM,OAAO;EAGlC,OAAO;CACT;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type-rules.mjs","names":[],"sources":["../../../../../../../../../../seal/src/rules/common/type-rules.ts"],"sourcesContent":["import { isObject, isPlainObject } from \"@mongez/supportive-is\";\
|
|
1
|
+
{"version":3,"file":"type-rules.mjs","names":[],"sources":["../../../../../../../../../../seal/src/rules/common/type-rules.ts"],"sourcesContent":["import { isObject, isPlainObject } from \"@mongez/supportive-is\";\nimport { invalidRule, VALID_RULE } from \"../../helpers\";\nimport type { SchemaRule } from \"../../types\";\n\n/**\n * String rule - validates string type\n */\nexport const stringRule: SchemaRule = {\n name: \"string\",\n defaultErrorMessage: \"The :input must be a string\",\n async validate(value: any, context) {\n if (typeof value === \"string\") {\n return VALID_RULE;\n }\n return invalidRule(this, context);\n },\n};\n\n/**\n * Number rule - validates number type\n */\nexport const numberRule: SchemaRule = {\n name: \"number\",\n defaultErrorMessage: \"The :input must be a number\",\n async validate(value: any, context) {\n if (typeof value === \"number\") {\n return VALID_RULE;\n }\n return invalidRule(this, context);\n },\n};\n\n/**\n * Boolean rule - validates boolean type\n */\nexport const booleanRule: SchemaRule = {\n name: \"boolean\",\n defaultErrorMessage: \"The :input must be a boolean\",\n async validate(value: any, context) {\n if (typeof value === \"boolean\") {\n return VALID_RULE;\n }\n return invalidRule(this, context);\n },\n};\n\n/**\n * Int rule - validates integer type\n */\nexport const intRule: SchemaRule = {\n name: \"int\",\n defaultErrorMessage: \"The :input must be an integer\",\n async validate(value: any, context) {\n if (Number.isInteger(value)) {\n return VALID_RULE;\n }\n return invalidRule(this, context);\n },\n};\n\n/**\n * Float rule - validates float type\n */\nexport const floatRule: SchemaRule = {\n name: \"float\",\n defaultErrorMessage: \"The :input must be a float\",\n async validate(value: any, context) {\n if (Number.isFinite(value) && !Number.isInteger(value)) {\n return VALID_RULE;\n }\n return invalidRule(this, context);\n },\n};\n\n/**\n * Scalar rule - validates scalar value (string, number, or boolean)\n */\nexport const scalarRule: SchemaRule = {\n name: \"scalar\",\n defaultErrorMessage: \"The :input must be a scalar value\",\n async validate(value: any, context) {\n if ([\"string\", \"number\", \"boolean\"].includes(typeof value)) {\n return VALID_RULE;\n }\n return invalidRule(this, context);\n },\n};\n\n/**\n * Object rule - validates object type\n */\nexport const objectRule: SchemaRule = {\n name: \"object\",\n defaultErrorMessage: \"The :input must be an object\",\n async validate(value: any, context) {\n if (!!isObject(value) && value !== null) {\n return VALID_RULE;\n }\n\n return invalidRule(this, context);\n },\n};\n\n/**\n * Object rule - validates object type\n */\nexport const plainObjectRule: SchemaRule = {\n name: \"plainObject\",\n defaultErrorMessage: \"The :input must be an object\",\n async validate(value: any, context) {\n if (!!isPlainObject(value) && value !== null) {\n return VALID_RULE;\n }\n\n return invalidRule(this, context);\n },\n};\n\n/**\n * Array rule - validates array type\n */\nexport const arrayRule: SchemaRule = {\n name: \"array\",\n defaultErrorMessage: \"The :input must be an array\",\n async validate(value: any, context) {\n if (Array.isArray(value)) {\n return VALID_RULE;\n }\n\n return invalidRule(this, context);\n },\n};\n"],"mappings":";;;;;;;;AAOA,MAAa,aAAyB;CACpC,MAAM;CACN,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAClC,IAAI,OAAO,UAAU,UACnB,OAAO;EAET,OAAO,YAAY,MAAM,OAAO;CAClC;AACF;;;;AAKA,MAAa,aAAyB;CACpC,MAAM;CACN,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAClC,IAAI,OAAO,UAAU,UACnB,OAAO;EAET,OAAO,YAAY,MAAM,OAAO;CAClC;AACF;;;;AAKA,MAAa,cAA0B;CACrC,MAAM;CACN,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAClC,IAAI,OAAO,UAAU,WACnB,OAAO;EAET,OAAO,YAAY,MAAM,OAAO;CAClC;AACF;;;;AAKA,MAAa,UAAsB;CACjC,MAAM;CACN,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAClC,IAAI,OAAO,UAAU,KAAK,GACxB,OAAO;EAET,OAAO,YAAY,MAAM,OAAO;CAClC;AACF;;;;AAKA,MAAa,YAAwB;CACnC,MAAM;CACN,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAClC,IAAI,OAAO,SAAS,KAAK,KAAK,CAAC,OAAO,UAAU,KAAK,GACnD,OAAO;EAET,OAAO,YAAY,MAAM,OAAO;CAClC;AACF;;;;AAmBA,MAAa,aAAyB;CACpC,MAAM;CACN,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAClC,IAAI,CAAC,CAAC,SAAS,KAAK,KAAK,UAAU,MACjC,OAAO;EAGT,OAAO,YAAY,MAAM,OAAO;CAClC;AACF;;;;AAKA,MAAa,kBAA8B;CACzC,MAAM;CACN,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAClC,IAAI,CAAC,CAAC,cAAc,KAAK,KAAK,UAAU,MACtC,OAAO;EAGT,OAAO,YAAY,MAAM,OAAO;CAClC;AACF;;;;AAKA,MAAa,YAAwB;CACnC,MAAM;CACN,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAClC,IAAI,MAAM,QAAQ,KAAK,GACrB,OAAO;EAGT,OAAO,YAAY,MAAM,OAAO;CAClC;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"forbidden-if-rules.mjs","names":[],"sources":["../../../../../../../../../../seal/src/rules/conditional/forbidden-if-rules.ts"],"sourcesContent":["import { getFieldValue, invalidRule, VALID_RULE } from \"../../helpers\";\
|
|
1
|
+
{"version":3,"file":"forbidden-if-rules.mjs","names":[],"sources":["../../../../../../../../../../seal/src/rules/conditional/forbidden-if-rules.ts"],"sourcesContent":["import { getFieldValue, invalidRule, VALID_RULE } from \"../../helpers\";\nimport { isEmptyValue } from \"../../helpers/is-empty-value\";\nimport type { SchemaRule } from \"../../types\";\n\n/**\n * Forbidden if rule - field is forbidden if another field equals a specific value\n * Supports both global and sibling scope\n */\nexport const forbiddenIfRule: SchemaRule<{\n field: string;\n value: any;\n scope?: \"global\" | \"sibling\";\n}> = {\n name: \"forbiddenIf\",\n description: \"The field is forbidden if another field equals a specific value\",\n sortOrder: -2,\n defaultErrorMessage: \"The :input is forbidden\",\n async validate(value: any, context) {\n const { value: expectedValue } = this.context.options;\n const fieldValue = getFieldValue(this, context);\n\n // Field is forbidden if it has a value and the other field equals the expected value\n if (!isEmptyValue(value) && fieldValue === expectedValue) {\n this.context.translatableParams.field = this.context.options.field;\n this.context.translationParams.value = expectedValue;\n return invalidRule(this, context);\n }\n\n return VALID_RULE;\n },\n};\n\n/**\n * Forbidden if not rule - field is forbidden if another field does NOT equal a specific value\n * Supports both global and sibling scope\n */\nexport const forbiddenIfNotRule: SchemaRule<{\n field: string;\n value: any;\n scope?: \"global\" | \"sibling\";\n}> = {\n name: \"forbiddenIfNot\",\n description: \"The field is forbidden if another field does NOT equal a specific value\",\n sortOrder: -2,\n defaultErrorMessage: \"The :input is forbidden\",\n async validate(value: any, context) {\n const { value: expectedValue } = this.context.options;\n const fieldValue = getFieldValue(this, context);\n\n // Field is forbidden if it has a value and the other field does NOT equal the expected value\n if (!isEmptyValue(value) && fieldValue !== expectedValue) {\n return invalidRule(this, context);\n }\n\n return VALID_RULE;\n },\n};\n\n/**\n * Forbidden if empty rule - field is forbidden if another field is empty\n * Supports both global and sibling scope\n */\nexport const forbiddenIfEmptyRule: SchemaRule<{\n field: string;\n scope?: \"global\" | \"sibling\";\n}> = {\n name: \"forbiddenIfEmpty\",\n description: \"The field is forbidden if another field is empty\",\n sortOrder: -2,\n defaultErrorMessage: \"The :input is forbidden\",\n async validate(value: any, context) {\n const fieldValue = getFieldValue(this, context);\n\n // Field is forbidden if it has a value and the other field is empty\n if (!isEmptyValue(value) && isEmptyValue(fieldValue)) {\n return invalidRule(this, context);\n }\n\n return VALID_RULE;\n },\n};\n\n/**\n * Forbidden if not empty rule - field is forbidden if another field is not empty\n * Supports both global and sibling scope\n */\nexport const forbiddenIfNotEmptyRule: SchemaRule<{\n field: string;\n scope?: \"global\" | \"sibling\";\n}> = {\n name: \"forbiddenIfNotEmpty\",\n description: \"The field is forbidden if another field is not empty\",\n sortOrder: -2,\n defaultErrorMessage: \"The :input is forbidden\",\n async validate(value: any, context) {\n const fieldValue = getFieldValue(this, context);\n\n // Field is forbidden if it has a value and the other field is not empty\n if (!isEmptyValue(value) && !isEmptyValue(fieldValue)) {\n return invalidRule(this, context);\n }\n\n return VALID_RULE;\n },\n};\n\n/**\n * Forbidden if in rule - field is forbidden if another field's value is in the given array\n * Supports both global and sibling scope\n */\nexport const forbiddenIfInRule: SchemaRule<{\n field: string;\n values: any[];\n scope?: \"global\" | \"sibling\";\n}> = {\n name: \"forbiddenIfIn\",\n description: \"The field is forbidden if another field's value is in the given array\",\n sortOrder: -2,\n defaultErrorMessage: \"The :input is forbidden\",\n async validate(value: any, context) {\n const { values } = this.context.options;\n const fieldValue = getFieldValue(this, context);\n\n // Field is forbidden if it has a value and the other field's value is in the array\n if (!isEmptyValue(value) && values.includes(fieldValue)) {\n this.context.translationParams.values = values.join(\", \");\n this.context.translatableParams.field = this.context.options.field;\n return invalidRule(this, context);\n }\n\n return VALID_RULE;\n },\n};\n\n/**\n * Forbidden if not in rule - field is forbidden if another field's value is NOT in the given array\n * Supports both global and sibling scope\n */\nexport const forbiddenIfNotInRule: SchemaRule<{\n field: string;\n values: any[];\n scope?: \"global\" | \"sibling\";\n}> = {\n name: \"forbiddenIfNotIn\",\n description: \"The field is forbidden if another field's value is NOT in the given array\",\n sortOrder: -2,\n defaultErrorMessage: \"The :input is forbidden\",\n async validate(value: any, context) {\n const { values } = this.context.options;\n const fieldValue = getFieldValue(this, context);\n\n // Field is forbidden if it has a value and the other field's value is NOT in the array\n if (!isEmptyValue(value) && !values.includes(fieldValue)) {\n this.context.translationParams.values = values.join(\", \");\n this.context.translatableParams.field = this.context.options.field;\n return invalidRule(this, context);\n }\n\n return VALID_RULE;\n },\n};\n"],"mappings":";;;;;;;;;;AAQA,MAAa,kBAIR;CACH,MAAM;CACN,aAAa;CACb,WAAW;CACX,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAClC,MAAM,EAAE,OAAO,kBAAkB,KAAK,QAAQ;EAC9C,MAAM,aAAa,cAAc,MAAM,OAAO;EAG9C,IAAI,CAAC,aAAa,KAAK,KAAK,eAAe,eAAe;GACxD,KAAK,QAAQ,mBAAmB,QAAQ,KAAK,QAAQ,QAAQ;GAC7D,KAAK,QAAQ,k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F;;;;;AAMA,MAAa,uBAIR;CACH,MAAM;CACN,aAAa;CACb,WAAW;CACX,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAClC,MAAM,EAAE,WAAW,KAAK,QAAQ;EAChC,MAAM,aAAa,cAAc,MAAM,OAAO;EAG9C,IAAI,CAAC,aAAa,KAAK,KAAK,CAAC,OAAO,SAAS,UAAU,GAAG;GACxD,KAAK,QAAQ,kBAAkB,SAAS,OAAO,KAAK,IAAI;GACxD,KAAK,QAAQ,mBAAmB,QAAQ,KAAK,QAAQ,QAAQ;GAC7D,OAAO,YAAY,MAAM,OAAO;EAClC;EAEA,OAAO;CACT;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"present-if-rules.mjs","names":[],"sources":["../../../../../../../../../../seal/src/rules/conditional/present-if-rules.ts"],"sourcesContent":["import { getFieldValue, invalidRule, VALID_RULE } from \"../../helpers\";\
|
|
1
|
+
{"version":3,"file":"present-if-rules.mjs","names":[],"sources":["../../../../../../../../../../seal/src/rules/conditional/present-if-rules.ts"],"sourcesContent":["import { getFieldValue, invalidRule, VALID_RULE } from \"../../helpers\";\nimport type { SchemaRule } from \"../../types\";\nimport { isEmptyValue } from \"./../../helpers/is-empty-value\";\n\n/**\n * Present if rule - field must be present if another field equals a specific value\n * Supports both global and sibling scope\n */\nexport const presentIfRule: SchemaRule<{\n field: string;\n value: any;\n scope?: \"global\" | \"sibling\";\n}> = {\n name: \"presentIf\",\n description: \"The field must be present if another field equals a specific value\",\n sortOrder: -2,\n requiresValue: false,\n defaultErrorMessage: \"The :input field must be present\",\n async validate(value: any, context) {\n const { value: expectedValue } = this.context.options;\n const fieldValue = getFieldValue(this, context);\n\n // Field must be present if the other field equals the expected value\n if (value === undefined && fieldValue === expectedValue) {\n this.context.translationParams.value = expectedValue;\n this.context.translatableParams.field = this.context.options.field;\n return invalidRule(this, context);\n }\n\n return VALID_RULE;\n },\n};\n\n/**\n * Present if empty rule - field must be present if another field is empty\n * Supports both global and sibling scope\n */\nexport const presentIfEmptyRule: SchemaRule<{\n field: string;\n scope?: \"global\" | \"sibling\";\n}> = {\n name: \"presentIfEmpty\",\n description: \"The field must be present if another field is empty\",\n sortOrder: -2,\n requiresValue: false,\n defaultErrorMessage: \"The :input field must be present\",\n async validate(value: any, context) {\n const fieldValue = getFieldValue(this, context);\n\n // Field must be present if the other field is empty\n if (value === undefined && isEmptyValue(fieldValue)) {\n return invalidRule(this, context);\n }\n\n return VALID_RULE;\n },\n};\n\n/**\n * Present if not empty rule - field must be present if another field is not empty\n * Supports both global and sibling scope\n */\nexport const presentIfNotEmptyRule: SchemaRule<{\n field: string;\n scope?: \"global\" | \"sibling\";\n}> = {\n name: \"presentIfNotEmpty\",\n description: \"The field must be present if another field is not empty\",\n sortOrder: -2,\n requiresValue: false,\n defaultErrorMessage: \"The :input field must be present\",\n async validate(value: any, context) {\n const fieldValue = getFieldValue(this, context);\n\n // Field must be present if the other field is not empty\n if (value === undefined && !isEmptyValue(fieldValue)) {\n return invalidRule(this, context);\n }\n\n return VALID_RULE;\n },\n};\n\n/**\n * Present if in rule - field must be present if another field's value is in the given array\n * Supports both global and sibling scope\n */\nexport const presentIfInRule: SchemaRule<{\n field: string;\n values: any[];\n scope?: \"global\" | \"sibling\";\n}> = {\n name: \"presentIfIn\",\n description: \"The field must be present if another field's value is in the given array\",\n sortOrder: -2,\n requiresValue: false,\n defaultErrorMessage: \"The :input field must be present\",\n async validate(value: any, context) {\n const { values } = this.context.options;\n const fieldValue = getFieldValue(this, context);\n\n // Field must be present if the other field's value is in the array\n if (value === undefined && values.includes(fieldValue)) {\n return invalidRule(this, context);\n }\n\n return VALID_RULE;\n },\n};\n\n/**\n * Present if not in rule - field must be present if another field's value is NOT in the given array\n * Supports both global and sibling scope\n */\nexport const presentIfNotInRule: SchemaRule<{\n field: string;\n values: any[];\n scope?: \"global\" | \"sibling\";\n}> = {\n name: \"presentIfNotIn\",\n description: \"The field must be present if another field's value is NOT in the given array\",\n sortOrder: -2,\n requiresValue: false,\n defaultErrorMessage: \"The :input field must be present\",\n async validate(value: any, context) {\n const { values } = this.context.options;\n const fieldValue = getFieldValue(this, context);\n\n // Field must be present if the other field's value is NOT in the array\n if (value === undefined && !values.includes(fieldValue)) {\n return invalidRule(this, context);\n }\n\n return VALID_RULE;\n },\n};\n"],"mappings":";;;;;;;;;;AAQA,MAAa,gBAIR;CACH,MAAM;CACN,aAAa;CACb,WAAW;CACX,eAAe;CACf,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAClC,MAAM,EAAE,OAAO,kBAAkB,KAAK,QAAQ;EAC9C,MAAM,aAAa,cAAc,MAAM,OAAO;EAG9C,IAAI,UAAU,UAAa,eAAe,eAAe;GACvD,KAAK,QAAQ,kBAAkB,QAAQ;GACvC,KAAK,QAAQ,mBAAmB,QAAQ,KAAK,QAAQ,QAAQ;GAC7D,OAAO,YAAY,MAAM,OAAO;EAClC;EAEA,OAAO;CACT;AACF;;;;;AAMA,MAAa,qBAGR;CACH,MAAM;CACN,aAAa;CACb,WAAW;CACX,eAAe;CACf,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAClC,MAAM,aAAa,cAAc,MAAM,OAAO;EAG9C,IAAI,UAAU,UAAa,aAAa,UAAU,GAChD,OAAO,YAAY,MAAM,OAAO;EAGlC,OAAO;CACT;AACF;;;;;AAMA,MAAa,wBAGR;CACH,MAAM;CACN,aAAa;CACb,WAAW;CACX,eAAe;CACf,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAClC,MAAM,aAAa,cAAc,MAAM,OAAO;EAG9C,IAAI,UAAU,UAAa,CAAC,aAAa,UAAU,GACjD,OAAO,YAAY,MAAM,OAAO;EAGlC,OAAO;CACT;AACF;;;;;AAMA,MAAa,kBAIR;CACH,MAAM;CACN,aAAa;CACb,WAAW;CACX,eAAe;CACf,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAClC,MAAM,EAAE,WAAW,KAAK,QAAQ;EAChC,MAAM,aAAa,cAAc,MAAM,OAAO;EAG9C,IAAI,UAAU,UAAa,OAAO,SAAS,UAAU,GACnD,OAAO,YAAY,MAAM,OAAO;EAGlC,OAAO;CACT;AACF;;;;;AAMA,MAAa,qBAIR;CACH,MAAM;CACN,aAAa;CACb,WAAW;CACX,eAAe;CACf,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAClC,MAAM,EAAE,WAAW,KAAK,QAAQ;EAChC,MAAM,aAAa,cAAc,MAAM,OAAO;EAG9C,IAAI,UAAU,UAAa,CAAC,OAAO,SAAS,UAAU,GACpD,OAAO,YAAY,MAAM,OAAO;EAGlC,OAAO;CACT;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"present-unless-rules.mjs","names":[],"sources":["../../../../../../../../../../seal/src/rules/conditional/present-unless-rules.ts"],"sourcesContent":["import { getFieldValue, invalidRule, VALID_RULE } from \"../../helpers\";\
|
|
1
|
+
{"version":3,"file":"present-unless-rules.mjs","names":[],"sources":["../../../../../../../../../../seal/src/rules/conditional/present-unless-rules.ts"],"sourcesContent":["import { getFieldValue, invalidRule, VALID_RULE } from \"../../helpers\";\nimport type { SchemaRule } from \"../../types\";\n\n/**\n * Present unless rule - field must be present unless another field equals a specific value\n * Supports both global and sibling scope\n */\nexport const presentUnlessRule: SchemaRule<{\n field: string;\n value: any;\n scope?: \"global\" | \"sibling\";\n}> = {\n name: \"presentUnless\",\n description: \"The field must be present unless another field equals a specific value\",\n sortOrder: -2,\n requiresValue: false,\n defaultErrorMessage: \"The :input field must be present\",\n async validate(value: any, context) {\n const { value: expectedValue } = this.context.options;\n const fieldValue = getFieldValue(this, context);\n\n // Field must be present unless the other field equals the expected value\n if (value === undefined && fieldValue !== expectedValue) {\n this.context.translationParams.value = expectedValue;\n this.context.translatableParams.field = this.context.options.field;\n return invalidRule(this, context);\n }\n\n return VALID_RULE;\n },\n};\n"],"mappings":";;;;;;;;;AAOA,MAAa,oBAIR;CACH,MAAM;CACN,aAAa;CACb,WAAW;CACX,eAAe;CACf,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAClC,MAAM,EAAE,OAAO,kBAAkB,KAAK,QAAQ;EAC9C,MAAM,aAAa,cAAc,MAAM,OAAO;EAG9C,IAAI,UAAU,UAAa,eAAe,eAAe;GACvD,KAAK,QAAQ,kBAAkB,QAAQ;GACvC,KAAK,QAAQ,mBAAmB,QAAQ,KAAK,QAAQ,QAAQ;GAC7D,OAAO,YAAY,MAAM,OAAO;EAClC;EAEA,OAAO;CACT;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"present-with-rules.mjs","names":[],"sources":["../../../../../../../../../../seal/src/rules/conditional/present-with-rules.ts"],"sourcesContent":["import { get } from \"@mongez/reinforcements\";\
|
|
1
|
+
{"version":3,"file":"present-with-rules.mjs","names":[],"sources":["../../../../../../../../../../seal/src/rules/conditional/present-with-rules.ts"],"sourcesContent":["import { get } from \"@mongez/reinforcements\";\nimport { getFieldValue, invalidRule, VALID_RULE } from \"../../helpers\";\nimport type { SchemaRule } from \"../../types\";\n\n/**\n * Present with rule - field must be present if another field is present\n * Supports both global and sibling scope\n */\nexport const presentWithRule: SchemaRule<{\n field: string;\n scope?: \"global\" | \"sibling\";\n}> = {\n name: \"presentWith\",\n description: \"The field must be present if another field is present\",\n sortOrder: -2,\n requiresValue: false,\n defaultErrorMessage: \"The :input field must be present\",\n async validate(value: any, context) {\n const fieldValue = getFieldValue(this, context);\n\n // The field must be present if the other field is present\n if (value === undefined && fieldValue !== undefined) {\n this.context.translatableParams.field = this.context.options.field;\n return invalidRule(this, context);\n }\n\n return VALID_RULE;\n },\n};\n\n/**\n * Present with all rule - field must be present if all specified fields are present\n * Supports both global and sibling scope\n */\nexport const presentWithAllRule: SchemaRule<{\n fields: string[];\n scope?: \"global\" | \"sibling\";\n}> = {\n name: \"presentWithAll\",\n description: \"The field must be present if all specified fields are present\",\n sortOrder: -2,\n requiresValue: false,\n defaultErrorMessage: \"The :input field must be present\",\n async validate(value: any, context) {\n const { fields, scope = \"global\" } = this.context.options;\n const source = scope === \"sibling\" ? context.parent : context.allValues;\n\n // Check if all fields are present\n const allPresent = fields.every((field) => get(source, field) !== undefined);\n\n // Field must be present if all other fields are present\n if (value === undefined && allPresent) {\n fields.forEach((field) => {\n this.context.translatableParams.field = field;\n });\n\n return invalidRule(this, context);\n }\n\n return VALID_RULE;\n },\n};\n\n/**\n * Present with any rule - field must be present if any of the specified fields is present\n * Supports both global and sibling scope\n */\nexport const presentWithAnyRule: SchemaRule<{\n fields: string[];\n scope?: \"global\" | \"sibling\";\n}> = {\n name: \"presentWithAny\",\n description: \"The field must be present if any of the specified fields is present\",\n sortOrder: -2,\n requiresValue: false,\n defaultErrorMessage: \"The :input field must be present\",\n async validate(value: any, context) {\n const { fields, scope = \"global\" } = this.context.options;\n const source = scope === \"sibling\" ? context.parent : context.allValues;\n\n // Check if any field is present\n const anyPresent = fields.some((field) => get(source, field) !== undefined);\n\n // Field must be present if any other field is present\n if (value === undefined && anyPresent) {\n fields.forEach((field) => {\n this.context.translatableParams.field = field;\n });\n\n return invalidRule(this, context);\n }\n\n return VALID_RULE;\n },\n};\n"],"mappings":";;;;;;;;;;;AAQA,MAAa,kBAGR;CACH,MAAM;CACN,aAAa;CACb,WAAW;CACX,eAAe;CACf,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAClC,MAAM,aAAa,cAAc,MAAM,OAAO;EAG9C,IAAI,UAAU,UAAa,eAAe,QAAW;GACnD,KAAK,QAAQ,mBAAmB,QAAQ,KAAK,QAAQ,QAAQ;GAC7D,OAAO,YAAY,MAAM,OAAO;EAClC;EAEA,OAAO;CACT;AACF;;;;;AAMA,MAAa,qBAGR;CACH,MAAM;CACN,aAAa;CACb,WAAW;CACX,eAAe;CACf,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAClC,MAAM,EAAE,QAAQ,QAAQ,aAAa,KAAK,QAAQ;EAClD,MAAM,SAAS,UAAU,YAAY,QAAQ,SAAS,QAAQ;EAG9D,MAAM,aAAa,OAAO,OAAO,UAAU,IAAI,QAAQ,KAAK,MAAM,MAAS;EAG3E,IAAI,UAAU,UAAa,YAAY;GACrC,OAAO,SAAS,UAAU;IACxB,KAAK,QAAQ,mBAAmB,QAAQ;GAC1C,CAAC;GAED,OAAO,YAAY,MAAM,OAAO;EAClC;EAEA,OAAO;CACT;AACF;;;;;AAMA,MAAa,qBAGR;CACH,MAAM;CACN,aAAa;CACb,WAAW;CACX,eAAe;CACf,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAClC,MAAM,EAAE,QAAQ,QAAQ,aAAa,KAAK,QAAQ;EAClD,MAAM,SAAS,UAAU,YAAY,QAAQ,SAAS,QAAQ;EAG9D,MAAM,aAAa,OAAO,MAAM,UAAU,IAAI,QAAQ,KAAK,MAAM,MAAS;EAG1E,IAAI,UAAU,UAAa,YAAY;GACrC,OAAO,SAAS,UAAU;IACxB,KAAK,QAAQ,mBAAmB,QAAQ;GAC1C,CAAC;GAED,OAAO,YAAY,MAAM,OAAO;EAClC;EAEA,OAAO;CACT;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"present-without-rules.mjs","names":[],"sources":["../../../../../../../../../../seal/src/rules/conditional/present-without-rules.ts"],"sourcesContent":["import { get } from \"@mongez/reinforcements\";\
|
|
1
|
+
{"version":3,"file":"present-without-rules.mjs","names":[],"sources":["../../../../../../../../../../seal/src/rules/conditional/present-without-rules.ts"],"sourcesContent":["import { get } from \"@mongez/reinforcements\";\nimport { getFieldValue, invalidRule, VALID_RULE } from \"../../helpers\";\nimport type { SchemaRule } from \"../../types\";\n\n/**\n * Present without rule - field must be present if another field is missing\n * Supports both global and sibling scope\n */\nexport const presentWithoutRule: SchemaRule<{\n field: string;\n scope?: \"global\" | \"sibling\";\n}> = {\n name: \"presentWithout\",\n description: \"The field must be present if another field is missing\",\n sortOrder: -2,\n requiresValue: false,\n defaultErrorMessage: \"The :input field must be present\",\n async validate(value: any, context) {\n const fieldValue = getFieldValue(this, context);\n\n // Field must be present if the other field is missing\n if (value === undefined && fieldValue === undefined) {\n this.context.translatableParams.field = this.context.options.field;\n return invalidRule(this, context);\n }\n\n return VALID_RULE;\n },\n};\n\n/**\n * Present without all rule - field must be present if all specified fields are missing\n * Supports both global and sibling scope\n */\nexport const presentWithoutAllRule: SchemaRule<{\n fields: string[];\n scope?: \"global\" | \"sibling\";\n}> = {\n name: \"presentWithoutAll\",\n description: \"The field must be present if all specified fields are missing\",\n sortOrder: -2,\n requiresValue: false,\n defaultErrorMessage: \"The :input field must be present\",\n async validate(value: any, context) {\n const { fields, scope = \"global\" } = this.context.options;\n const source = scope === \"sibling\" ? context.parent : context.allValues;\n\n // Check if all fields are missing\n const allMissing = fields.every((field) => get(source, field) === undefined);\n\n // Field must be present if all other fields are missing\n if (value === undefined && allMissing) {\n fields.forEach((field) => {\n this.context.translatableParams.field = field;\n });\n\n return invalidRule(this, context);\n }\n\n return VALID_RULE;\n },\n};\n\n/**\n * Present without any rule - field must be present if any of the specified fields is missing\n * Supports both global and sibling scope\n */\nexport const presentWithoutAnyRule: SchemaRule<{\n fields: string[];\n scope?: \"global\" | \"sibling\";\n}> = {\n name: \"presentWithoutAny\",\n description: \"The field must be present if any of the specified fields is missing\",\n sortOrder: -2,\n requiresValue: false,\n defaultErrorMessage: \"The :input field must be present\",\n async validate(value: any, context) {\n const { fields, scope = \"global\" } = this.context.options;\n const source = scope === \"sibling\" ? context.parent : context.allValues;\n\n // Check if any field is missing\n const anyMissing = fields.some((field) => get(source, field) === undefined);\n\n // Field must be present if any other field is missing\n if (value === undefined && anyMissing) {\n fields.forEach((field) => {\n this.context.translatableParams.field = field;\n });\n\n return invalidRule(this, context);\n }\n\n return VALID_RULE;\n },\n};\n"],"mappings":";;;;;;;;;;;AAQA,MAAa,qBAGR;CACH,MAAM;CACN,aAAa;CACb,WAAW;CACX,eAAe;CACf,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAClC,MAAM,aAAa,cAAc,MAAM,OAAO;EAG9C,IAAI,UAAU,UAAa,eAAe,QAAW;GACnD,KAAK,QAAQ,mBAAmB,QAAQ,KAAK,QAAQ,QAAQ;GAC7D,OAAO,YAAY,MAAM,OAAO;EAClC;EAEA,OAAO;CACT;AACF;;;;;AAMA,MAAa,wBAGR;CACH,MAAM;CACN,aAAa;CACb,WAAW;CACX,eAAe;CACf,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAClC,MAAM,EAAE,QAAQ,QAAQ,aAAa,KAAK,QAAQ;EAClD,MAAM,SAAS,UAAU,YAAY,QAAQ,SAAS,QAAQ;EAG9D,MAAM,aAAa,OAAO,OAAO,UAAU,IAAI,QAAQ,KAAK,MAAM,MAAS;EAG3E,IAAI,UAAU,UAAa,YAAY;GACrC,OAAO,SAAS,UAAU;IACxB,KAAK,QAAQ,mBAAmB,QAAQ;GAC1C,CAAC;GAED,OAAO,YAAY,MAAM,OAAO;EAClC;EAEA,OAAO;CACT;AACF;;;;;AAMA,MAAa,wBAGR;CACH,MAAM;CACN,aAAa;CACb,WAAW;CACX,eAAe;CACf,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAClC,MAAM,EAAE,QAAQ,QAAQ,aAAa,KAAK,QAAQ;EAClD,MAAM,SAAS,UAAU,YAAY,QAAQ,SAAS,QAAQ;EAG9D,MAAM,aAAa,OAAO,MAAM,UAAU,IAAI,QAAQ,KAAK,MAAM,MAAS;EAG1E,IAAI,UAAU,UAAa,YAAY;GACrC,OAAO,SAAS,UAAU;IACxB,KAAK,QAAQ,mBAAmB,QAAQ;GAC1C,CAAC;GAED,OAAO,YAAY,MAAM,OAAO;EAClC;EAEA,OAAO;CACT;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"required-if-rules.mjs","names":[],"sources":["../../../../../../../../../../seal/src/rules/conditional/required-if-rules.ts"],"sourcesContent":["import { get } from \"@mongez/reinforcements\";\r\nimport { getFieldValue, invalidRule, VALID_RULE } from \"../../helpers\";\r\nimport { isEmptyValue } from \"../../helpers/is-empty-value\";\r\nimport type { SchemaRule } from \"../../types\";\r\n\r\n/**\r\n * Required if rule - field is required if another field equals a specific value\r\n * Supports both global and sibling scope\r\n */\r\nexport const requiredIfRule: SchemaRule<{\r\n field: string;\r\n value: any;\r\n scope?: \"global\" | \"sibling\";\r\n}> = {\r\n name: \"requiredIf\",\r\n description: \"The field is required if another field equals a specific value\",\r\n sortOrder: -2,\r\n requiresValue: false,\r\n defaultErrorMessage: \"The :input is required\",\r\n async validate(value: any, context) {\r\n const { value: expectedValue } = this.context.options;\r\n const fieldValue = getFieldValue(this, context);\r\n\r\n // Field is required if the other field equals the expected value\r\n if (isEmptyValue(value) && fieldValue === expectedValue) {\r\n this.context.translatableParams.field = this.context.options.field;\r\n return invalidRule(this, context);\r\n }\r\n\r\n return VALID_RULE;\r\n },\r\n};\r\n\r\n/**\r\n * Required if empty rule - field is required if another field is empty\r\n * Supports both global and sibling scope\r\n */\r\nexport const requiredIfEmptyRule: SchemaRule<{\r\n field: string;\r\n scope?: \"global\" | \"sibling\";\r\n}> = {\r\n name: \"requiredIfEmpty\",\r\n description: \"The field is required if :field is empty\",\r\n sortOrder: -2,\r\n requiresValue: false,\r\n defaultErrorMessage: \"The :input is required\",\r\n async validate(value: any, context) {\r\n const fieldValue = getFieldValue(this, context);\r\n\r\n // Field is required if the other field is empty\r\n if (isEmptyValue(value) && isEmptyValue(fieldValue)) {\r\n this.context.translatableParams.field = this.context.options.field;\r\n return invalidRule(this, context);\r\n }\r\n\r\n return VALID_RULE;\r\n },\r\n};\r\n\r\n/**\r\n * Required if not empty rule - field is required if another field is not empty\r\n * Supports both global and sibling scope\r\n */\r\nexport const requiredIfNotEmptyRule: SchemaRule<{\r\n field: string;\r\n scope?: \"global\" | \"sibling\";\r\n}> = {\r\n name: \"requiredIfNotEmpty\",\r\n description: \"The field is required if :field is not empty\",\r\n sortOrder: -2,\r\n requiresValue: false,\r\n defaultErrorMessage: \"The :input is required\",\r\n async validate(value: any, context) {\r\n const fieldValue = getFieldValue(this, context);\r\n\r\n // Field is required if the other field is not empty\r\n if (isEmptyValue(value) && !isEmptyValue(fieldValue)) {\r\n this.context.translatableParams.field = this.context.options.field;\r\n return invalidRule(this, context);\r\n }\r\n\r\n return VALID_RULE;\r\n },\r\n};\r\n\r\n/**\r\n * Required if in rule - field is required if another field's value is in the given array\r\n * Supports both global and sibling scope\r\n */\r\nexport const requiredIfInRule: SchemaRule<{\r\n field: string;\r\n values: any[];\r\n scope?: \"global\" | \"sibling\";\r\n}> = {\r\n name: \"requiredIfIn\",\r\n description: \"The field is required if :field value is in the given array\",\r\n sortOrder: -2,\r\n requiresValue: false,\r\n defaultErrorMessage: \"The :input is required\",\r\n async validate(value: any, context) {\r\n const { values } = this.context.options;\r\n const fieldValue = getFieldValue(this, context);\r\n\r\n // Field is required if the other field's value is in the array\r\n if (isEmptyValue(value) && values.includes(fieldValue)) {\r\n this.context.translatableParams.field = this.context.options.field;\r\n this.context.translationParams.values = this.context.options.values.join(\", \");\r\n return invalidRule(this, context);\r\n }\r\n\r\n return VALID_RULE;\r\n },\r\n};\r\n\r\n/**\r\n * Required if not in rule - field is required if another field's value is NOT in the given array\r\n * Supports both global and sibling scope\r\n */\r\nexport const requiredIfNotInRule: SchemaRule<{\r\n field: string;\r\n values: any[];\r\n scope?: \"global\" | \"sibling\";\r\n}> = {\r\n name: \"requiredIfNotIn\",\r\n description: \"The field is required if another field's value is NOT in the given array\",\r\n sortOrder: -2,\r\n requiresValue: false,\r\n defaultErrorMessage: \"The :input is required\",\r\n async validate(value: any, context) {\r\n const { values } = this.context.options;\r\n const fieldValue = getFieldValue(this, context);\r\n\r\n // Field is required if the other field's value is NOT in the array\r\n if (isEmptyValue(value) && !values.includes(fieldValue)) {\r\n this.context.translatableParams.field = this.context.options.field;\r\n this.context.translationParams.values = this.context.options.values.join(\", \");\r\n return invalidRule(this, context);\r\n }\r\n\r\n return VALID_RULE;\r\n },\r\n};\r\n\r\n/**\r\n * Get multiple field values based on scope\r\n */\r\nfunction getFieldsValues(\r\n rule: SchemaRule<{ fields: string[]; scope?: \"global\" | \"sibling\" }>,\r\n context: any,\r\n): any[] {\r\n const { fields, scope = \"global\" } = (rule as any).context.options;\r\n const source = scope === \"sibling\" ? context.parent : context.allValues;\r\n return fields.map((field: string) => get(source, field));\r\n}\r\n\r\n/**\r\n * Required if all empty rule - field is required if ALL specified fields are empty\r\n * Supports both global and sibling scope\r\n */\r\nexport const requiredIfAllEmptyRule: SchemaRule<{\r\n fields: string[];\r\n scope?: \"global\" | \"sibling\";\r\n}> = {\r\n name: \"requiredIfAllEmpty\",\r\n description: \"The field is required if all :fields are empty\",\r\n sortOrder: -2,\r\n requiresValue: false,\r\n defaultErrorMessage: \"The :input is required\",\r\n async validate(value: any, context) {\r\n const fieldValues = getFieldsValues(this, context);\r\n\r\n // Field is required if ALL other fields are empty\r\n const allEmpty = fieldValues.every((v) => isEmptyValue(v));\r\n if (isEmptyValue(value) && allEmpty) {\r\n this.context.options.fields.forEach((field) => {\r\n this.context.translatableParams.field = field;\r\n });\r\n return invalidRule(this, context);\r\n }\r\n\r\n return VALID_RULE;\r\n },\r\n};\r\n\r\n/**\r\n * Required if any empty rule - field is required if ANY of the specified fields is empty\r\n * Supports both global and sibling scope\r\n */\r\nexport const requiredIfAnyEmptyRule: SchemaRule<{\r\n fields: string[];\r\n scope?: \"global\" | \"sibling\";\r\n}> = {\r\n name: \"requiredIfAnyEmpty\",\r\n description: \"The field is required if any of the :fields is empty\",\r\n sortOrder: -2,\r\n requiresValue: false,\r\n defaultErrorMessage: \"The :input is required\",\r\n async validate(value: any, context) {\r\n const fieldValues = getFieldsValues(this, context);\r\n\r\n // Field is required if ANY other field is empty\r\n const anyEmpty = fieldValues.some((v) => isEmptyValue(v));\r\n if (isEmptyValue(value) && anyEmpty) {\r\n this.context.options.fields.forEach((field) => {\r\n this.context.translatableParams.field = field;\r\n });\r\n return invalidRule(this, context);\r\n }\r\n\r\n return VALID_RULE;\r\n },\r\n};\r\n\r\n/**\r\n * Required if all not empty rule - field is required if ALL specified fields are NOT empty\r\n * Supports both global and sibling scope\r\n */\r\nexport const requiredIfAllNotEmptyRule: SchemaRule<{\r\n fields: string[];\r\n scope?: \"global\" | \"sibling\";\r\n}> = {\r\n name: \"requiredIfAllNotEmpty\",\r\n description: \"The field is required if all :fields are not empty\",\r\n sortOrder: -2,\r\n requiresValue: false,\r\n defaultErrorMessage: \"The :input is required\",\r\n async validate(value: any, context) {\r\n const fieldValues = getFieldsValues(this, context);\r\n\r\n // Field is required if ALL other fields are NOT empty\r\n const allNotEmpty = fieldValues.every((v) => !isEmptyValue(v));\r\n if (isEmptyValue(value) && allNotEmpty) {\r\n this.context.options.fields.forEach((field) => {\r\n this.context.translatableParams.field = field;\r\n });\r\n return invalidRule(this, context);\r\n }\r\n\r\n return VALID_RULE;\r\n },\r\n};\r\n\r\n/**\r\n * Required if any not empty rule - field is required if ANY of the specified fields is NOT empty\r\n * Supports both global and sibling scope\r\n */\r\nexport const requiredIfAnyNotEmptyRule: SchemaRule<{\r\n fields: string[];\r\n scope?: \"global\" | \"sibling\";\r\n}> = {\r\n name: \"requiredIfAnyNotEmpty\",\r\n description: \"The field is required if any of the :fields is not empty\",\r\n sortOrder: -2,\r\n requiresValue: false,\r\n defaultErrorMessage: \"The :input is required\",\r\n async validate(value: any, context) {\r\n const fieldValues = getFieldsValues(this, context);\r\n\r\n // Field is required if ANY other field is NOT empty\r\n const anyNotEmpty = fieldValues.some((v) => !isEmptyValue(v));\r\n if (isEmptyValue(value) && anyNotEmpty) {\r\n this.context.options.fields.forEach((field) => {\r\n this.context.translatableParams.field = field;\r\n });\r\n return invalidRule(this, context);\r\n }\r\n\r\n return VALID_RULE;\r\n },\r\n};\r\n"],"mappings":";;;;;;;;;;;;AASA,MAAa,iBAIR;CACH,MAAM;CACN,aAAa;CACb,WAAW;CAC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S;EAIlC,MAAM,WAHc,gBAAgB,MAAM,OAGf,CAAC,CAAC,MAAM,MAAM,aAAa,CAAC,CAAC;EACxD,IAAI,aAAa,KAAK,KAAK,UAAU;GACnC,KAAK,QAAQ,QAAQ,OAAO,SAAS,UAAU;IAC7C,KAAK,QAAQ,mBAAmB,QAAQ;GAC1C,CAAC;GACD,OAAO,YAAY,MAAM,OAAO;EAClC;EAEA,OAAO;CACT;AACF;;;;;AAMA,MAAa,4BAGR;CACH,MAAM;CACN,aAAa;CACb,WAAW;CACX,eAAe;CACf,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAIlC,MAAM,cAHc,gBAAgB,MAAM,OAGZ,CAAC,CAAC,OAAO,MAAM,CAAC,aAAa,CAAC,CAAC;EAC7D,IAAI,aAAa,KAAK,KAAK,aAAa;GACtC,KAAK,QAAQ,QAAQ,OAAO,SAAS,UAAU;IAC7C,KAAK,QAAQ,mBAAmB,QAAQ;GAC1C,CAAC;GACD,OAAO,YAAY,MAAM,OAAO;EAClC;EAEA,OAAO;CACT;AACF;;;;;AAMA,MAAa,4BAGR;CACH,MAAM;CACN,aAAa;CACb,WAAW;CACX,eAAe;CACf,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAIlC,MAAM,cAHc,gBAAgB,MAAM,OAGZ,CAAC,CAAC,MAAM,MAAM,CAAC,aAAa,CAAC,CAAC;EAC5D,IAAI,aAAa,KAAK,KAAK,aAAa;GACtC,KAAK,QAAQ,QAAQ,OAAO,SAAS,UAAU;IAC7C,KAAK,QAAQ,mBAAmB,QAAQ;GAC1C,CAAC;GACD,OAAO,YAAY,MAAM,OAAO;EAClC;EAEA,OAAO;CACT;AACF"}
|
|
1
|
+
{"version":3,"file":"required-if-rules.mjs","names":[],"sources":["../../../../../../../../../../seal/src/rules/conditional/required-if-rules.ts"],"sourcesContent":["import { get } from \"@mongez/reinforcements\";\nimport { getFieldValue, invalidRule, VALID_RULE } from \"../../helpers\";\nimport { isEmptyValue } from \"../../helpers/is-empty-value\";\nimport type { SchemaRule } from \"../../types\";\n\n/**\n * Required if rule - field is required if another field equals a specific value\n * Supports both global and sibling scope\n */\nexport const requiredIfRule: SchemaRule<{\n field: string;\n value: any;\n scope?: \"global\" | \"sibling\";\n}> = {\n name: \"requiredIf\",\n description: \"The field is required if another field equals a specific value\",\n sortOrder: -2,\n requiresValue: false,\n defaultErrorMessage: \"The :input is required\",\n async validate(value: any, context) {\n const { value: expectedValue } = this.context.options;\n const fieldValue = getFieldValue(this, context);\n\n // Field is required if the other field equals the expected value\n if (isEmptyValue(value) && fieldValue === expectedValue) {\n this.context.translatableParams.field = this.context.options.field;\n return invalidRule(this, context);\n }\n\n return VALID_RULE;\n },\n};\n\n/**\n * Required if empty rule - field is required if another field is empty\n * Supports both global and sibling scope\n */\nexport const requiredIfEmptyRule: SchemaRule<{\n field: string;\n scope?: \"global\" | \"sibling\";\n}> = {\n name: \"requiredIfEmpty\",\n description: \"The field is required if :field is empty\",\n sortOrder: -2,\n requiresValue: false,\n defaultErrorMessage: \"The :input is required\",\n async validate(value: any, context) {\n const fieldValue = getFieldValue(this, context);\n\n // Field is required if the other field is empty\n if (isEmptyValue(value) && isEmptyValue(fieldValue)) {\n this.context.translatableParams.field = this.context.options.field;\n return invalidRule(this, context);\n }\n\n return VALID_RULE;\n },\n};\n\n/**\n * Required if not empty rule - field is required if another field is not empty\n * Supports both global and sibling scope\n */\nexport const requiredIfNotEmptyRule: SchemaRule<{\n field: string;\n scope?: \"global\" | \"sibling\";\n}> = {\n name: \"requiredIfNotEmpty\",\n description: \"The field is required if :field is not empty\",\n sortOrder: -2,\n requiresValue: false,\n defaultErrorMessage: \"The :input is required\",\n async validate(value: any, context) {\n const fieldValue = getFieldValue(this, context);\n\n // Field is required if the other field is not empty\n if (isEmptyValue(value) && !isEmptyValue(fieldValue)) {\n this.context.translatableParams.field = this.context.options.field;\n return invalidRule(this, context);\n }\n\n return VALID_RULE;\n },\n};\n\n/**\n * Required if in rule - field is required if another field's value is in the given array\n * Supports both global and sibling scope\n */\nexport const requiredIfInRule: SchemaRule<{\n field: string;\n values: any[];\n scope?: \"global\" | \"sibling\";\n}> = {\n name: \"requiredIfIn\",\n description: \"The field is required if :field value is in the given array\",\n sortOrder: -2,\n requiresValue: false,\n defaultErrorMessage: \"The :input is required\",\n async validate(value: any, context) {\n const { values } = this.context.options;\n const fieldValue = getFieldValue(this, context);\n\n // Field is required if the other field's value is in the array\n if (isEmptyValue(value) && values.includes(fieldValue)) {\n this.context.translatableParams.field = this.context.options.field;\n this.context.translationParams.values = this.context.options.values.join(\", \");\n return invalidRule(this, context);\n }\n\n return VALID_RULE;\n },\n};\n\n/**\n * Required if not in rule - field is required if another field's value is NOT in the given array\n * Supports both global and sibling scope\n */\nexport const requiredIfNotInRule: SchemaRule<{\n field: string;\n values: any[];\n scope?: \"global\" | \"sibling\";\n}> = {\n name: \"requiredIfNotIn\",\n description: \"The field is required if another field's value is NOT in the given array\",\n sortOrder: -2,\n requiresValue: false,\n defaultErrorMessage: \"The :input is required\",\n async validate(value: any, context) {\n const { values } = this.context.options;\n const fieldValue = getFieldValue(this, context);\n\n // Field is required if the other field's value is NOT in the array\n if (isEmptyValue(value) && !values.includes(fieldValue)) {\n this.context.translatableParams.field = this.context.options.field;\n this.context.translationParams.values = this.context.options.values.join(\", \");\n return invalidRule(this, context);\n }\n\n return VALID_RULE;\n },\n};\n\n/**\n * Get multiple field values based on scope\n */\nfunction getFieldsValues(\n rule: SchemaRule<{ fields: string[]; scope?: \"global\" | \"sibling\" }>,\n context: any,\n): any[] {\n const { fields, scope = \"global\" } = (rule as any).context.options;\n const source = scope === \"sibling\" ? context.parent : context.allValues;\n return fields.map((field: string) => get(source, field));\n}\n\n/**\n * Required if all empty rule - field is required if ALL specified fields are empty\n * Supports both global and sibling scope\n */\nexport const requiredIfAllEmptyRule: SchemaRule<{\n fields: string[];\n scope?: \"global\" | \"sibling\";\n}> = {\n name: \"requiredIfAllEmpty\",\n description: \"The field is required if all :fields are empty\",\n sortOrder: -2,\n requiresValue: false,\n defaultErrorMessage: \"The :input is required\",\n async validate(value: any, context) {\n const fieldValues = getFieldsValues(this, context);\n\n // Field is required if ALL other fields are empty\n const allEmpty = fieldValues.every((v) => isEmptyValue(v));\n if (isEmptyValue(value) && allEmpty) {\n this.context.options.fields.forEach((field) => {\n this.context.translatableParams.field = field;\n });\n return invalidRule(this, context);\n }\n\n return VALID_RULE;\n },\n};\n\n/**\n * Required if any empty rule - field is required if ANY of the specified fields is empty\n * Supports both global and sibling scope\n */\nexport const requiredIfAnyEmptyRule: SchemaRule<{\n fields: string[];\n scope?: \"global\" | \"sibling\";\n}> = {\n name: \"requiredIfAnyEmpty\",\n description: \"The field is required if any of the :fields is empty\",\n sortOrder: -2,\n requiresValue: false,\n defaultErrorMessage: \"The :input is required\",\n async validate(value: any, context) {\n const fieldValues = getFieldsValues(this, context);\n\n // Field is required if ANY other field is empty\n const anyEmpty = fieldValues.some((v) => isEmptyValue(v));\n if (isEmptyValue(value) && anyEmpty) {\n this.context.options.fields.forEach((field) => {\n this.context.translatableParams.field = field;\n });\n return invalidRule(this, context);\n }\n\n return VALID_RULE;\n },\n};\n\n/**\n * Required if all not empty rule - field is required if ALL specified fields are NOT empty\n * Supports both global and sibling scope\n */\nexport const requiredIfAllNotEmptyRule: SchemaRule<{\n fields: string[];\n scope?: \"global\" | \"sibling\";\n}> = {\n name: \"requiredIfAllNotEmpty\",\n description: \"The field is required if all :fields are not empty\",\n sortOrder: -2,\n requiresValue: false,\n defaultErrorMessage: \"The :input is required\",\n async validate(value: any, context) {\n const fieldValues = getFieldsValues(this, context);\n\n // Field is required if ALL other fields are NOT empty\n const allNotEmpty = fieldValues.every((v) => !isEmptyValue(v));\n if (isEmptyValue(value) && allNotEmpty) {\n this.context.options.fields.forEach((field) => {\n this.context.translatableParams.field = field;\n });\n return invalidRule(this, context);\n }\n\n return VALID_RULE;\n },\n};\n\n/**\n * Required if any not empty rule - field is required if ANY of the specified fields is NOT empty\n * Supports both global and sibling scope\n */\nexport const requiredIfAnyNotEmptyRule: SchemaRule<{\n fields: string[];\n scope?: \"global\" | \"sibling\";\n}> = {\n name: \"requiredIfAnyNotEmpty\",\n description: \"The field is required if any of the :fields is not empty\",\n sortOrder: -2,\n requiresValue: false,\n defaultErrorMessage: \"The :input is required\",\n async validate(value: any, context) {\n const fieldValues = getFieldsValues(this, context);\n\n // Field is required if ANY other field is NOT empty\n const anyNotEmpty = fieldValues.some((v) => !isEmptyValue(v));\n if (isEmptyValue(value) && anyNotEmpty) {\n this.context.options.fields.forEach((field) => {\n this.context.translatableParams.field = field;\n });\n return invalidRule(this, context);\n }\n\n return VALID_RULE;\n },\n};\n"],"mappings":";;;;;;;;;;;;AASA,MAAa,iBAIR;CACH,MAAM;CACN,aAAa;CACb,WAAW;CACX,eAAe;CACf,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAClC,MAAM,EAAE,OAAO,kBAAkB,KAAK,QAAQ;EAC9C,MAAM,aAAa,cAAc,MAAM,OAAO;EAG9C,IAAI,aAAa,KAAK,KAAK,eAAe,eAAe;GACvD,KAAK,QAAQ,mBAAmB,QAAQ,KAAK,QAAQ,QAAQ;GAC7D,OAAO,YAAY,MAAM,OAAO;EAClC;EAEA,OAAO;CACT;AACF;;;;;AAMA,MAAa,sBAGR;CACH,MAAM;CACN,aAAa;CACb,WAAW;CACX,eAAe;CACf,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAClC,MAAM,aAAa,cAAc,MAAM,OAAO;EAG9C,IAAI,aAAa,KAAK,KAAK,aAAa,UAAU,GAAG;GACnD,KAAK,QAAQ,mBAAmB,QAAQ,KAAK,QAAQ,QAAQ;GAC7D,OAAO,YAAY,MAAM,OAAO;EAClC;EAEA,OAAO;CACT;AACF;;;;;AAMA,MAAa,yBAGR;CACH,MAAM;CACN,aAAa;CACb,WAAW;CACX,eAAe;CACf,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAClC,MAAM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;CACf,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAIlC,MAAM,cAHc,gBAAgB,MAAM,OAGZ,CAAC,CAAC,MAAM,MAAM,CAAC,aAAa,CAAC,CAAC;EAC5D,IAAI,aAAa,KAAK,KAAK,aAAa;GACtC,KAAK,QAAQ,QAAQ,OAAO,SAAS,UAAU;IAC7C,KAAK,QAAQ,mBAAmB,QAAQ;GAC1C,CAAC;GACD,OAAO,YAAY,MAAM,OAAO;EAClC;EAEA,OAAO;CACT;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"required-unless-rules.mjs","names":[],"sources":["../../../../../../../../../../seal/src/rules/conditional/required-unless-rules.ts"],"sourcesContent":["import { getFieldValue, invalidRule, VALID_RULE } from \"../../helpers\";\
|
|
1
|
+
{"version":3,"file":"required-unless-rules.mjs","names":[],"sources":["../../../../../../../../../../seal/src/rules/conditional/required-unless-rules.ts"],"sourcesContent":["import { getFieldValue, invalidRule, VALID_RULE } from \"../../helpers\";\nimport type { SchemaRule } from \"../../types\";\nimport { isEmptyValue } from \"./../../helpers/is-empty-value\";\n\n/**\n * Required unless rule - field is required unless another field equals a specific value\n * Supports both global and sibling scope\n */\nexport const requiredUnlessRule: SchemaRule<{\n field: string;\n value: any;\n scope?: \"global\" | \"sibling\";\n}> = {\n name: \"requiredUnless\",\n description: \"The field is required unless another field equals a specific value\",\n sortOrder: -2,\n requiresValue: false,\n defaultErrorMessage: \"The :input is required\",\n async validate(value: any, context) {\n const { value: expectedValue } = this.context.options;\n const fieldValue = getFieldValue(this, context);\n\n // Field is required unless the other field equals the expected value\n if (isEmptyValue(value) && fieldValue !== expectedValue) {\n this.context.translatableParams.field = this.context.options.field;\n this.context.translationParams.value = this.context.options.value;\n return invalidRule(this, context);\n }\n\n return VALID_RULE;\n },\n};\n"],"mappings":";;;;;;;;;;AAQA,MAAa,qBAIR;CACH,MAAM;CACN,aAAa;CACb,WAAW;CACX,eAAe;CACf,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAClC,MAAM,EAAE,OAAO,kBAAkB,KAAK,QAAQ;EAC9C,MAAM,aAAa,cAAc,MAAM,OAAO;EAG9C,IAAI,aAAa,KAAK,KAAK,eAAe,eAAe;GACvD,KAAK,QAAQ,mBAAmB,QAAQ,KAAK,QAAQ,QAAQ;GAC7D,KAAK,QAAQ,kBAAkB,QAAQ,KAAK,QAAQ,QAAQ;GAC5D,OAAO,YAAY,MAAM,OAAO;EAClC;EAEA,OAAO;CACT;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"required-with-rules.mjs","names":[],"sources":["../../../../../../../../../../seal/src/rules/conditional/required-with-rules.ts"],"sourcesContent":["import { get } from \"@mongez/reinforcements\";\
|
|
1
|
+
{"version":3,"file":"required-with-rules.mjs","names":[],"sources":["../../../../../../../../../../seal/src/rules/conditional/required-with-rules.ts"],"sourcesContent":["import { get } from \"@mongez/reinforcements\";\nimport { getFieldValue, invalidRule, VALID_RULE } from \"../../helpers\";\nimport { isEmptyValue } from \"../../helpers/is-empty-value\";\nimport type { SchemaRule } from \"../../types\";\n\n/**\n * Required with rule - field is required if another field is present\n * Supports both global and sibling scope\n */\nexport const requiredWithRule: SchemaRule<{\n field: string;\n scope?: \"global\" | \"sibling\";\n}> = {\n name: \"requiredWith\",\n description: \"The field is required if another field is present\",\n sortOrder: -2,\n requiresValue: false,\n defaultErrorMessage: \"The :input is required\",\n async validate(value: any, context) {\n const fieldValue = getFieldValue(this, context);\n\n // Field is required if the other field is present\n if (isEmptyValue(value) && fieldValue !== undefined) {\n this.context.translatableParams.field = this.context.options.field;\n return invalidRule(this, context);\n }\n\n return VALID_RULE;\n },\n};\n\n/**\n * Required with all rule - field is required if all specified fields are present\n * Supports both global and sibling scope\n */\nexport const requiredWithAllRule: SchemaRule<{\n fields: string[];\n scope?: \"global\" | \"sibling\";\n}> = {\n name: \"requiredWithAll\",\n description: \"The field is required if all specified fields are present\",\n sortOrder: -2,\n requiresValue: false,\n defaultErrorMessage: \"The :input is required\",\n async validate(value: any, context) {\n const { fields, scope = \"global\" } = this.context.options;\n const source = scope === \"sibling\" ? context.parent : context.allValues;\n\n // Check if all fields are present\n const allPresent = fields.every((field) => get(source, field) !== undefined);\n\n // Field is required if all other fields are present\n if (isEmptyValue(value) && allPresent) {\n return invalidRule(this, context);\n }\n\n return VALID_RULE;\n },\n};\n\n/**\n * Required with any rule - field is required if any of the specified fields is present\n * Supports both global and sibling scope\n */\nexport const requiredWithAnyRule: SchemaRule<{\n fields: string[];\n scope?: \"global\" | \"sibling\";\n}> = {\n name: \"requiredWithAny\",\n description: \"The field is required if any of the specified fields is present\",\n sortOrder: -2,\n requiresValue: false,\n defaultErrorMessage: \"The :input is required\",\n async validate(value: any, context) {\n const { fields, scope = \"global\" } = this.context.options;\n const source = scope === \"sibling\" ? context.parent : context.allValues;\n\n // Check if any field is present\n const anyPresent = fields.some((field) => get(source, field) !== undefined);\n\n // Field is required if any other field is present\n if (isEmptyValue(value) && anyPresent) {\n return invalidRule(this, context);\n }\n\n return VALID_RULE;\n },\n};\n"],"mappings":";;;;;;;;;;;;AASA,MAAa,mBAGR;CACH,MAAM;CACN,aAAa;CACb,WAAW;CACX,eAAe;CACf,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAClC,MAAM,aAAa,cAAc,MAAM,OAAO;EAG9C,IAAI,aAAa,KAAK,KAAK,eAAe,QAAW;GACnD,KAAK,QAAQ,mBAAmB,QAAQ,KAAK,QAAQ,QAAQ;GAC7D,OAAO,YAAY,MAAM,OAAO;EAClC;EAEA,OAAO;CACT;AACF;;;;;AAMA,MAAa,sBAGR;CACH,MAAM;CACN,aAAa;CACb,WAAW;CACX,eAAe;CACf,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAClC,MAAM,EAAE,QAAQ,QAAQ,aAAa,KAAK,QAAQ;EAClD,MAAM,SAAS,UAAU,YAAY,QAAQ,SAAS,QAAQ;EAG9D,MAAM,aAAa,OAAO,OAAO,UAAU,IAAI,QAAQ,KAAK,MAAM,MAAS;EAG3E,IAAI,aAAa,KAAK,KAAK,YACzB,OAAO,YAAY,MAAM,OAAO;EAGlC,OAAO;CACT;AACF;;;;;AAMA,MAAa,sBAGR;CACH,MAAM;CACN,aAAa;CACb,WAAW;CACX,eAAe;CACf,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAClC,MAAM,EAAE,QAAQ,QAAQ,aAAa,KAAK,QAAQ;EAClD,MAAM,SAAS,UAAU,YAAY,QAAQ,SAAS,QAAQ;EAG9D,MAAM,aAAa,OAAO,MAAM,UAAU,IAAI,QAAQ,KAAK,MAAM,MAAS;EAG1E,IAAI,aAAa,KAAK,KAAK,YACzB,OAAO,YAAY,MAAM,OAAO;EAGlC,OAAO;CACT;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"required-without-rules.mjs","names":[],"sources":["../../../../../../../../../../seal/src/rules/conditional/required-without-rules.ts"],"sourcesContent":["import { get } from \"@mongez/reinforcements\";\
|
|
1
|
+
{"version":3,"file":"required-without-rules.mjs","names":[],"sources":["../../../../../../../../../../seal/src/rules/conditional/required-without-rules.ts"],"sourcesContent":["import { get } from \"@mongez/reinforcements\";\nimport { getFieldValue, invalidRule, VALID_RULE } from \"../../helpers\";\nimport type { SchemaRule } from \"../../types\";\nimport { isEmptyValue } from \"./../../helpers/is-empty-value\";\n\n/**\n * Required without rule - field is required if another field is missing\n * Supports both global and sibling scope\n */\nexport const requiredWithoutRule: SchemaRule<{\n field: string;\n scope?: \"global\" | \"sibling\";\n}> = {\n name: \"requiredWithout\",\n description: \"The field is required if another field is missing\",\n sortOrder: -2,\n requiresValue: false,\n defaultErrorMessage: \"The :input is required\",\n async validate(value: any, context) {\n const fieldValue = getFieldValue(this, context);\n\n // Field is required if the other field is missing\n if (isEmptyValue(value) && fieldValue === undefined) {\n this.context.translatableParams.field = this.context.options.field;\n return invalidRule(this, context);\n }\n\n return VALID_RULE;\n },\n};\n\n/**\n * Required without all rule - field is required if all specified fields are missing\n * Supports both global and sibling scope\n */\nexport const requiredWithoutAllRule: SchemaRule<{\n fields: string[];\n scope?: \"global\" | \"sibling\";\n}> = {\n name: \"requiredWithoutAll\",\n description: \"The field is required if all specified fields are missing\",\n sortOrder: -2,\n requiresValue: false,\n defaultErrorMessage: \"The :input is required\",\n async validate(value: any, context) {\n const { fields, scope = \"global\" } = this.context.options;\n const source = scope === \"sibling\" ? context.parent : context.allValues;\n\n // Check if all fields are missing\n const allMissing = fields.every((field) => get(source, field) === undefined);\n\n // Field is required if all other fields are missing\n if (isEmptyValue(value) && allMissing) {\n return invalidRule(this, context);\n }\n\n return VALID_RULE;\n },\n};\n\n/**\n * Required without any rule - field is required if any of the specified fields is missing\n * Supports both global and sibling scope\n */\nexport const requiredWithoutAnyRule: SchemaRule<{\n fields: string[];\n scope?: \"global\" | \"sibling\";\n}> = {\n name: \"requiredWithoutAny\",\n description: \"The field is required if any of the specified fields is missing\",\n sortOrder: -2,\n requiresValue: false,\n defaultErrorMessage: \"The :input is required\",\n async validate(value: any, context) {\n const { fields, scope = \"global\" } = this.context.options;\n const source = scope === \"sibling\" ? context.parent : context.allValues;\n\n // Check if any field is missing\n const anyMissing = fields.some((field) => get(source, field) === undefined);\n\n // Field is required if any other field is missing\n if (isEmptyValue(value) && anyMissing) {\n return invalidRule(this, context);\n }\n\n return VALID_RULE;\n },\n};\n"],"mappings":";;;;;;;;;;;;AASA,MAAa,sBAGR;CACH,MAAM;CACN,aAAa;CACb,WAAW;CACX,eAAe;CACf,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAClC,MAAM,aAAa,cAAc,MAAM,OAAO;EAG9C,IAAI,aAAa,KAAK,KAAK,eAAe,QAAW;GACnD,KAAK,QAAQ,mBAAmB,QAAQ,KAAK,QAAQ,QAAQ;GAC7D,OAAO,YAAY,MAAM,OAAO;EAClC;EAEA,OAAO;CACT;AACF;;;;;AAMA,MAAa,yBAGR;CACH,MAAM;CACN,aAAa;CACb,WAAW;CACX,eAAe;CACf,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAClC,MAAM,EAAE,QAAQ,QAAQ,aAAa,KAAK,QAAQ;EAClD,MAAM,SAAS,UAAU,YAAY,QAAQ,SAAS,QAAQ;EAG9D,MAAM,aAAa,OAAO,OAAO,UAAU,IAAI,QAAQ,KAAK,MAAM,MAAS;EAG3E,IAAI,aAAa,KAAK,KAAK,YACzB,OAAO,YAAY,MAAM,OAAO;EAGlC,OAAO;CACT;AACF;;;;;AAMA,MAAa,yBAGR;CACH,MAAM;CACN,aAAa;CACb,WAAW;CACX,eAAe;CACf,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAClC,MAAM,EAAE,QAAQ,QAAQ,aAAa,KAAK,QAAQ;EAClD,MAAM,SAAS,UAAU,YAAY,QAAQ,SAAS,QAAQ;EAG9D,MAAM,aAAa,OAAO,MAAM,UAAU,IAAI,QAAQ,KAAK,MAAM,MAAS;EAG1E,IAAI,aAAa,KAAK,KAAK,YACzB,OAAO,YAAY,MAAM,OAAO;EAGlC,OAAO;CACT;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"equal.mjs","names":[],"sources":["../../../../../../../../../../seal/src/rules/core/equal.ts"],"sourcesContent":["import { invalidRule, VALID_RULE } from \"../../helpers\";\
|
|
1
|
+
{"version":3,"file":"equal.mjs","names":[],"sources":["../../../../../../../../../../seal/src/rules/core/equal.ts"],"sourcesContent":["import { invalidRule, VALID_RULE } from \"../../helpers\";\nimport type { SchemaRule } from \"../../types\";\n\n/**\n * Equal rule - value must be equal to a specific value\n */\nexport const equalRule: SchemaRule<{ value: any }> = {\n name: \"equal\",\n defaultErrorMessage: \"The :input must be equal to :value\",\n async validate(value: any, context) {\n if (value !== this.context.options.value) {\n this.context.translatableParams.value = this.context.options.value;\n return invalidRule(this, context);\n }\n return VALID_RULE;\n },\n};\n"],"mappings":";;;;;;;AAMA,MAAa,YAAwC;CACnD,MAAM;CACN,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAClC,IAAI,UAAU,KAAK,QAAQ,QAAQ,OAAO;GACxC,KAAK,QAAQ,mBAAmB,QAAQ,KAAK,QAAQ,QAAQ;GAC7D,OAAO,YAAY,MAAM,OAAO;EAClC;EACA,OAAO;CACT;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"forbidden.mjs","names":[],"sources":["../../../../../../../../../../seal/src/rules/core/forbidden.ts"],"sourcesContent":["import { invalidRule, VALID_RULE } from \"../../helpers\";\
|
|
1
|
+
{"version":3,"file":"forbidden.mjs","names":[],"sources":["../../../../../../../../../../seal/src/rules/core/forbidden.ts"],"sourcesContent":["import { invalidRule, VALID_RULE } from \"../../helpers\";\nimport { isEmptyValue } from \"../../helpers/is-empty-value\";\nimport type { SchemaRule } from \"../../types\";\n\n/**\n * Forbidden rule - value must not be present\n */\nexport const forbiddenRule: SchemaRule = {\n name: \"forbidden\",\n defaultErrorMessage: \"The :input is forbidden\",\n async validate(value: any, context) {\n if (!isEmptyValue(value)) {\n return invalidRule(this, context);\n }\n return VALID_RULE;\n },\n};\n"],"mappings":";;;;;;;;AAOA,MAAa,gBAA4B;CACvC,MAAM;CACN,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAClC,IAAI,CAAC,aAAa,KAAK,GACrB,OAAO,YAAY,MAAM,OAAO;EAElC,OAAO;CACT;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"required.mjs","names":[],"sources":["../../../../../../../../../../seal/src/rules/core/required.ts"],"sourcesContent":["import { invalidRule, VALID_RULE } from \"../../helpers\";\
|
|
1
|
+
{"version":3,"file":"required.mjs","names":[],"sources":["../../../../../../../../../../seal/src/rules/core/required.ts"],"sourcesContent":["import { invalidRule, VALID_RULE } from \"../../helpers\";\nimport { isEmptyValue } from \"../../helpers/is-empty-value\";\nimport type { SchemaRule } from \"../../types\";\n\n/**\n * Required rule - value must be present and not empty\n */\nexport const requiredRule: SchemaRule = {\n name: \"required\",\n defaultErrorMessage: \"The :input is required\",\n requiresValue: false,\n sortOrder: -2,\n async validate(value: any, context) {\n if (isEmptyValue(value)) {\n return invalidRule(this, context);\n }\n return VALID_RULE;\n },\n};\n\n/**\n * Present rule - key must exist in the data, but value can be anything\n * (empty string, null are all valid as long as the key exists)\n */\nexport const presentRule: SchemaRule = {\n name: \"present\",\n defaultErrorMessage: \"The :input field is required\",\n requiresValue: false,\n sortOrder: -2,\n async validate(value: any, context) {\n if (value === undefined) {\n return invalidRule(this, context);\n }\n\n return VALID_RULE;\n },\n};\n"],"mappings":";;;;;;;;AAOA,MAAa,eAA2B;CACtC,MAAM;CACN,qBAAqB;CACrB,eAAe;CACf,WAAW;CACX,MAAM,SAAS,OAAY,SAAS;EAClC,IAAI,aAAa,KAAK,GACpB,OAAO,YAAY,MAAM,OAAO;EAElC,OAAO;CACT;AACF;;;;;AAMA,MAAa,cAA0B;CACrC,MAAM;CACN,qBAAqB;CACrB,eAAe;CACf,WAAW;CACX,MAAM,SAAS,OAAY,SAAS;EAClC,IAAI,UAAU,QACZ,OAAO,YAAY,MAAM,OAAO;EAGlC,OAAO;CACT;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"union.mjs","names":[],"sources":["../../../../../../../../../../seal/src/rules/core/union.ts"],"sourcesContent":["import { invalidRule, VALID_RULE } from \"../../helpers\";\
|
|
1
|
+
{"version":3,"file":"union.mjs","names":[],"sources":["../../../../../../../../../../seal/src/rules/core/union.ts"],"sourcesContent":["import { invalidRule, VALID_RULE } from \"../../helpers\";\nimport type { SchemaRule } from \"../../types\";\nimport type { BaseValidator } from \"../../validators/base-validator\";\n\n/**\n * Union rule - value must match at least one of the provided validators\n */\nexport const unionRule: SchemaRule<{ validators: BaseValidator[] }> = {\n name: \"union\",\n defaultErrorMessage: \"Value must match one of the allowed types\",\n async validate(value: any, context) {\n const validators = this.context.options.validators;\n const firstErrorOnly = context.configurations?.firstErrorOnly ?? true;\n const allErrors: string[] = [];\n\n // Try each validator\n for (const validator of validators) {\n // Skip if type doesn't match (optimization)\n if (!validator.matchesType(value)) {\n continue;\n }\n\n // Type matches - validate\n const result = await validator.validate(value, context);\n\n if (result.isValid) {\n // Success! Validator matched and validated\n return VALID_RULE;\n }\n\n // Failed - collect error message\n const errorMsg = result.errors?.[0]?.error || \"Validation failed\";\n allErrors.push(errorMsg);\n\n // If firstErrorOnly, stop after first failed validator\n if (firstErrorOnly) {\n break;\n }\n }\n\n // All failed or no validator matched the type\n if (allErrors.length > 0) {\n // At least one validator matched type but failed validation\n this.context.errorMessage = firstErrorOnly\n ? allErrors[0]\n : allErrors.join(\"; \");\n }\n\n return invalidRule(this, context);\n },\n};\n"],"mappings":";;;;;;;AAOA,MAAa,YAAyD;CACpE,MAAM;CACN,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAClC,MAAM,aAAa,KAAK,QAAQ,QAAQ;EACxC,MAAM,iBAAiB,QAAQ,gBAAgB,kBAAkB;EACjE,MAAM,YAAsB,CAAC;EAG7B,KAAK,MAAM,aAAa,YAAY;GAElC,IAAI,CAAC,UAAU,YAAY,KAAK,GAC9B;GAIF,MAAM,SAAS,MAAM,UAAU,SAAS,OAAO,OAAO;GAEtD,IAAI,OAAO,SAET,OAAO;GAIT,MAAM,WAAW,OAAO,SAAS,EAAE,EAAE,SAAS;GAC9C,UAAU,KAAK,QAAQ;GAGvB,IAAI,gBACF;EAEJ;EAGA,IAAI,UAAU,SAAS,GAErB,KAAK,QAAQ,eAAe,iBACxB,UAAU,KACV,UAAU,KAAK,IAAI;EAGzB,OAAO,YAAY,MAAM,OAAO;CAClC;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"when.mjs","names":[],"sources":["../../../../../../../../../../seal/src/rules/core/when.ts"],"sourcesContent":["import { get } from \"@mongez/reinforcements\";\
|
|
1
|
+
{"version":3,"file":"when.mjs","names":[],"sources":["../../../../../../../../../../seal/src/rules/core/when.ts"],"sourcesContent":["import { get } from \"@mongez/reinforcements\";\nimport { invalidRule, VALID_RULE } from \"../../helpers\";\nimport type { SchemaRule, WhenRuleOptions } from \"../../types\";\n\n/**\n * When rule - conditional validation based on another field value\n */\nexport const whenRule: SchemaRule<WhenRuleOptions> = {\n name: \"when\",\n description: \"Apply conditional validation based on another field value\",\n async validate(value: any, context) {\n const fieldToCheck = this.context.options.field;\n const conditions = this.context.options.is;\n const otherwise = this.context.options.otherwise;\n const scope = this.context.options.scope || \"global\";\n\n const fieldValue =\n scope === \"global\"\n ? get(context.allValues, fieldToCheck)\n : get(context.parent, fieldToCheck);\n\n // Convert field value to string for key lookup\n // This handles boolean, number, and string field values\n const fieldValueKey = String(fieldValue);\n\n if (conditions[fieldValueKey]) {\n const result = await conditions[fieldValueKey].validate(value, context);\n if (result.isValid) {\n return VALID_RULE;\n }\n\n // Safe error access\n this.context.errorMessage =\n result.errors?.[0]?.error || \"Validation failed\";\n return invalidRule(this, context);\n }\n\n if (otherwise) {\n const result = await otherwise.validate(value, context);\n\n if (result.isValid) {\n return VALID_RULE;\n }\n\n // Safe error access\n this.context.errorMessage =\n result.errors?.[0]?.error || \"Validation failed\";\n return invalidRule(this, context);\n }\n\n return VALID_RULE;\n },\n};\n"],"mappings":";;;;;;;;;AAOA,MAAa,WAAwC;CACnD,MAAM;CACN,aAAa;CACb,MAAM,SAAS,OAAY,SAAS;EAClC,MAAM,eAAe,KAAK,QAAQ,QAAQ;EAC1C,MAAM,aAAa,KAAK,QAAQ,QAAQ;EACxC,MAAM,YAAY,KAAK,QAAQ,QAAQ;EAGvC,MAAM,cAFQ,KAAK,QAAQ,QAAQ,SAAS,cAGhC,WACN,IAAI,QAAQ,WAAW,YAAY,IACnC,IAAI,QAAQ,QAAQ,YAAY;EAItC,MAAM,gBAAgB,OAAO,UAAU;EAEvC,IAAI,WAAW,gBAAgB;GAC7B,MAAM,SAAS,MAAM,WAAW,cAAc,CAAC,SAAS,OAAO,OAAO;GACtE,IAAI,OAAO,SACT,OAAO;GAIT,KAAK,QAAQ,eACX,OAAO,SAAS,EAAE,EAAE,SAAS;GAC/B,OAAO,YAAY,MAAM,OAAO;EAClC;EAEA,IAAI,WAAW;GACb,MAAM,SAAS,MAAM,UAAU,SAAS,OAAO,OAAO;GAEtD,IAAI,OAAO,SACT,OAAO;GAIT,KAAK,QAAQ,eACX,OAAO,SAAS,EAAE,EAAE,SAAS;GAC/B,OAAO,YAAY,MAAM,OAAO;EAClC;EAEA,OAAO;CACT;AACF"}
|