@orieljs/validation 0.1.0-alpha.10 → 0.1.0-alpha.11
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/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../errors.ts","../FormRequest.ts","../messages.ts","../MessageBag.ts","../rules/acceptance.ts","../parse.ts","../rules/dependent.ts","../rules/type.ts","../rules/array.ts","../rules/auth.ts","../rules/database.ts","../rules/date.ts","../dates/phpFormat.ts","../rules/exclude.ts","../rules/file.ts","../files/dimensions.ts","../rules/format.ts","../rules/network.ts","../rules/numeric.ts","../rules/presence.ts","../rules/prohibited.ts","../rules/size.ts","../rules/timezone.ts","../registry.ts","../rules/password.ts","../Rule.ts","../Validator.ts","../ValidationFactory.ts","../facade.ts","../ValidationServiceProvider.ts"],"sourcesContent":["import type { OrielError, ValidationError } from '@orieljs/contracts'\n\nexport class ValidationErrorImpl extends Error implements ValidationError {\n readonly kind = 'Validation' as const\n readonly status = 422\n override readonly name = 'ValidationError'\n constructor(\n readonly errors: Record<string, string[]>,\n readonly errorBag = 'default',\n readonly redirectTo?: string,\n ) {\n super('The given data was invalid.')\n }\n}\n\n/**\n * Laravel's ValidationException, for failing a request by hand:\n * `throw ValidationException.withMessages({ email: __('auth.failed') })`. Rendered like any validation error: 422 JSON,\n * or a redirect back with the errors.\n */\nexport class ValidationException extends ValidationErrorImpl {\n /** Messages per field, each a string or a list. */\n static withMessages(messages: Record<string, string | readonly string[]>): ValidationException {\n const errors = Object.fromEntries(Object.entries(messages).map(([field, list]) => [field, typeof list === 'string' ? [list] : [...list]]))\n return new ValidationException(errors)\n }\n\n constructor(errors: Record<string, string[]>, errorBag = 'default', redirectTo?: string) {\n super(errors, errorBag, redirectTo)\n this.message = summarize(errors)\n }\n}\n\n/** \"The first message. (and 2 more errors)\" (Laravel's ValidationException::summarize()). */\nfunction summarize(errors: Record<string, string[]>): string {\n const messages = Object.values(errors).flat()\n if (messages.length === 0) return 'The given data was invalid.'\n const more = messages.length - 1\n return more === 0 ? messages[0]! : `${messages[0]!} (and ${more} more ${more === 1 ? 'error' : 'errors'})`\n}\n\nexport class AuthorizationErrorImpl extends Error implements OrielError {\n readonly kind = 'Authorization' as const\n readonly status = 403\n override readonly name = 'AuthorizationError'\n constructor(message = 'This action is unauthorized.') {\n super(message)\n }\n}\n\nexport class UnknownValidationRuleError extends Error implements OrielError {\n readonly kind = 'Server' as const\n readonly status = 500\n override readonly name = 'UnknownValidationRuleError'\n constructor(name: string) {\n super(`Validation rule \"${name}\" is not registered. Register it with ValidationFactory.extend() first.`)\n }\n}\n\n/** A rule was written with a parameter it can't use (a bad regex, an unparseable date). A developer error, not a user one. */\nexport class InvalidRuleParameterError extends Error implements OrielError {\n readonly kind = 'Server' as const\n readonly status = 500\n override readonly name = 'InvalidRuleParameterError'\n constructor(rule: string, parameter: string, reason: string) {\n super(`Validation rule \"${rule}\" has an invalid parameter \"${parameter}\": ${reason}`)\n }\n}\n","import type { InferValidatedType, Rules } from '@orieljs/contracts'\nimport { HttpRequest, ValidationFactory } from '@orieljs/contracts'\nimport { inject } from '@orieljs/container'\nimport { AuthorizationErrorImpl } from './errors'\n\n/** The data a FormRequest's validate() returns, typed from its rules(). */\ntype ValidatedData<F extends FormRequest> = InferValidatedType<Awaited<ReturnType<F['rules']>>>\n\n/**\n * Mirrors Illuminate\\Foundation\\Http\\FormRequest, minus dependency injection by type (Oriel resolves the current\n * request and the ValidationFactory through inject(), never through constructor parameters — see spec §3 rule 5).\n * A subclass only has to implement rules(); authorize()/messages()/attributes() default to Laravel's own defaults.\n */\nexport abstract class FormRequest {\n /** May be async, to await something first: `async rules() { const user = await request().user<User>() … }`. */\n abstract rules(): Rules | Promise<Rules>\n\n authorize(): boolean | Promise<boolean> {\n return true\n }\n\n messages(): Record<string, string> {\n return {}\n }\n\n attributes(): Record<string, string> {\n return {}\n }\n\n /**\n * `const data = await StorePostRequest.validate()` (spec §4.3). Resolves the current request and the\n * ValidationFactory from the active container, runs authorize() first (throwing AuthorizationErrorImpl if it\n * returns false), then validates request.all() against rules()/messages()/attributes() and returns the validated\n * data (or throws the 422 ValidationError — see ValidatorImpl.validated()). The data is typed from rules(): write\n * it without a return type and with `as const` (`return { title: 'required|string' } as const`), so its rule\n * strings keep their text; a rules() typed `Rules` gives `Record<string, unknown>`.\n */\n static async validate<F extends FormRequest>(this: new () => F): Promise<ValidatedData<F>> {\n const instance = new this()\n if (!(await instance.authorize())) throw new AuthorizationErrorImpl()\n\n const request = inject(HttpRequest)\n const factory = inject(ValidationFactory)\n const validator = factory.make(request.all(), await instance.rules(), instance.messages(), instance.attributes())\n return validator.validated<ValidatedData<F>>()\n }\n}\n","import { Str } from '@orieljs/support'\n\n/** Humanizes a (possibly dotted) attribute key, e.g. \"items.0.product_name\" -> \"items.0.product name\" (\"colors.*\" stays). */\nexport function defaultAttributeName(key: string): string {\n return key\n .split('.')\n .map((segment) => (segment === '*' ? segment : Str.snake(segment).replace(/_/g, ' ')))\n .join('.')\n}\n\nexport function applyReplacements(template: string, replacements: Record<string, string>): string {\n return Object.entries(replacements).reduce((message, [key, value]) => message.replaceAll(`:${key}`, value), template)\n}\n\n/** Laravel's English lang/en/validation.php, reproduced as closely as possible. */\nexport const DEFAULT_MESSAGES: Record<string, string> = {\n required: 'The :attribute field is required.',\n required_if: 'The :attribute field is required when :other is :value.',\n required_unless: 'The :attribute field is required unless :other is in :values.',\n required_with: 'The :attribute field is required when :values is present.',\n required_with_all: 'The :attribute field is required when :values are present.',\n required_without: 'The :attribute field is required when :values is not present.',\n required_without_all: 'The :attribute field is required when none of :values are present.',\n required_if_accepted: 'The :attribute field is required when :other is accepted.',\n required_if_declined: 'The :attribute field is required when :other is declined.',\n present: 'The :attribute field must be present.',\n present_if: 'The :attribute field must be present when :other is :value.',\n present_unless: 'The :attribute field must be present unless :other is :value.',\n present_with: 'The :attribute field must be present when :values is present.',\n present_with_all: 'The :attribute field must be present when :values are present.',\n filled: 'The :attribute field must have a value.',\n missing: 'The :attribute field must be missing.',\n missing_if: 'The :attribute field must be missing when :other is :value.',\n missing_unless: 'The :attribute field must be missing unless :other is :value.',\n missing_with: 'The :attribute field must be missing when :values is present.',\n missing_with_all: 'The :attribute field must be missing when :values are present.',\n prohibited: 'The :attribute field is prohibited.',\n prohibited_if: 'The :attribute field is prohibited when :other is :value.',\n prohibited_if_accepted: 'The :attribute field is prohibited when :other is accepted.',\n prohibited_if_declined: 'The :attribute field is prohibited when :other is declined.',\n prohibited_unless: 'The :attribute field is prohibited unless :other is in :values.',\n prohibits: 'The :attribute field prohibits :other from being present.',\n string: 'The :attribute field must be a string.',\n integer: 'The :attribute field must be an integer.',\n numeric: 'The :attribute field must be a number.',\n boolean: 'The :attribute field must be true or false.',\n array: 'The :attribute field must be an array.',\n list: 'The :attribute field must be a list.',\n required_array_keys: 'The :attribute field must contain entries for: :values.',\n in_array_keys: 'The :attribute field must contain at least one of the following keys: :values.',\n contains: 'The :attribute field is missing a required value.',\n doesnt_contain: 'The :attribute field must not contain any of the following: :values.',\n distinct: 'The :attribute field has a duplicate value.',\n in_array: 'The :attribute field must exist in :other.',\n email: 'The :attribute field must be a valid email address.',\n url: 'The :attribute field must be a valid URL.',\n uuid: 'The :attribute field must be a valid UUID.',\n ulid: 'The :attribute field must be a valid ULID.',\n ascii: 'The :attribute field must only contain single-byte alphanumeric characters and symbols.',\n hex_color: 'The :attribute field must be a valid hexadecimal color.',\n json: 'The :attribute field must be a valid JSON string.',\n ip: 'The :attribute field must be a valid IP address.',\n ipv4: 'The :attribute field must be a valid IPv4 address.',\n ipv6: 'The :attribute field must be a valid IPv6 address.',\n mac_address: 'The :attribute field must be a valid MAC address.',\n active_url: 'The :attribute field must be a valid URL.',\n timezone: 'The :attribute field must be a valid timezone.',\n starts_with: 'The :attribute field must start with one of the following: :values.',\n ends_with: 'The :attribute field must end with one of the following: :values.',\n doesnt_start_with: 'The :attribute field must not start with one of the following: :values.',\n doesnt_end_with: 'The :attribute field must not end with one of the following: :values.',\n alpha: 'The :attribute field must only contain letters.',\n alpha_num: 'The :attribute field must only contain letters and numbers.',\n alpha_dash: 'The :attribute field must only contain letters, numbers, dashes, and underscores.',\n regex: 'The :attribute field format is invalid.',\n not_regex: 'The :attribute field format is invalid.',\n lowercase: 'The :attribute field must be lowercase.',\n uppercase: 'The :attribute field must be uppercase.',\n current_password: 'The password is incorrect.',\n 'password.letters': 'The :attribute field must contain at least one letter.',\n 'password.mixed': 'The :attribute field must contain at least one uppercase and one lowercase letter.',\n 'password.numbers': 'The :attribute field must contain at least one number.',\n 'password.symbols': 'The :attribute field must contain at least one symbol.',\n confirmed: 'The :attribute field confirmation does not match.',\n same: 'The :attribute field must match :other.',\n different: 'The :attribute field and :other must be different.',\n accepted: 'The :attribute field must be accepted.',\n accepted_if: 'The :attribute field must be accepted when :other is :value.',\n declined: 'The :attribute field must be declined.',\n declined_if: 'The :attribute field must be declined when :other is :value.',\n digits: 'The :attribute field must be :digits digits.',\n digits_between: 'The :attribute field must be between :min and :max digits.',\n max_digits: 'The :attribute field must not have more than :max digits.',\n min_digits: 'The :attribute field must have at least :min digits.',\n decimal: 'The :attribute field must have :decimal decimal places.',\n multiple_of: 'The :attribute field must be a multiple of :value.',\n date: 'The :attribute field must be a valid date.',\n before: 'The :attribute field must be a date before :date.',\n before_or_equal: 'The :attribute field must be a date before or equal to :date.',\n after: 'The :attribute field must be a date after :date.',\n after_or_equal: 'The :attribute field must be a date after or equal to :date.',\n date_equals: 'The :attribute field must be a date equal to :date.',\n date_format: 'The :attribute field must match the format :format.',\n in: 'The selected :attribute is invalid.',\n not_in: 'The selected :attribute is invalid.',\n enum: 'The selected :attribute is invalid.',\n unique: 'The :attribute has already been taken.',\n exists: 'The selected :attribute is invalid.',\n file: 'The :attribute field must be a file.',\n image: 'The :attribute field must be an image.',\n mimes: 'The :attribute field must be a file of type: :values.',\n mimetypes: 'The :attribute field must be a file of type: :values.',\n extensions: 'The :attribute field must have one of the following extensions: :values.',\n dimensions: 'The :attribute field has invalid image dimensions.',\n 'max.string': 'The :attribute field must not be greater than :max characters.',\n 'max.numeric': 'The :attribute field must not be greater than :max.',\n 'max.array': 'The :attribute field must not have more than :max items.',\n 'max.file': 'The :attribute field must not be greater than :max kilobytes.',\n 'min.string': 'The :attribute field must be at least :min characters.',\n 'min.numeric': 'The :attribute field must be at least :min.',\n 'min.array': 'The :attribute field must have at least :min items.',\n 'min.file': 'The :attribute field must be at least :min kilobytes.',\n 'between.string': 'The :attribute field must be between :min and :max characters.',\n 'between.numeric': 'The :attribute field must be between :min and :max.',\n 'between.array': 'The :attribute field must have between :min and :max items.',\n 'between.file': 'The :attribute field must be between :min and :max kilobytes.',\n 'size.string': 'The :attribute field must be :size characters.',\n 'size.numeric': 'The :attribute field must be :size.',\n 'size.array': 'The :attribute field must contain :size items.',\n 'size.file': 'The :attribute field must be :size kilobytes.',\n 'gt.array': 'The :attribute field must have more than :value items.',\n 'gt.file': 'The :attribute field must be greater than :value kilobytes.',\n 'gt.numeric': 'The :attribute field must be greater than :value.',\n 'gt.string': 'The :attribute field must be greater than :value characters.',\n 'gte.array': 'The :attribute field must have :value items or more.',\n 'gte.file': 'The :attribute field must be greater than or equal to :value kilobytes.',\n 'gte.numeric': 'The :attribute field must be greater than or equal to :value.',\n 'gte.string': 'The :attribute field must be greater than or equal to :value characters.',\n 'lt.array': 'The :attribute field must have less than :value items.',\n 'lt.file': 'The :attribute field must be less than :value kilobytes.',\n 'lt.numeric': 'The :attribute field must be less than :value.',\n 'lt.string': 'The :attribute field must be less than :value characters.',\n 'lte.array': 'The :attribute field must not have more than :value items.',\n 'lte.file': 'The :attribute field must be less than or equal to :value kilobytes.',\n 'lte.numeric': 'The :attribute field must be less than or equal to :value.',\n 'lte.string': 'The :attribute field must be less than or equal to :value characters.',\n}\n","import type { MessageBag } from '@orieljs/contracts'\n\nexport class MessageBagImpl implements MessageBag {\n // No prototype: a field named `constructor` or `toString` is a key like any other.\n private readonly items: Record<string, string[]> = Object.create(null) as Record<string, string[]>\n\n add(key: string, message: string): void {\n ;(this.items[key] ??= []).push(message)\n }\n\n has(key: string): boolean {\n return (this.items[key]?.length ?? 0) > 0\n }\n\n first(key?: string): string | undefined {\n if (key !== undefined) return this.items[key]?.[0]\n for (const messages of Object.values(this.items)) {\n if (messages[0] !== undefined) return messages[0]\n }\n return undefined\n }\n\n get(key: string): string[] {\n return this.items[key] ?? []\n }\n\n all(): string[] {\n return Object.values(this.items).flat()\n }\n\n isEmpty(): boolean {\n return Object.keys(this.items).length === 0\n }\n\n count(): number {\n return this.all().length\n }\n\n toObject(): Record<string, string[]> {\n return structuredClone(this.items)\n }\n}\n","import { Arr } from '@orieljs/support'\nimport type { BuiltinRule } from '../parse'\nimport { isEmptyValue } from '../parse'\nimport { otherAndValue, otherFieldMatches } from './dependent'\n\nconst ACCEPTED_VALUES: unknown[] = ['yes', 'on', 1, '1', true, 'true']\nconst DECLINED_VALUES: unknown[] = ['no', 'off', 0, '0', false, 'false']\n\n/** Laravel's validateAccepted(): yes, on, 1, '1', true or 'true'. */\nexport const isAccepted = (value: unknown): boolean => !isEmptyValue(value) && ACCEPTED_VALUES.includes(value)\n\n/** Laravel's validateDeclined(): no, off, 0, '0', false or 'false'. */\nexport const isDeclined = (value: unknown): boolean => !isEmptyValue(value) && DECLINED_VALUES.includes(value)\n\n/** Whether the field the first parameter names is accepted (or declined), for the `_if_accepted` rules. */\nexport const otherAccepted = (data: Record<string, unknown>, field = ''): boolean => isAccepted(Arr.get(data, field))\nexport const otherDeclined = (data: Record<string, unknown>, field = ''): boolean => isDeclined(Arr.get(data, field))\n\nexport const acceptanceRules: Record<string, BuiltinRule> = {\n accepted: { implicit: true, validate: (ctx) => isAccepted(ctx.value), messageKey: () => 'accepted' },\n accepted_if: {\n implicit: true,\n validate: (ctx) => !otherFieldMatches(ctx) || isAccepted(ctx.value),\n messageKey: () => 'accepted_if',\n replacements: otherAndValue,\n },\n declined: { implicit: true, validate: (ctx) => isDeclined(ctx.value), messageKey: () => 'declined' },\n declined_if: {\n implicit: true,\n validate: (ctx) => !otherFieldMatches(ctx) || isDeclined(ctx.value),\n messageKey: () => 'declined_if',\n replacements: otherAndValue,\n },\n}\n","import type { ValidationRule } from '@orieljs/contracts'\nimport { Arr } from '@orieljs/support'\n\n/** Everything a single rule needs to validate one concrete field. */\nexport interface RuleContext {\n /** The concrete, wildcard-expanded field path, e.g. \"items.1.name\". */\n attribute: string\n /** True when `attribute` came from expanding a wildcard pattern such as \"items.*.email\". */\n expandedFromWildcard?: boolean\n value: unknown\n parameters: string[]\n data: Record<string, unknown>\n /** Every named rule attached to this field (for size-type resolution: numeric/array/file/string). */\n ruleNames: string[]\n /** The rule key as written, e.g. \"items.*.email\" (distinct reads every row of it). */\n pattern?: string\n /**\n * What the rules keep for one validation pass, such as every row a wildcard names: each pass starts with an empty\n * one, so nothing outlives the data it was read from. Absent when a rule runs on its own.\n */\n cache?: Map<string, unknown>\n /** The parameters of rule `name` on `field` (a concrete path), or undefined when that field has no such rule. */\n getRule?(field: string, name: string): string[] | undefined\n /** How a message names `field`: its custom attribute, else the humanized key. */\n displayName?(field: string): string\n}\n\nexport interface BuiltinRule {\n validate(ctx: RuleContext): boolean | Promise<boolean>\n /** Which DEFAULT_MESSAGES key to use, e.g. `max.${sizeType}`. Most rules return a constant name. */\n messageKey(ctx: RuleContext): string\n /** Extra :placeholder substitutions beyond :attribute (e.g. :max, :other, :values). */\n replacements?(ctx: RuleContext): Record<string, string>\n /** Used when messageKey() isn't in DEFAULT_MESSAGES (e.g. an extend()ed rule with a custom message). */\n defaultMessage?: string\n /** An extend()ed rule's own message: it wins over the default lines, as Laravel's fallback messages do. */\n message?: string\n /** Runs even when the value is missing, blank, or null under nullable (the required* family, and accepted); a failure stops the field. */\n implicit?: boolean\n /**\n * An exclude rule (`exclude`, `exclude_if`, …): it always runs, and when validate() returns false the field and its\n * children are skipped from then on and left out of the validated data, with no message.\n */\n excludes?: boolean\n}\n\nexport type ParsedRule =\n | { kind: 'named'; name: string; parameters: string[] }\n | { kind: 'object'; rule: ValidationRule }\n\nfunction splitParameters(name: string, raw: string): string[] {\n // regex/not_regex parameters are never comma-split, so a pattern containing a comma survives intact.\n return name === 'regex' || name === 'not_regex' ? [raw] : raw.split(',')\n}\n\nfunction splitOnce(value: string, separator: string): [string, string | undefined] {\n const index = value.indexOf(separator)\n return index === -1 ? [value, undefined] : [value.slice(0, index), value.slice(index + 1)]\n}\n\n/**\n * A rule object that stands for string rules (Rule.requiredIf(), Rule.when(), Rule.array(), …), as Laravel's\n * ValidationRuleParser reads them: the rules expandRules() returns, given the data, take its place.\n */\nexport interface ExpandingRule extends ValidationRule {\n expandRules(data: Record<string, unknown>): string | ReadonlyArray<string | ValidationRule>\n}\n\nfunction isExpandingRule(item: unknown): item is ExpandingRule {\n return typeof item === 'object' && item !== null && typeof (item as Partial<ExpandingRule>).expandRules === 'function'\n}\n\nexport function parseRuleSpec(spec: string | ReadonlyArray<string | ValidationRule>, data: Record<string, unknown> = {}): ParsedRule[] {\n const items = typeof spec === 'string' ? spec.split('|') : spec\n return items\n .filter((item) => item !== '')\n .flatMap((item): ParsedRule[] => {\n if (isExpandingRule(item)) return parseRuleSpec(item.expandRules(data), data)\n if (typeof item !== 'string') return [{ kind: 'object', rule: item }]\n const [name, raw] = splitOnce(item, ':')\n return [{ kind: 'named', name, parameters: raw === undefined ? [] : splitParameters(name, raw) }]\n })\n}\n\n/**\n * Laravel's definition of \"empty\" for the required family (validateRequired()): null, undefined, text that is blank\n * once trimmed, an empty array and an empty plain object (a JSON object is a PHP array). false and 0 are NOT empty.\n */\nexport function isEmptyValue(value: unknown): boolean {\n if (value === null || value === undefined) return true\n if (typeof value === 'string') return value.trim() === ''\n if (Array.isArray(value)) return value.length === 0\n if (typeof value === 'object') {\n const proto: unknown = Object.getPrototypeOf(value)\n return (proto === Object.prototype || proto === null) && Object.keys(value).length === 0\n }\n return false\n}\n\n/** Duck-types Contracts/Http's UploadedFile without importing @orieljs/http. */\nexport function isUploadedFileLike(value: unknown): value is {\n clientName: string\n mimeType: string\n size: number\n extension(): string\n arrayBuffer(): Promise<ArrayBuffer>\n} {\n return (\n typeof value === 'object' &&\n value !== null &&\n typeof (value as Record<string, unknown>).clientName === 'string' &&\n typeof (value as Record<string, unknown>).arrayBuffer === 'function'\n )\n}\n\n/**\n * Keys that must never be followed or written when walking user input: assigning through them reaches\n * Object.prototype (or a constructor) instead of a plain data slot. Mirrors the guard in Arr.set.\n */\nexport const UNSAFE_KEYS: ReadonlySet<string> = new Set(['__proto__', 'prototype', 'constructor'])\n\n/**\n * Expands a `*`-wildcard rule pattern (e.g. \"items.*.name\") into every concrete path present in `data`\n * (e.g. [\"items.0.name\", \"items.1.name\"]). A pattern with no `*` is returned unchanged. A `*` segment whose\n * container is missing, not an array and not a plain object expands to nothing for that branch, so every reported\n * error is keyed by a concrete path, never the literal pattern. Object keys in UNSAFE_KEYS are\n * treated as absent, so a JSON body like {\"items\":{\"__proto__\":{...}}} never yields a path through the prototype.\n */\nexport function expandWildcardKeys(pattern: string, data: Record<string, unknown>): string[] {\n const segments = pattern.split('.')\n let paths = ['']\n for (const segment of segments) {\n const next: string[] = []\n for (const base of paths) {\n const prefix = base === '' ? '' : `${base}.`\n if (segment !== '*') {\n next.push(`${prefix}${segment}`)\n continue\n }\n const container = Arr.get<unknown>(data, base === '' ? undefined : base)\n if (Array.isArray(container)) {\n container.forEach((_, index) => next.push(`${prefix}${index}`))\n } else if (container !== null && typeof container === 'object') {\n Object.keys(container)\n .filter((key) => !UNSAFE_KEYS.has(key))\n .forEach((key) => next.push(`${prefix}${key}`))\n }\n }\n paths = next\n }\n return paths\n}\n","import { Arr } from '@orieljs/support'\nimport { defaultAttributeName } from '../messages'\nimport type { RuleContext } from '../parse'\nimport { isNumeric } from './type'\n\n/** PHP's truthiness, for a loose comparison with true or false. */\nexport function truthy(value: unknown): boolean {\n if (typeof value === 'string') return value !== '' && value !== '0'\n if (Array.isArray(value)) return value.length > 0\n return Boolean(value)\n}\n\n/** PHP 8's `==` between a field's value and a rule parameter (text, or true/false once converted). */\nexport function looseEquals(value: unknown, parameter: string | boolean): boolean {\n if (typeof parameter === 'boolean') return truthy(value) === parameter\n if (typeof value === 'number') return isNumeric(parameter) ? Number(parameter) === value : String(value) === parameter\n if (typeof value === 'string') return isNumeric(value) && isNumeric(parameter) ? Number(value) === Number(parameter) : value === parameter\n return false\n}\n\n/**\n * Laravel's parseDependentRuleParameters() and its in_array() check, for the `_if` and `_unless` rules: whether the\n * field named by the first parameter holds one of the others. `true`/`false` match a boolean (or a field with the\n * `boolean` rule, whose '1' and '0' they then match); `null` matches a null or missing field; numbers match their text.\n */\nexport function otherFieldMatches(ctx: RuleContext): boolean {\n const [field = '', ...listed] = ctx.parameters\n const other = Arr.get<unknown>(ctx.data, field)\n let values: Array<string | boolean | null> = listed\n if (typeof other === 'boolean' || ctx.getRule?.(field, 'boolean') !== undefined) {\n values = values.map((value) => (value === 'true' ? true : value === 'false' ? false : value))\n }\n if (other === null || other === undefined) {\n values = values.map((value) => (typeof value === 'string' && value.toLowerCase() === 'null' ? null : value))\n return values.includes(null)\n }\n if (typeof other === 'boolean') return values.includes(other)\n return values.some((value) => value !== null && looseEquals(other, value))\n}\n\n/** Laravel's getDisplayableValue(): how a message shows a value (true, false, empty, array, or its text). */\nexport function displayableValue(value: unknown): string {\n if (typeof value === 'boolean') return value ? 'true' : 'false'\n if (value === null || value === undefined) return 'empty'\n if (typeof value === 'object') return 'array'\n return String(value)\n}\n\n/** Laravel's getDisplayableAttribute(): the field's custom name, else its humanized key. */\nexport function displayName(ctx: RuleContext, field: string): string {\n return ctx.displayName?.(field) ?? defaultAttributeName(field)\n}\n\n/** `:other` and `:value` for the `_if` rules: the other field's name and the value it holds. */\nexport function otherAndValue(ctx: RuleContext): Record<string, string> {\n const field = ctx.parameters[0] ?? ''\n return { other: displayName(ctx, field), value: displayableValue(Arr.get(ctx.data, field)) }\n}\n\n/** `:other` and `:values` for the `_unless` rules: the other field's name and the values listed. */\nexport function otherAndValues(ctx: RuleContext): Record<string, string> {\n return { other: displayName(ctx, ctx.parameters[0] ?? ''), values: ctx.parameters.slice(1).join(', ') }\n}\n\n/** `:values` for the `_with` rules: the fields named, joined with \" / \". */\nexport function fieldList(ctx: RuleContext): Record<string, string> {\n return { values: ctx.parameters.map((field) => displayName(ctx, field)).join(' / ') }\n}\n","import type { BuiltinRule } from '../parse'\n\nconst BOOLEAN_VALUES: unknown[] = [true, false, 0, 1, '0', '1']\n\n/** PHP's is_numeric for strings: optional surrounding whitespace and sign, decimal digits, optional exponent. */\nconst NUMERIC_STRING_RE = /^\\s*[+-]?(?:\\d+(?:\\.\\d*)?|\\.\\d+)(?:[eE][+-]?\\d+)?\\s*$/\n\n/**\n * Laravel's `numeric` (PHP is_numeric): a finite number, or a decimal string. Unlike `Number()`, it rejects\n * \"Infinity\", hex/binary/octal literals (\"0x1F\", \"0b101\", \"0o7\") and the empty string.\n */\nexport function isNumeric(value: unknown): boolean {\n if (typeof value === 'number') return Number.isFinite(value)\n return typeof value === 'string' && NUMERIC_STRING_RE.test(value)\n}\n\n/** A JSON object: what PHP calls an associative array. */\nexport function isPlainObject(value: unknown): value is Record<string, unknown> {\n if (typeof value !== 'object' || value === null || Array.isArray(value)) return false\n const proto: unknown = Object.getPrototypeOf(value)\n return proto === Object.prototype || proto === null\n}\n\nexport const typeRules: Record<string, BuiltinRule> = {\n string: { validate: (ctx) => typeof ctx.value === 'string', messageKey: () => 'string' },\n /** `integer:strict` refuses the text of a number (Laravel's is_int()). */\n integer: {\n validate: (ctx) =>\n ctx.parameters[0] === 'strict'\n ? Number.isInteger(ctx.value)\n : typeof ctx.value !== 'object' && /^-?\\d+$/.test(String(ctx.value).trim()),\n messageKey: () => 'integer',\n },\n /** `numeric:strict` refuses the text of a number. */\n numeric: {\n validate: (ctx) => (ctx.parameters[0] === 'strict' ? typeof ctx.value === 'number' && Number.isFinite(ctx.value) : isNumeric(ctx.value)),\n messageKey: () => 'numeric',\n },\n /** `boolean:strict` lets only true and false through. */\n boolean: {\n validate: (ctx) => (ctx.parameters[0] === 'strict' ? typeof ctx.value === 'boolean' : BOOLEAN_VALUES.includes(ctx.value)),\n messageKey: () => 'boolean',\n },\n /**\n * `array`: a list. `array:name,email`: an object (PHP's associative array) whose keys are all among those named, as\n * Laravel's validateArray() with keys.\n */\n array: {\n validate: (ctx) => (ctx.parameters.length === 0 ? Array.isArray(ctx.value) : isPlainObject(ctx.value) && Object.keys(ctx.value).every((key) => ctx.parameters.includes(key))),\n messageKey: () => 'array',\n },\n}\n","import { Arr } from '@orieljs/support'\nimport type { BuiltinRule, RuleContext } from '../parse'\nimport { expandWildcardKeys } from '../parse'\nimport { displayName, looseEquals, truthy } from './dependent'\nimport { isNumeric, isPlainObject } from './type'\n\n/** PHP's in_array() comparison: `==` (a number and its text are alike), or `===` when strict. */\nexport function alike(a: unknown, b: unknown, strict = false): boolean {\n if (strict || a === b) return a === b\n if (typeof b === 'string' || typeof b === 'boolean') return looseEquals(a, b)\n if (typeof a === 'string' || typeof a === 'boolean') return looseEquals(b, a)\n return false\n}\n\nconst listed = (values: readonly string[]): Record<string, string> => ({ values: values.join(', ') })\n\n/** How `distinct` and `in_array` compare: PHP's loose `==` (alike()), `===`, or text in any case. */\ntype Comparison = 'loose' | 'strict' | 'ignore_case'\n\n/** Whether `value` matches `other` under the comparison (`value` is the field's own, as alike() reads it). */\nfunction matches(value: unknown, other: unknown, comparison: Comparison): boolean {\n if (comparison === 'strict') return value === other\n if (comparison === 'loose') return alike(value, other)\n return (typeof other === 'string' || typeof other === 'number') && String(other).toLowerCase() === String(value).toLowerCase()\n}\n\n/**\n * The classes PHP's `==` keeps apart for a string or finite number: numbers and numeric text by value, other text as\n * written. Anything else (booleans, null, objects, NaN and ±Infinity) has no class and is counted another way.\n */\nfunction looseClass(value: unknown): string | undefined {\n if (typeof value === 'number') return Number.isFinite(value) ? `n:${value}` : undefined\n if (typeof value === 'string') return isNumeric(value) ? `n:${Number(value)}` : `s:${value}`\n return undefined\n}\n\nconst increment = <K>(counts: Map<K, number>, key: K): Map<K, number> => counts.set(key, (counts.get(key) ?? 0) + 1)\n\n/**\n * The values of every field a pattern names (`colors.*`, `items.*.id`), counted so that how many of them a value\n * matches is answered without reading every row again, as Laravel keeps each pattern's values for the whole pass.\n */\nclass PatternValues {\n /** By identity (SameValueZero): strict comparison, and null, undefined and objects under loose comparison. */\n private readonly identical = new Map<unknown, number>()\n /** Strings and numbers by their lower-cased text. */\n private readonly text = new Map<string, number>()\n /** Strings and finite numbers by looseClass(). */\n private readonly classes = new Map<string, number>()\n /** Booleans by value: what a string, number, null or object equals loosely besides its own class. */\n private readonly booleans = new Map<boolean, number>()\n /** Every value but a string, by PHP truthiness: what a boolean equals loosely. */\n private readonly truthiness = new Map<boolean, number>()\n /** NaN and ±Infinity, compared one by one. */\n private readonly unclassed: unknown[] = []\n\n constructor(private readonly values: readonly unknown[]) {\n for (const value of values) {\n increment(this.identical, value)\n if (typeof value === 'string' || typeof value === 'number') increment(this.text, String(value).toLowerCase())\n const loose = looseClass(value)\n if (loose !== undefined) increment(this.classes, loose)\n else if (typeof value === 'number') this.unclassed.push(value)\n if (typeof value === 'boolean') increment(this.booleans, value)\n if (typeof value !== 'string') increment(this.truthiness, truthy(value))\n }\n }\n\n /** How many of the values `value` matches under the comparison. */\n count(value: unknown, comparison: Comparison): number {\n if (comparison === 'strict') return Number.isNaN(value) ? 0 : (this.identical.get(value) ?? 0)\n if (comparison === 'ignore_case') return this.text.get(String(value).toLowerCase()) ?? 0\n if (typeof value === 'boolean') return this.truthiness.get(value) ?? 0\n const loose = looseClass(value)\n if (loose === undefined && typeof value === 'number') return this.values.filter((other) => alike(value, other)).length\n const own = loose === undefined ? (this.identical.get(value) ?? 0) : (this.classes.get(loose) ?? 0) + this.unclassed.filter((other) => alike(value, other)).length\n return own + (this.booleans.get(truthy(value)) ?? 0)\n }\n\n /** The values of the fields `pattern` names in the context's data, gathered once per validation pass. */\n static of(ctx: RuleContext, pattern: string): PatternValues {\n const key = `array:values:${pattern}`\n const cached = ctx.cache?.get(key)\n if (cached instanceof PatternValues) return cached\n const fields = expandWildcardKeys(pattern, ctx.data).filter((field) => Arr.has(ctx.data, field))\n const values = new PatternValues(fields.map((field) => Arr.get<unknown>(ctx.data, field)))\n ctx.cache?.set(key, values)\n return values\n }\n}\n\nexport const arrayRules: Record<string, BuiltinRule> = {\n list: { validate: (ctx) => Array.isArray(ctx.value), messageKey: () => 'list' },\n required_array_keys: {\n validate: (ctx) => isPlainObject(ctx.value) && ctx.parameters.every((key) => Object.hasOwn(ctx.value as object, key)),\n messageKey: () => 'required_array_keys',\n replacements: (ctx) => listed(ctx.parameters),\n },\n in_array_keys: {\n validate: (ctx) => isPlainObject(ctx.value) && ctx.parameters.some((key) => Object.hasOwn(ctx.value as object, key)),\n messageKey: () => 'in_array_keys',\n replacements: (ctx) => listed(ctx.parameters),\n },\n /** Every value named is an item of the array (compared as PHP's in_array() does). */\n contains: {\n validate: (ctx) => {\n const items = ctx.value\n return Array.isArray(items) && ctx.parameters.every((needle) => items.some((item) => alike(item, needle)))\n },\n messageKey: () => 'contains',\n },\n doesnt_contain: {\n validate: (ctx) => {\n const items = ctx.value\n return Array.isArray(items) && !ctx.parameters.some((needle) => items.some((item) => alike(item, needle)))\n },\n messageKey: () => 'doesnt_contain',\n replacements: (ctx) => listed(ctx.parameters),\n },\n /**\n * Laravel's validateDistinct(): no other field under the same wildcard holds this value. `distinct:strict` compares\n * with `===`; `distinct:ignore_case` compares text case-insensitively.\n */\n distinct: {\n validate: (ctx) => {\n const comparison: Comparison = ctx.parameters.includes('ignore_case') ? 'ignore_case' : ctx.parameters.includes('strict') ? 'strict' : 'loose'\n const own = Arr.has(ctx.data, ctx.attribute) && matches(ctx.value, Arr.get(ctx.data, ctx.attribute), comparison) ? 1 : 0\n return PatternValues.of(ctx, ctx.pattern ?? ctx.attribute).count(ctx.value, comparison) - own === 0\n },\n messageKey: () => 'distinct',\n },\n /** The value is one of the values of the fields the parameter names (`in_array:colors.*`). */\n in_array: {\n validate: (ctx) => PatternValues.of(ctx, ctx.parameters[0] ?? '').count(ctx.value, 'loose') > 0,\n messageKey: () => 'in_array',\n replacements: (ctx) => ({ other: displayName(ctx, ctx.parameters[0] ?? '') }),\n },\n}\n","import { AuthFactory, Hasher } from '@orieljs/contracts'\nimport { inject } from '@orieljs/container'\nimport type { BuiltinRule } from '../parse'\n\n/** `current_password` / `current_password:<guard>`: the value is the signed-in user's password (Laravel). */\nexport const authRules: Record<string, BuiltinRule> = {\n current_password: {\n validate: async (ctx) => {\n const guard = inject(AuthFactory).guard(ctx.parameters[0])\n if (await guard.guest()) return false\n const user = await guard.user()\n return user !== undefined && typeof ctx.value === 'string' && inject(Hasher).check(ctx.value, user.getAuthPassword())\n },\n messageKey: () => 'current_password',\n },\n}\n","import { DatabaseManager } from '@orieljs/contracts'\nimport { inject } from '@orieljs/container'\nimport type { BuiltinRule } from '../parse'\n\n/**\n * The column to query when a unique/exists rule doesn't name one: the attribute itself, except for a\n * wildcard-expanded field like \"items.0.email\", which checks the last non-numeric segment (\"email\") rather than a\n * column literally named after the path (Laravel's guessColumnForQuery).\n */\nexport function guessColumn(attribute: string, expandedFromWildcard = false): string {\n if (!expandedFromWildcard) return attribute\n return attribute.split('.').filter((segment) => !/^\\d+$/.test(segment)).at(-1) ?? attribute\n}\n\n/** Laravel's idiom `unique:users,email,NULL,id` (and an empty or null ignore) means \"exclude nothing\". */\nfunction isNoExcept(except: unknown): boolean {\n return except === undefined || except === null || except === '' || except === 'NULL'\n}\n\n/**\n * Shared query shape behind both `unique`/`exists` string rules and `Rule.unique()`/`Rule.exists()`:\n * resolve DatabaseManager, filter table/column on value, optionally exclude a record by idColumn/except, and\n * report whether any row matches. Kept in one place so a future fix to this path can't miss one of the two callers.\n */\nexport async function matchingRecordExists(\n table: string,\n column: string,\n value: unknown,\n except?: unknown,\n idColumn = 'id',\n): Promise<boolean> {\n const db = inject(DatabaseManager)\n let query = db.connection().table(table).where(column, value)\n if (!isNoExcept(except)) query = query.where(idColumn, '!=', except)\n return query.exists()\n}\n\nexport const databaseRules: Record<string, BuiltinRule> = {\n unique: {\n validate: async (ctx) => {\n const [table, column, except, idColumn] = ctx.parameters\n return !(await matchingRecordExists(table!, column || guessColumn(ctx.attribute, ctx.expandedFromWildcard), ctx.value, except, idColumn || 'id'))\n },\n messageKey: () => 'unique',\n },\n exists: {\n validate: async (ctx) => {\n const [table, column] = ctx.parameters\n return matchingRecordExists(table!, column || guessColumn(ctx.attribute, ctx.expandedFromWildcard), ctx.value)\n },\n messageKey: () => 'exists',\n },\n}\n","import { Arr } from '@orieljs/support'\nimport { assertSupportedFormat, matchesFormat, timestampWithFormat } from '../dates/phpFormat'\nimport { InvalidRuleParameterError } from '../errors'\nimport type { BuiltinRule, RuleContext } from '../parse'\nimport { displayName } from './dependent'\n\n/**\n * Shapes a string must have before it counts as a date. Date.parse alone is far too lenient (V8 reads \"1\" as the\n * year 2001), so a value needs an ISO date, a slashed/dotted/dashed day-month-year, or a month name with a number.\n */\nconst DATE_SHAPES = [\n /^\\d{4}-\\d{1,2}-\\d{1,2}(?:[T\\s].*)?$/,\n /^\\d{1,2}[/.-]\\d{1,2}[/.-]\\d{2,4}(?:\\s.*)?$/,\n /^(?=.*\\d).*\\b(?:jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)[a-z]*\\b/i,\n]\nconst DATE_ONLY_RE = /^(\\d{4})-(\\d{2})-(\\d{2})$/\n\n/**\n * Parses a user-supplied date string to epoch milliseconds, or NaN. A bare YYYY-MM-DD means local midnight, like\n * PHP's strtotime, so it compares sensibly against `today`/`tomorrow`.\n */\nfunction parseDate(value: string): number {\n const trimmed = value.trim()\n if (!DATE_SHAPES.some((shape) => shape.test(trimmed))) return Number.NaN\n const dateOnly = DATE_ONLY_RE.exec(trimmed)\n if (dateOnly) {\n const [, y, m, d] = dateOnly.map(Number) as [number, number, number, number]\n const local = new Date(y, m - 1, d)\n return local.getMonth() === m - 1 && local.getDate() === d ? local.getTime() : Number.NaN\n }\n return Date.parse(trimmed)\n}\n\nfunction startOfDay(offsetDays: number): number {\n const date = new Date()\n date.setHours(0, 0, 0, 0)\n date.setDate(date.getDate() + offsetDays)\n return date.getTime()\n}\n\nconst RELATIVE_RE = /^([+-]\\d+)\\s*(second|minute|hour|day|week|month|year)s?$/i\n\n/** strtotime's keywords (today, tomorrow, yesterday, now) and \"+N unit\"/\"-N unit\" offsets from now, or undefined. */\nfunction relativeDate(param: string): number | undefined {\n switch (param.trim().toLowerCase()) {\n case 'now':\n return Date.now()\n case 'today':\n return startOfDay(0)\n case 'tomorrow':\n return startOfDay(1)\n case 'yesterday':\n return startOfDay(-1)\n }\n const match = RELATIVE_RE.exec(param.trim())\n if (!match) return undefined\n const amount = Number(match[1])\n const date = new Date()\n switch (match[2]!.toLowerCase()) {\n case 'second':\n date.setSeconds(date.getSeconds() + amount)\n break\n case 'minute':\n date.setMinutes(date.getMinutes() + amount)\n break\n case 'hour':\n date.setHours(date.getHours() + amount)\n break\n case 'day':\n date.setDate(date.getDate() + amount)\n break\n case 'week':\n date.setDate(date.getDate() + amount * 7)\n break\n case 'month':\n date.setMonth(date.getMonth() + amount)\n break\n case 'year':\n date.setFullYear(date.getFullYear() + amount)\n break\n }\n return date.getTime()\n}\n\n/** An attribute path such as \"starts_at\" or \"event.starts_at\". */\nconst FIELD_REFERENCE_RE = /^[A-Za-z_][\\w-]*(?:\\.[\\w-]+)*$/\n\n/** What PHP's is_numeric() and is_string() let through to Laravel's date comparisons (no booleans, arrays or NaN). */\ntype DateInput = string | number\n\nconst isDateInput = (value: unknown): value is DateInput =>\n typeof value === 'string' || (typeof value === 'number' && Number.isFinite(value))\n\n/**\n * Resolves a before/after parameter, in order: another field's date value, a relative keyword/offset, a literal\n * date. A parameter shaped like a field name whose field is missing, null or not a date gives null, Laravel's \"no\n * date\" (compareDates() decides what that means). Anything else that can't be parsed is a mistake in the rule itself,\n * so it throws a 'Server' error instead of blaming the user's input.\n */\nfunction resolveDateParam(ctx: RuleContext, rule: string, param: string, format: string | undefined): number | null {\n const fieldValue = Arr.get<unknown>(ctx.data, param)\n if (isDateInput(fieldValue)) {\n // Laravel's checkDateTimeOrder(): the other field is read with its own date_format, else this field's.\n const parsed = readDate(fieldValue, ctx.getRule?.(param, 'date_format')?.[0] ?? format)\n if (!Number.isNaN(parsed)) return parsed\n }\n const relative = relativeDate(param)\n if (relative !== undefined) return relative\n const literal = readDate(param, format)\n if (!Number.isNaN(literal)) return literal\n if (FIELD_REFERENCE_RE.test(param)) return null\n throw new InvalidRuleParameterError(rule, param, 'expected a date, today/tomorrow/yesterday/now, \"+N unit\", or a field name')\n}\n\n/**\n * A date read with the format when one is given and the value fits it, else as Laravel's getDateTime() reads it: a\n * number is seconds since the epoch (Carbon::parse()), text is read as the date rule reads it.\n */\nfunction readDate(value: DateInput, format: string | undefined): number {\n if (format !== undefined) {\n const formatted = timestampWithFormat(format, String(value))\n if (!Number.isNaN(formatted)) return formatted\n }\n return typeof value === 'number' ? value * 1000 : parseDate(value)\n}\n\ntype DateRule = 'before' | 'before_or_equal' | 'after' | 'after_or_equal' | 'date_equals'\n\nconst COMPARE: Record<DateRule, (value: number, target: number) => boolean> = {\n before: (value, target) => value < target,\n before_or_equal: (value, target) => value <= target,\n after: (value, target) => value > target,\n after_or_equal: (value, target) => value >= target,\n date_equals: (value, target) => value === target,\n}\n\n/**\n * Laravel's compareDates(): the value (text or a number) against the parameter (another field's date,\n * today/tomorrow/…, or a date). When the field has date_format, the value and a literal parameter are read with that\n * format.\n */\nfunction compareDates(ctx: RuleContext, rule: DateRule): boolean {\n const format = ctx.getRule?.(ctx.attribute, 'date_format')?.[0]\n const param = ctx.parameters[0] ?? ''\n const target = resolveDateParam(ctx, rule, param, format)\n if (!isDateInput(ctx.value)) return false\n if (target === null && format !== undefined) {\n // checkDateTimeOrder(): an other field that is missing or null passes; one that holds something else fails.\n return Arr.get<unknown>(ctx.data, param) == null\n }\n const value = readDate(ctx.value, format)\n if (Number.isNaN(value)) return false\n if (target === null) {\n // compare() with a null date: PHP compares the value's timestamp with null as booleans (true unless it is 0).\n return COMPARE[rule](Math.trunc(value / 1000) === 0 ? 0 : 1, 0)\n }\n return COMPARE[rule](value, target)\n}\n\n/**\n * Laravel's replaceBefore(): `:date` is the parameter as written when it reads as a date (a keyword, a date, or a\n * literal in the field's date_format), else the name of the field it refers to.\n */\nfunction dateReplacement(ctx: RuleContext): Record<string, string> {\n const param = ctx.parameters[0] ?? ''\n const format = ctx.getRule?.(ctx.attribute, 'date_format')?.[0]\n const isDate = relativeDate(param) !== undefined || !Number.isNaN(readDate(param, format))\n return { date: isDate && !Arr.has(ctx.data, param) ? param : displayName(ctx, param) }\n}\n\nconst comparison = (rule: DateRule): BuiltinRule => ({\n validate: (ctx) => compareDates(ctx, rule),\n messageKey: () => rule,\n replacements: dateReplacement,\n})\n\nexport const dateRules: Record<string, BuiltinRule> = {\n date: {\n validate: (ctx) => typeof ctx.value === 'string' && !Number.isNaN(parseDate(ctx.value)),\n messageKey: () => 'date',\n },\n before: comparison('before'),\n before_or_equal: comparison('before_or_equal'),\n after: comparison('after'),\n after_or_equal: comparison('after_or_equal'),\n date_equals: comparison('date_equals'),\n /**\n * Laravel's validateDateFormat(): the value (text, or a number) reads with one of the formats (PHP's characters,\n * `date_format:Y-m-d,d/m/Y`) and formats back to the same text, so `2026-02-30` and `2026-2-28` fail `Y-m-d`.\n */\n date_format: {\n validate: (ctx) => {\n for (const format of ctx.parameters) assertSupportedFormat('date_format', format)\n if (typeof ctx.value !== 'string' && !(typeof ctx.value === 'number' && Number.isFinite(ctx.value))) return false\n const text = String(ctx.value)\n return ctx.parameters.some((format) => matchesFormat(format, text))\n },\n messageKey: () => 'date_format',\n replacements: (ctx) => ({ format: ctx.parameters[0] ?? '' }),\n },\n}\n","import { InvalidRuleParameterError } from '../errors'\n\n/**\n * PHP's DateTime::createFromFormat('!' . $format) and DateTime::format($format), for the format characters a date\n * format rule can round-trip: d j D l S F M m n Y y a A g h G H i s v u O P p U, `\\` to escape a character, and any\n * other character as itself. Unparsed fields are those of 1970-01-01 00:00:00, as with PHP's leading `!`.\n */\n\nconst DAYS = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']\nconst MONTHS = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']\n\n/** PHP's format characters this module doesn't read: a format using one is a mistake in the rule. */\nconst UNSUPPORTED = new Set(['z', 'W', 't', 'L', 'o', 'X', 'x', 'B', 'e', 'I', 'T', 'Z', 'c', 'r', 'N', 'w', '#', '?', '*', '+'])\n\ninterface Fields {\n year: number\n month: number\n day: number\n hour: number\n minute: number\n second: number\n micro: number\n /** Minutes east of UTC, when the value names its offset. */\n offset: number | undefined\n /** Seconds since the epoch, when the format has U. */\n unix: number | undefined\n}\n\nconst pad = (value: number, length: number): string => String(Math.abs(value)).padStart(length, '0')\n\nfunction suffix(day: number): string {\n if (day % 100 >= 11 && day % 100 <= 13) return 'th'\n return ['th', 'st', 'nd', 'rd'][day % 10] ?? 'th'\n}\n\nfunction formatOffset(offset: number, colon: boolean): string {\n const sign = offset < 0 ? '-' : '+'\n return `${sign}${pad(Math.trunc(Math.abs(offset) / 60), 2)}${colon ? ':' : ''}${pad(Math.abs(offset) % 60, 2)}`\n}\n\n/** Reads the value against the format; undefined when it doesn't fit (PHP's createFromFormat() returning false). */\nfunction parse(format: string, value: string): Fields | undefined {\n const fields: Fields = { year: 1970, month: 1, day: 1, hour: 0, minute: 0, second: 0, micro: 0, offset: undefined, unix: undefined }\n let meridiem: 'am' | 'pm' | undefined\n let twelveHour = false\n let position = 0\n\n const digits = (min: number, max: number): number | undefined => {\n const match = new RegExp(`^\\\\d{${min},${max}}`).exec(value.slice(position))\n if (!match) return undefined\n position += match[0].length\n return Number(match[0])\n }\n const word = (names: readonly string[], short: boolean): number | undefined => {\n const match = /^[A-Za-z]+/.exec(value.slice(position))\n if (!match) return undefined\n const text = match[0].toLowerCase()\n const index = names.findIndex((name) => name.toLowerCase() === text || (short && name.slice(0, 3).toLowerCase() === text))\n if (index === -1) return undefined\n position += match[0].length\n return index\n }\n const offset = (colon: 'required' | 'none' | 'z'): number | undefined => {\n const rest = value.slice(position)\n if (colon === 'z' && rest.startsWith('Z')) {\n position += 1\n return 0\n }\n const match = (colon === 'none' ? /^([+-])(\\d{2})(\\d{2})/ : /^([+-])(\\d{2}):(\\d{2})/).exec(rest)\n if (!match) return undefined\n position += match[0].length\n return (match[1] === '-' ? -1 : 1) * (Number(match[2]) * 60 + Number(match[3]))\n }\n\n for (let i = 0; i < format.length; i++) {\n const char = format[i]!\n let read: number | undefined = 0\n switch (char) {\n case '!':\n case '|':\n continue\n case '\\\\':\n i++\n if (value[position] !== format[i]) return undefined\n position++\n continue\n case 'd':\n case 'j':\n read = digits(1, 2)\n if (read !== undefined) fields.day = read\n break\n case 'D':\n case 'l':\n read = word(DAYS, true)\n break\n case 'S':\n if (!/^(st|nd|rd|th)/i.test(value.slice(position))) return undefined\n position += 2\n break\n case 'F':\n case 'M':\n read = word(MONTHS, true)\n if (read !== undefined) fields.month = read + 1\n break\n case 'm':\n case 'n':\n read = digits(1, 2)\n if (read !== undefined) fields.month = read\n break\n case 'Y':\n read = digits(1, 4)\n if (read !== undefined) fields.year = read\n break\n case 'y':\n read = digits(2, 2)\n if (read !== undefined) fields.year = read + (read < 70 ? 2000 : 1900)\n break\n case 'a':\n case 'A': {\n const match = /^(am|pm)/i.exec(value.slice(position))\n if (!match) return undefined\n position += 2\n meridiem = match[1]!.toLowerCase() as 'am' | 'pm'\n break\n }\n case 'g':\n case 'h':\n read = digits(1, 2)\n if (read !== undefined && (read < 1 || read > 12)) return undefined\n if (read !== undefined) fields.hour = read\n twelveHour = true\n break\n case 'G':\n case 'H':\n read = digits(1, 2)\n if (read !== undefined) fields.hour = read\n break\n case 'i':\n read = digits(2, 2)\n if (read !== undefined) fields.minute = read\n break\n case 's':\n read = digits(2, 2)\n if (read !== undefined) fields.second = read\n break\n case 'v':\n read = digits(3, 3)\n if (read !== undefined) fields.micro = read * 1000\n break\n case 'u': {\n const match = /^\\d{1,6}/.exec(value.slice(position))\n read = match ? Number(match[0].padEnd(6, '0')) : undefined\n if (match) position += match[0].length\n if (read !== undefined) fields.micro = read\n break\n }\n case 'O':\n read = fields.offset = offset('none')\n break\n case 'P':\n read = fields.offset = offset('required')\n break\n case 'p':\n read = fields.offset = offset('z')\n break\n case 'U': {\n const match = /^-?\\d+/.exec(value.slice(position))\n read = match ? Number(match[0]) : undefined\n if (match) position += match[0].length\n fields.unix = read\n break\n }\n default:\n if (value[position] !== char) return undefined\n position++\n continue\n }\n if (read === undefined) return undefined\n }\n if (position !== value.length) return undefined\n if (twelveHour && meridiem !== undefined) fields.hour = (fields.hour % 12) + (meridiem === 'pm' ? 12 : 0)\n return fields\n}\n\n/**\n * The fields as a Date whose UTC fields are the value's wall clock (overflowing fields roll over, as PHP's do). The\n * setters keep years below 100 as they are (Date.UTC() would read 26 as 1926).\n */\nfunction wallClock(fields: Fields): Date {\n if (fields.unix !== undefined) return new Date(fields.unix * 1000)\n const date = new Date(0)\n date.setUTCFullYear(fields.year, fields.month - 1, fields.day)\n date.setUTCHours(fields.hour, fields.minute, fields.second, Math.floor(fields.micro / 1000))\n return date\n}\n\n/** PHP's DateTime::format() for the supported characters, reading the UTC fields of `date` in the value's offset. */\nfunction format(format: string, date: Date, micro: number, offset: number): string {\n let out = ''\n for (let i = 0; i < format.length; i++) {\n const char = format[i]!\n const day = date.getUTCDate()\n const hour = date.getUTCHours()\n switch (char) {\n case '!':\n case '|':\n break\n case '\\\\':\n i++\n out += format[i] ?? ''\n break\n case 'd': out += pad(day, 2); break\n case 'j': out += String(day); break\n case 'D': out += DAYS[date.getUTCDay()]!.slice(0, 3); break\n case 'l': out += DAYS[date.getUTCDay()]!; break\n case 'S': out += suffix(day); break\n case 'F': out += MONTHS[date.getUTCMonth()]!; break\n case 'M': out += MONTHS[date.getUTCMonth()]!.slice(0, 3); break\n case 'm': out += pad(date.getUTCMonth() + 1, 2); break\n case 'n': out += String(date.getUTCMonth() + 1); break\n case 'Y': out += pad(date.getUTCFullYear(), 4); break\n case 'y': out += pad(date.getUTCFullYear() % 100, 2); break\n case 'a': out += hour < 12 ? 'am' : 'pm'; break\n case 'A': out += hour < 12 ? 'AM' : 'PM'; break\n case 'g': out += String(hour % 12 || 12); break\n case 'h': out += pad(hour % 12 || 12, 2); break\n case 'G': out += String(hour); break\n case 'H': out += pad(hour, 2); break\n case 'i': out += pad(date.getUTCMinutes(), 2); break\n case 's': out += pad(date.getUTCSeconds(), 2); break\n case 'v': out += pad(Math.floor(micro / 1000), 3); break\n case 'u': out += pad(micro, 6); break\n case 'O': out += formatOffset(offset, false); break\n case 'P': out += formatOffset(offset, true); break\n case 'p': out += offset === 0 ? 'Z' : formatOffset(offset, true); break\n case 'U': out += String(Math.floor(date.getTime() / 1000)); break\n default: out += char\n }\n }\n return out\n}\n\n/** Throws InvalidRuleParameterError for a format character this module can't read (a developer error, a 500). */\nexport function assertSupportedFormat(rule: string, dateFormat: string): void {\n for (let i = 0; i < dateFormat.length; i++) {\n if (dateFormat[i] === '\\\\') i++\n else if (UNSUPPORTED.has(dateFormat[i]!)) {\n throw new InvalidRuleParameterError(rule, dateFormat, `the format character \"${dateFormat[i]!}\" is not supported`)\n }\n }\n}\n\n/** Laravel's validateDateFormat() for one format: the value reads with it and formats back to the same text. */\nexport function matchesFormat(dateFormat: string, value: string): boolean {\n const fields = parse(dateFormat, value)\n if (!fields) return false\n const offset = fields.offset ?? 0\n return format(dateFormat, wallClock(fields), fields.micro, offset) === value\n}\n\n/**\n * The epoch milliseconds the value names when read with the format, or NaN. A value without an offset (and without U)\n * is local time, like the other date rules' bare dates.\n */\nexport function timestampWithFormat(dateFormat: string, value: string): number {\n const fields = parse(dateFormat, value)\n if (!fields) return Number.NaN\n if (fields.unix !== undefined) return fields.unix * 1000\n const utc = wallClock(fields).getTime()\n if (fields.offset !== undefined) return utc - fields.offset * 60_000\n const local = new Date(0)\n local.setFullYear(fields.year, fields.month - 1, fields.day)\n local.setHours(fields.hour, fields.minute, fields.second, Math.floor(fields.micro / 1000))\n return local.getTime()\n}\n","import { Arr } from '@orieljs/support'\nimport type { BuiltinRule } from '../parse'\nimport { isEmptyValue } from '../parse'\nimport { otherFieldMatches } from './dependent'\n\n/** Laravel's exclude rules: validate() returning false takes the field out (BuiltinRule.excludes). */\nexport const excludeRules: Record<string, BuiltinRule> = {\n exclude: { excludes: true, validate: () => false, messageKey: () => 'exclude' },\n /** Excluded when the other field holds one of the values; nothing happens while the other field is missing. */\n exclude_if: {\n excludes: true,\n validate: (ctx) => !Arr.has(ctx.data, ctx.parameters[0] ?? '') || !otherFieldMatches(ctx),\n messageKey: () => 'exclude_if',\n },\n exclude_unless: { excludes: true, validate: (ctx) => otherFieldMatches(ctx), messageKey: () => 'exclude_unless' },\n /** Excluded while the other field's key is there. */\n exclude_with: { excludes: true, validate: (ctx) => !Arr.has(ctx.data, ctx.parameters[0] ?? ''), messageKey: () => 'exclude_with' },\n /** Excluded while any field named is missing or empty. */\n exclude_without: {\n excludes: true,\n validate: (ctx) => !ctx.parameters.some((field) => isEmptyValue(Arr.get(ctx.data, field))),\n messageKey: () => 'exclude_without',\n },\n}\n","import { FileType } from '@orieljs/support'\nimport { InvalidRuleParameterError } from '../errors'\nimport { imageDimensions, type Dimensions } from '../files/dimensions'\nimport type { BuiltinRule, RuleContext } from '../parse'\nimport { isUploadedFileLike } from '../parse'\n\nconst { BINARY_AND_MARKUP_TYPES, detectFileType, EMPTY, RASTER_IMAGES, SVG, TEXT } = FileType\ntype DetectedType = FileType.DetectedType\n\ninterface Upload {\n clientName: string\n arrayBuffer(): Promise<ArrayBuffer>\n}\n\n/** What an upload's bytes show: its type and, for a raster image, its pixel size. */\ninterface Inspection {\n type: DetectedType\n dimensions: Dimensions | undefined\n}\n\nconst inspections = new WeakMap<object, Promise<Inspection>>()\n\n/** Reads an upload's bytes once per file object, however many file rules look at it. */\nfunction inspect(file: Upload): Promise<Inspection> {\n let inspection = inspections.get(file)\n if (!inspection) {\n inspection = file.arrayBuffer().then((buffer) => {\n const bytes = new Uint8Array(buffer)\n const type = detectFileType(bytes)\n return { type, dimensions: RASTER_IMAGES.has(type.mime) ? imageDimensions(bytes, type.mime) : undefined }\n })\n inspections.set(file, inspection)\n }\n return inspection\n}\n\n/** The extension of the file name the client sent, lower-cased ('' when it has none). */\nfunction clientExtension(file: Upload): string {\n const name = file.clientName.slice(Math.max(file.clientName.lastIndexOf('/'), file.clientName.lastIndexOf('\\\\')) + 1)\n const dot = name.lastIndexOf('.')\n return dot === -1 ? '' : name.slice(dot + 1).trim().toLowerCase()\n}\n\nconst PHP_EXTENSIONS: ReadonlySet<string> = new Set(['php', 'php3', 'php4', 'php5', 'php7', 'php8', 'phtml', 'phar'])\n\n/** Laravel's shouldBlockPhpUpload(): a file named like a PHP script fails the file rules unless the list names php. */\nconst blocksPhp = (file: Upload, allowed: readonly string[]): boolean => !allowed.includes('php') && PHP_EXTENSIONS.has(clientExtension(file))\n\n/** Text formats whose bytes look like any plain text: the client's extension tells them apart, for text bytes only. */\nconst TEXT_FORMATS: ReadonlySet<string> = new Set(['txt', 'text', 'csv', 'tsv', 'json', 'md'])\n\n/** The extensions of the formats recognised by their bytes: a file name alone never earns one. */\nconst RECOGNISED_EXTENSIONS: ReadonlySet<string> = new Set(BINARY_AND_MARKUP_TYPES.flatMap(({ extensions }) => extensions))\n\nconst lower = (values: readonly string[]): string[] => values.map((value) => value.trim().toLowerCase())\n\n/**\n * mimes: the detected type must be one the list names (jpg and jpeg are one, as in Laravel).\n * - A format recognised by its bytes (images, SVG, PDF, HTML, XML) passes only by its own extensions.\n * - Plain text passes `txt`, or the client's extension when that names no recognised format (`csv`, `json`, `yaml`, …).\n * - Bytes no format matches (docx, zip, mp4, …) pass by the client's extension, unless that extension names a\n * recognised format or a text format, which the bytes would have shown.\n * - An empty file fails.\n */\nfunction meetsMimes(type: DetectedType, extension: string, allowed: ReadonlySet<string>): boolean {\n if (type === EMPTY) return false\n if (type === TEXT && allowed.has('txt')) return true\n if (type !== TEXT && type.extensions.length > 0) return type.extensions.some((name) => allowed.has(name))\n if (!allowed.has(extension) || RECOGNISED_EXTENSIONS.has(extension)) return false\n return type === TEXT || !TEXT_FORMATS.has(extension)\n}\n\nfunction allowedExtensions(ctx: RuleContext): Set<string> {\n const allowed = new Set(lower(ctx.parameters))\n if (allowed.has('jpg') || allowed.has('jpeg')) allowed.add('jpg').add('jpeg')\n return allowed\n}\n\nconst listed = (ctx: RuleContext): Record<string, string> => ({ values: ctx.parameters.join(', ') })\n\nconst DIMENSION_KEYS = ['width', 'height', 'min_width', 'min_height', 'max_width', 'max_height', 'ratio'] as const\ntype DimensionKey = (typeof DIMENSION_KEYS)[number]\ntype DimensionConstraints = Partial<Record<DimensionKey, number>>\n\n/** 'min_width=800' → ['min_width', '800']. */\nfunction namedParameter(parameter: string): [string, string] {\n const at = parameter.indexOf('=')\n return at === -1 ? [parameter, ''] : [parameter.slice(0, at), parameter.slice(at + 1)]\n}\n\n/** '3/2' or '1.5' (Laravel reads a ratio as a number, optionally over a whole number). */\nfunction parseRatio(value: string): number | undefined {\n const match = /^(\\d+(?:\\.\\d+)?|\\.\\d+)(?:\\/(\\d+))?$/.exec(value.trim())\n if (!match) return undefined\n const ratio = Number(match[1]) / Number(match[2] ?? 1)\n return Number.isFinite(ratio) && ratio > 0 ? ratio : undefined\n}\n\n/** dimensions' parameters as numbers. A name Oriel doesn't know or a value it can't read is a developer error. */\nfunction dimensionConstraints(parameters: readonly string[]): DimensionConstraints {\n if (parameters.length === 0) throw new InvalidRuleParameterError('dimensions', '', `expected one or more of ${DIMENSION_KEYS.join(', ')}`)\n const constraints: DimensionConstraints = {}\n for (const parameter of parameters) {\n const [key, value] = namedParameter(parameter)\n if (!(DIMENSION_KEYS as readonly string[]).includes(key)) {\n throw new InvalidRuleParameterError('dimensions', parameter, `expected one of ${DIMENSION_KEYS.join(', ')}`)\n }\n const number = key === 'ratio' ? parseRatio(value) : /^\\d+$/.test(value) ? Number(value) : undefined\n if (number === undefined) {\n throw new InvalidRuleParameterError('dimensions', parameter, key === 'ratio' ? 'expected a ratio such as 3/2 or 1.5' : 'expected a whole number of pixels')\n }\n constraints[key as DimensionKey] = number\n }\n return constraints\n}\n\n/** Laravel's failsBasicDimensionChecks() and failsRatioCheck(), inverted. */\nfunction meetsDimensions(constraints: DimensionConstraints, { width, height }: Dimensions): boolean {\n const { width: exactWidth, height: exactHeight, min_width, max_width, min_height, max_height, ratio } = constraints\n if (exactWidth !== undefined && width !== exactWidth) return false\n if (exactHeight !== undefined && height !== exactHeight) return false\n if (min_width !== undefined && width < min_width) return false\n if (max_width !== undefined && width > max_width) return false\n if (min_height !== undefined && height < min_height) return false\n if (max_height !== undefined && height > max_height) return false\n // The tolerance is Laravel's: about one pixel at the image's size.\n return ratio === undefined || Math.abs(ratio - width / height) <= 1 / (Math.max((width + height) / 2, height) + 1)\n}\n\nexport const fileRules: Record<string, BuiltinRule> = {\n file: { validate: (ctx) => isUploadedFileLike(ctx.value), messageKey: () => 'file' },\n\n /** A JPEG, PNG, GIF, WebP, AVIF or BMP by its bytes; SVG only as `image:allow_svg` (Laravel 12). */\n image: {\n validate: async (ctx) => {\n if (!isUploadedFileLike(ctx.value) || blocksPhp(ctx.value, [])) return false\n const { type } = await inspect(ctx.value)\n return RASTER_IMAGES.has(type.mime) || (type === SVG && ctx.parameters.includes('allow_svg'))\n },\n messageKey: () => 'image',\n },\n\n mimes: {\n validate: async (ctx) => {\n if (!isUploadedFileLike(ctx.value)) return false\n const allowed = allowedExtensions(ctx)\n if (blocksPhp(ctx.value, [...allowed])) return false\n return meetsMimes((await inspect(ctx.value)).type, clientExtension(ctx.value), allowed)\n },\n messageKey: () => 'mimes',\n replacements: listed,\n },\n\n /**\n * The detected MIME type is listed, or its `type/*` wildcard is. `image/*` includes SVG (`image/svg+xml`), as in\n * Laravel: the rule for photos is `image`.\n */\n mimetypes: {\n validate: async (ctx) => {\n if (!isUploadedFileLike(ctx.value)) return false\n const allowed = lower(ctx.parameters)\n if (blocksPhp(ctx.value, allowed)) return false\n const { mime } = (await inspect(ctx.value)).type\n return allowed.includes(mime) || allowed.includes(`${mime.split('/')[0]}/*`)\n },\n messageKey: () => 'mimetypes',\n replacements: listed,\n },\n\n /**\n * The pixel size read from the image's header meets every constraint: width, height, min_width, max_width,\n * min_height, max_height, ratio. SVG and images whose header can't be read fail.\n */\n dimensions: {\n validate: async (ctx) => {\n const constraints = dimensionConstraints(ctx.parameters)\n if (!isUploadedFileLike(ctx.value)) return false\n const { dimensions } = await inspect(ctx.value)\n return dimensions !== undefined && meetsDimensions(constraints, dimensions)\n },\n messageKey: () => 'dimensions',\n replacements: (ctx) => Object.fromEntries(ctx.parameters.map(namedParameter)),\n },\n\n /** The client file name's extension is listed (Laravel 11). It checks the name only: pair it with mimes or image. */\n extensions: {\n validate: (ctx) => {\n if (!isUploadedFileLike(ctx.value)) return false\n const allowed = lower(ctx.parameters)\n return !blocksPhp(ctx.value, allowed) && allowed.includes(clientExtension(ctx.value))\n },\n messageKey: () => 'extensions',\n replacements: listed,\n },\n}\n","/** An image's size in pixels, as its header declares it (what PHP's getimagesize() reports for Laravel). */\nexport interface Dimensions {\n readonly width: number\n readonly height: number\n}\n\ntype Reader = (view: DataView) => Dimensions | undefined\n\n/** JPEG frame headers (SOF0–SOF15, without DHT, JPG and DAC), baseline, progressive or lossless. */\nconst FRAME_MARKERS: ReadonlySet<number> = new Set([0xc0, 0xc1, 0xc2, 0xc3, 0xc5, 0xc6, 0xc7, 0xc9, 0xca, 0xcb, 0xcd, 0xce, 0xcf])\n\n/** The steps (a fill byte, a marker or a segment each) a JPEG gets to reach its frame header; real ones need a few dozen. */\nconst MAX_JPEG_STEPS = 1024\n\n/** The boxes one ISO-BMFF walk reads; real images have a handful at each level. */\nconst MAX_BOXES = 1024\n\nconst fourcc = (view: DataView, offset: number): string =>\n String.fromCharCode(view.getUint8(offset), view.getUint8(offset + 1), view.getUint8(offset + 2), view.getUint8(offset + 3))\n\nconst u24le = (view: DataView, offset: number): number =>\n view.getUint8(offset) | (view.getUint8(offset + 1) << 8) | (view.getUint8(offset + 2) << 16)\n\nconst READERS: Record<string, Reader> = {\n 'image/png': (view) => (fourcc(view, 12) === 'IHDR' ? { width: view.getUint32(16), height: view.getUint32(20) } : undefined),\n 'image/gif': (view) => ({ width: view.getUint16(6, true), height: view.getUint16(8, true) }),\n 'image/bmp': (view) =>\n view.getUint32(14, true) === 12\n ? { width: view.getUint16(18, true), height: view.getUint16(20, true) }\n : { width: Math.abs(view.getInt32(18, true)), height: Math.abs(view.getInt32(22, true)) },\n 'image/jpeg': jpeg,\n 'image/webp': webp,\n 'image/avif': avif,\n}\n\n/** The size declared in the header of an image of the given detected type, or undefined when it can't be read. */\nexport function imageDimensions(bytes: Uint8Array, mime: string): Dimensions | undefined {\n const reader = READERS[mime]\n if (!reader) return undefined\n try {\n const size = reader(new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength))\n return size && size.width > 0 && size.height > 0 ? size : undefined\n } catch (error) {\n // A header cut short reads past the end of the bytes: the image has no readable size.\n if (error instanceof RangeError) return undefined\n throw error\n }\n}\n\n/** Walks the marker segments to the first frame header. */\nfunction jpeg(view: DataView): Dimensions | undefined {\n let offset = 2\n for (let step = 0; step < MAX_JPEG_STEPS && offset + 4 <= view.byteLength; step++) {\n if (view.getUint8(offset) !== 0xff) return undefined\n const marker = view.getUint8(offset + 1)\n if (marker === 0xff) offset += 1 // a fill byte\n else if (marker === 0xd8 || marker === 0x01 || (marker >= 0xd0 && marker <= 0xd7)) offset += 2 // no length\n else if (marker === 0xd9 || marker === 0xda) return undefined // the image ends, or its data starts, before any frame header\n else if (FRAME_MARKERS.has(marker)) return { height: view.getUint16(offset + 5), width: view.getUint16(offset + 7) }\n else offset += 2 + view.getUint16(offset + 2)\n }\n return undefined\n}\n\n/** VP8 (lossy), VP8L (lossless) or VP8X (extended) chunks. */\nfunction webp(view: DataView): Dimensions | undefined {\n const chunk = fourcc(view, 12)\n if (chunk === 'VP8 ') {\n if (view.getUint8(23) !== 0x9d || view.getUint8(24) !== 0x01 || view.getUint8(25) !== 0x2a) return undefined\n return { width: view.getUint16(26, true) & 0x3fff, height: view.getUint16(28, true) & 0x3fff }\n }\n if (chunk === 'VP8L') {\n if (view.getUint8(20) !== 0x2f) return undefined\n const bits = view.getUint32(21, true)\n return { width: (bits & 0x3fff) + 1, height: ((bits >>> 14) & 0x3fff) + 1 }\n }\n if (chunk === 'VP8X') return { width: u24le(view, 24) + 1, height: u24le(view, 27) + 1 }\n return undefined\n}\n\ninterface Box {\n type: string\n /** Where the box's content starts. */\n start: number\n end: number\n}\n\n/** The ISO-BMFF boxes between start and end. */\nfunction* boxes(view: DataView, start: number, end: number): Generator<Box> {\n let offset = start\n for (let count = 0; count < MAX_BOXES && offset + 8 <= end; count++) {\n let size = view.getUint32(offset)\n let header = 8\n if (size === 1) {\n size = Number(view.getBigUint64(offset + 8))\n header = 16\n } else if (size === 0) {\n size = end - offset\n }\n if (size < header || offset + size > end) return\n yield { type: fourcc(view, offset + 4), start: offset + header, end: offset + size }\n offset += size\n }\n}\n\nconst findBox = (view: DataView, start: number, end: number, type: string): Box | undefined => {\n for (const box of boxes(view, start, end)) if (box.type === type) return box\n return undefined\n}\n\n/** The largest ispe (image spatial extents) property in meta → iprp → ipco: the primary image, not a thumbnail. */\nfunction avif(view: DataView): Dimensions | undefined {\n const meta = findBox(view, 0, view.byteLength, 'meta')\n // meta is a full box: its version and flags come before its children.\n const iprp = meta && findBox(view, meta.start + 4, meta.end, 'iprp')\n const ipco = iprp && findBox(view, iprp.start, iprp.end, 'ipco')\n if (!ipco) return undefined\n let largest: Dimensions | undefined\n for (const box of boxes(view, ipco.start, ipco.end)) {\n if (box.type !== 'ispe') continue\n const size = { width: view.getUint32(box.start + 4), height: view.getUint32(box.start + 8) }\n if (!largest || size.width * size.height > largest.width * largest.height) largest = size\n }\n return largest\n}\n","import { Arr, Str } from '@orieljs/support'\nimport type { BuiltinRule, RuleContext } from '../parse'\nimport { InvalidRuleParameterError } from '../errors'\nimport { displayName } from './dependent'\n\n/** voku/portable-ascii's is_ascii(), which Laravel's ascii rule uses: printable ASCII, tab, line feed, carriage return (and 0x10, 0x13). */\nconst ASCII_RE = /^[\\x09\\x10\\x13\\x0A\\x0D\\x20-\\x7E]*$/\nconst HEX_COLOR_RE = /^#(?:(?:[0-9a-f]{3}){1,2}|(?:[0-9a-f]{4}){1,2})$/i\nconst ALPHA_RE = /^[A-Za-z]+$/\nconst ALPHA_NUM_RE = /^[A-Za-z0-9]+$/\nconst ALPHA_DASH_RE = /^[A-Za-z0-9_-]+$/\n\n/**\n * `/^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/`, checked in one pass instead of with that pattern (which backtracks quadratically on\n * an address with many dots): one `@` with text before it, no whitespace, and a dot in the domain that is neither its\n * first nor its last character.\n */\nfunction isEmail(value: string): boolean {\n const at = value.indexOf('@')\n if (at < 1 || value.includes('@', at + 1) || /\\s/.test(value)) return false\n return value.slice(at + 2, -1).includes('.')\n}\n\n/** Laravel's Str::isUuid($value, $version): any version, or the one named (1–8, `nil`/`0`, `max`). */\nfunction isUuid(value: unknown, version: string | undefined): boolean {\n if (!Str.isUuid(value)) return false\n if (version === undefined) return true\n const hex = value.replaceAll('-', '').toLowerCase()\n if (version === 'nil' || version === '0') return /^0+$/.test(hex)\n if (version === 'max') return /^f+$/.test(hex)\n // A numbered version also needs the RFC 4122 variant (the 17th digit 8, 9, a or b), as ramsey/uuid's getVersion() does.\n return !/^0+$|^f+$/.test(hex) && hex[12] === version && '89ab'.includes(hex[16]!)\n}\n\n/** Str::isUrl()'s default schemes (Laravel 12), a regex alternation as Laravel writes it. */\nconst URL_PROTOCOLS =\n 'aaa|aaas|about|acap|acct|acd|acr|adiumxtra|adt|afp|afs|aim|amss|android|appdata|apt|ark|attachment|' +\n 'aw|barion|beshare|bitcoin|bitcoincash|blob|bolo|browserext|calculator|callto|cap|cast|casts|chrome|' +\n 'chrome-extension|cid|coap|coap\\\\+tcp|coap\\\\+ws|coaps|coaps\\\\+tcp|coaps\\\\+ws|com-eventbrite-attendee|' +\n 'content|conti|crid|cvs|dab|data|dav|diaspora|dict|did|dis|dlna-playcontainer|dlna-playsingle|dns|' +\n 'dntp|dpp|drm|drop|dtn|dvb|ed2k|elsi|example|facetime|fax|feed|feedready|file|filesystem|finger|' +\n 'first-run-pen-experience|fish|fm|ftp|fuchsia-pkg|geo|gg|git|gizmoproject|go|gopher|graph|gtalk|h323|' +\n 'ham|hcap|hcp|http|https|hxxp|hxxps|hydrazone|iax|icap|icon|im|imap|info|iotdisco|ipn|ipp|ipps|irc|' +\n 'irc6|ircs|iris|iris\\\\.beep|iris\\\\.lwz|iris\\\\.xpc|iris\\\\.xpcs|isostore|itms|jabber|jar|jms|keyparc|lastfm|' +\n 'ldap|ldaps|leaptofrogans|lorawan|lvlt|magnet|mailserver|mailto|maps|market|message|mid|mms|modem|' +\n 'mongodb|moz|ms-access|ms-browser-extension|ms-calculator|ms-drive-to|ms-enrollment|ms-excel|' +\n 'ms-eyecontrolspeech|ms-gamebarservices|ms-gamingoverlay|ms-getoffice|ms-help|ms-infopath|ms-inputapp|' +\n 'ms-lockscreencomponent-config|ms-media-stream-id|ms-mixedrealitycapture|ms-mobileplans|ms-officeapp|' +\n 'ms-people|ms-project|ms-powerpoint|ms-publisher|ms-restoretabcompanion|ms-screenclip|ms-screensketch|' +\n 'ms-search|ms-search-repair|ms-secondary-screen-controller|ms-secondary-screen-setup|ms-settings|' +\n 'ms-settings-airplanemode|ms-settings-bluetooth|ms-settings-camera|ms-settings-cellular|' +\n 'ms-settings-cloudstorage|ms-settings-connectabledevices|ms-settings-displays-topology|' +\n 'ms-settings-emailandaccounts|ms-settings-language|ms-settings-location|ms-settings-lock|' +\n 'ms-settings-nfctransactions|ms-settings-notifications|ms-settings-power|ms-settings-privacy|' +\n 'ms-settings-proximity|ms-settings-screenrotation|ms-settings-wifi|ms-settings-workplace|ms-spd|' +\n 'ms-sttoverlay|ms-transit-to|ms-useractivityset|ms-virtualtouchpad|ms-visio|ms-walk-to|ms-whiteboard|' +\n 'ms-whiteboard-cmd|ms-word|msnim|msrp|msrps|mss|mtqp|mumble|mupdate|mvn|news|nfs|ni|nih|nntp|notes|' +\n 'ocf|oid|onenote|onenote-cmd|opaquelocktoken|openpgp4fpr|pack|palm|paparazzi|payto|pkcs11|platform|' +\n 'pop|pres|prospero|proxy|pwid|psyc|pttp|qb|query|redis|rediss|reload|res|resource|rmi|rsync|rtmfp|' +\n 'rtmp|rtsp|rtsps|rtspu|s3|secondlife|service|session|sftp|sgn|shttp|sieve|simpleledger|sip|sips|skype|' +\n 'smb|sms|smtp|snews|snmp|soap\\\\.beep|soap\\\\.beeps|soldat|spiffe|spotify|ssh|steam|stun|stuns|submit|svn|' +\n 'tag|teamspeak|tel|teliaeid|telnet|tftp|tg|things|thismessage|tip|tn3270|tool|ts3server|turn|turns|tv|' +\n 'udp|unreal|urn|ut2004|v-event|vemmi|ventrilo|videotex|vnc|view-source|wais|webcal|wpid|ws|wss|wtai|' +\n 'wyciwyg|xcon|xcon-userid|xfire|xmlrpc\\\\.beep|xmlrpc\\\\.beeps|xmpp|xri|ymsgr|z39\\\\.50|z39\\\\.50r|z39\\\\.50s'\n\n/** RFC 3986's IPv6address, as Str::isUrl() writes it: h16 groups, `::`, and an IPv4 address in the last 32 bits. */\nconst H16 = '[0-9a-f]{1,4}'\nconst OCTET = '(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9])'\nconst LS32 = `(?:${H16}:${H16}|(?:${OCTET}\\\\.){3}${OCTET})`\nconst IPV6 = [\n `(?:${H16}:){6}${LS32}`,\n `::(?:${H16}:){5}${LS32}`,\n `(?:${H16})?::(?:${H16}:){4}${LS32}`,\n `(?:(?:${H16}:){0,1}${H16})?::(?:${H16}:){3}${LS32}`,\n `(?:(?:${H16}:){0,2}${H16})?::(?:${H16}:){2}${LS32}`,\n `(?:(?:${H16}:){0,3}${H16})?::${H16}:${LS32}`,\n `(?:(?:${H16}:){0,4}${H16})?::${LS32}`,\n `(?:(?:${H16}:){0,5}${H16})?::${H16}`,\n `(?:(?:${H16}:){0,6}${H16})?::`,\n].join('|')\n\nconst URL_USER = '(?:[_.\\\\p{L}\\\\p{N}-]|%[0-9A-Fa-f]{2})+'\n\n/**\n * Laravel's domain name, `([\\pL\\pN\\pS\\-\\_\\.])+(\\.?([\\pL\\pN]|xn\\-\\-[\\pL\\pN-]+)+\\.?)`, written so it can't backtrack\n * exponentially (JS has no backtrack limit; PCRE stops and returns false). It is the same set of strings: a run of\n * letters, numbers, symbols, `-`, `_` and `.` (taken whole, since nothing after the host can continue it) that ends in a\n * letter or number, or in an `xn--` label, either followed by one optional dot, with at least one character before.\n */\nconst URL_DOMAIN =\n '(?=(?<domain>[\\\\p{L}\\\\p{N}\\\\p{S}\\\\-_.]+))\\\\k<domain>' +\n '(?<=[\\\\p{L}\\\\p{N}\\\\p{S}\\\\-_.](?:[\\\\p{L}\\\\p{N}]|xn--[\\\\p{L}\\\\p{N}-]+)\\\\.?)'\n\n/**\n * Str::isUrl()'s pattern (derived from Symfony's UrlValidator 5.0.7, (c) Fabien Potencier), with PCRE's `ixu` as JS's\n * `iu`: PHP's `u` also turns on Unicode `\\d`, so `\\d` is `\\p{Nd}`, and PCRE's `$` also matches before a final line feed.\n */\nfunction urlPattern(protocols: string): RegExp {\n return new RegExp(\n `^(?:${protocols})://` +\n `(?:(?:${URL_USER}:)?${URL_USER}@)?` +\n `(?:${URL_DOMAIN}|\\\\p{Nd}{1,3}\\\\.\\\\p{Nd}{1,3}\\\\.\\\\p{Nd}{1,3}\\\\.\\\\p{Nd}{1,3}|\\\\[(?:${IPV6})\\\\])` +\n '(?::[0-9]+)?' +\n \"(?:/(?:[\\\\p{L}\\\\p{N}\\\\-._~!$&'()*+,;=:@]|%[0-9A-Fa-f]{2})*)*\" +\n \"(?:\\\\?(?:[\\\\p{L}\\\\p{N}\\\\-._~!$&'\\\\[\\\\]()*+,;=:@/?]|%[0-9A-Fa-f]{2})*)?\" +\n \"(?:#(?:[\\\\p{L}\\\\p{N}\\\\-._~!$&'()*+,;=:@/?]|%[0-9A-Fa-f]{2})*)?\" +\n '\\\\n?$',\n 'iu',\n )\n}\n\nconst URL_RE = urlPattern(URL_PROTOCOLS)\nconst urlPatterns = new Map<string, RegExp>()\n\n/**\n * Laravel's url rule (Str::isUrl): one of Laravel's schemes followed by `://`, an optional `user:password@`, a host (a\n * domain name, which may hold letters of any script, an IPv4 address or a bracketed IPv6 address), an optional port,\n * then a path, query and fragment of URL characters and `%` escapes only. So `javascript:` and `mailto:` fail, and so\n * do spaces, quotes, `<`, `\\` and bad escapes. `url:http,https` names the schemes allowed instead (case-insensitive,\n * written into the pattern as Laravel does).\n */\nfunction isUrl(value: unknown, protocols: readonly string[]): boolean {\n if (typeof value !== 'string') return false\n if (protocols.length === 0) return URL_RE.test(value)\n const list = protocols.join('|')\n let pattern = urlPatterns.get(list)\n if (pattern === undefined) {\n try {\n pattern = urlPattern(list)\n } catch (error) {\n throw new InvalidRuleParameterError(\n 'url',\n protocols.join(','),\n error instanceof Error ? error.message : String(error),\n )\n }\n urlPatterns.set(list, pattern)\n }\n return pattern.test(value)\n}\n\n/** Laravel's Str::startsWith() and endsWith(): text or a number, against any non-empty parameter. */\nfunction edges(value: unknown, parameters: readonly string[], end: boolean): boolean {\n if (typeof value !== 'string' && typeof value !== 'number') return false\n const text = String(value)\n return parameters.some((needle) => needle !== '' && (end ? text.endsWith(needle) : text.startsWith(needle)))\n}\n\nconst isText = (value: unknown): boolean => typeof value === 'string' || typeof value === 'number'\n\nconst listed = (ctx: RuleContext): Record<string, string> => ({ values: ctx.parameters.join(', ') })\n\nfunction compileRegex(raw: string): RegExp {\n const match = /^\\/(.*)\\/([a-z]*)$/.exec(raw)\n try {\n return match ? new RegExp(match[1]!, match[2]) : new RegExp(raw)\n } catch (error) {\n throw new InvalidRuleParameterError('regex', raw, error instanceof Error ? error.message : String(error))\n }\n}\n\nexport const formatRules: Record<string, BuiltinRule> = {\n email: { validate: (ctx) => typeof ctx.value === 'string' && isEmail(ctx.value), messageKey: () => 'email' },\n url: { validate: (ctx) => isUrl(ctx.value, ctx.parameters), messageKey: () => 'url' },\n uuid: { validate: (ctx) => isUuid(ctx.value, ctx.parameters[0]), messageKey: () => 'uuid' },\n ulid: { validate: (ctx) => Str.isUlid(ctx.value), messageKey: () => 'ulid' },\n ascii: { validate: (ctx) => isText(ctx.value) && ASCII_RE.test(String(ctx.value)), messageKey: () => 'ascii' },\n hex_color: { validate: (ctx) => typeof ctx.value === 'string' && HEX_COLOR_RE.test(ctx.value), messageKey: () => 'hex_color' },\n /** Text that parses as JSON (a JSON body's own numbers and objects are not \"a JSON string\"). */\n json: {\n validate: (ctx) => {\n if (typeof ctx.value !== 'string') return false\n try {\n JSON.parse(ctx.value)\n return true\n } catch {\n return false\n }\n },\n messageKey: () => 'json',\n },\n starts_with: { validate: (ctx) => edges(ctx.value, ctx.parameters, false), messageKey: () => 'starts_with', replacements: listed },\n ends_with: { validate: (ctx) => edges(ctx.value, ctx.parameters, true), messageKey: () => 'ends_with', replacements: listed },\n doesnt_start_with: {\n validate: (ctx) => isText(ctx.value) && !edges(ctx.value, ctx.parameters, false),\n messageKey: () => 'doesnt_start_with',\n replacements: listed,\n },\n doesnt_end_with: {\n validate: (ctx) => isText(ctx.value) && !edges(ctx.value, ctx.parameters, true),\n messageKey: () => 'doesnt_end_with',\n replacements: listed,\n },\n alpha: { validate: (ctx) => typeof ctx.value === 'string' && ALPHA_RE.test(ctx.value), messageKey: () => 'alpha' },\n alpha_num: {\n validate: (ctx) => typeof ctx.value === 'string' && ALPHA_NUM_RE.test(ctx.value),\n messageKey: () => 'alpha_num',\n },\n alpha_dash: {\n validate: (ctx) => typeof ctx.value === 'string' && ALPHA_DASH_RE.test(ctx.value),\n messageKey: () => 'alpha_dash',\n },\n lowercase: {\n validate: (ctx) => (typeof ctx.value === 'string' || typeof ctx.value === 'number') && String(ctx.value).toLowerCase() === String(ctx.value),\n messageKey: () => 'lowercase',\n },\n uppercase: {\n validate: (ctx) => (typeof ctx.value === 'string' || typeof ctx.value === 'number') && String(ctx.value).toUpperCase() === String(ctx.value),\n messageKey: () => 'uppercase',\n },\n regex: {\n validate: (ctx) => typeof ctx.value === 'string' && compileRegex(ctx.parameters[0] ?? '').test(ctx.value),\n messageKey: () => 'regex',\n },\n /** Laravel's validateNotRegex(): text or a number that the pattern does not match. */\n not_regex: {\n validate: (ctx) => isText(ctx.value) && !compileRegex(ctx.parameters[0] ?? '').test(String(ctx.value)),\n messageKey: () => 'not_regex',\n },\n /** `confirmed` matches `<field>_confirmation`; `confirmed:repeat_password` names the other field (Laravel 12). */\n confirmed: {\n validate: (ctx: RuleContext) => ctx.value === Arr.get(ctx.data, ctx.parameters[0] || `${ctx.attribute}_confirmation`),\n messageKey: () => 'confirmed',\n },\n same: {\n validate: (ctx) => ctx.value === Arr.get(ctx.data, ctx.parameters[0] ?? ''),\n messageKey: () => 'same',\n replacements: (ctx) => ({ other: displayName(ctx, ctx.parameters[0] ?? '') }),\n },\n different: {\n validate: (ctx) => ctx.value !== Arr.get(ctx.data, ctx.parameters[0] ?? ''),\n messageKey: () => 'different',\n replacements: (ctx) => ({ other: displayName(ctx, ctx.parameters[0] ?? '') }),\n },\n digits: {\n validate: (ctx) =>\n typeof ctx.value !== 'object' && new RegExp(`^\\\\d{${ctx.parameters[0]}}$`).test(String(ctx.value)),\n messageKey: () => 'digits',\n replacements: (ctx) => ({ digits: ctx.parameters[0] ?? '' }),\n },\n}\n","import { lookup } from 'node:dns/promises'\nimport { isIP, isIPv4, isIPv6 } from 'node:net'\nimport type { BuiltinRule } from '../parse'\n\n/** PHP's FILTER_VALIDATE_MAC: six pairs joined by one `-` or `:` throughout, or three groups of four joined by `.`. */\nconst MAC_RE = /^(?:[0-9a-f]{2}([-:])(?:[0-9a-f]{2}\\1){4}[0-9a-f]{2}|[0-9a-f]{4}\\.[0-9a-f]{4}\\.[0-9a-f]{4})$/i\n\n/** The lookup active_url asks, held in an object so a test can replace it. Not exported from the package. */\nexport const resolver = { lookup }\n\n/**\n * Laravel's active_url: the URL's host has an address (an A or AAAA record). Asked of the system's resolver, so a name\n * the machine knows (localhost, /etc/hosts) counts too.\n */\nasync function hasAddress(value: unknown): Promise<boolean> {\n if (typeof value !== 'string') return false\n let host: string\n try {\n host = new URL(value).hostname\n } catch {\n return false\n }\n if (host === '') return false\n try {\n return (await resolver.lookup(host.replace(/^\\[|\\]$/g, ''), { all: true })).length > 0\n } catch {\n return false\n }\n}\n\nexport const networkRules: Record<string, BuiltinRule> = {\n ip: { validate: (ctx) => typeof ctx.value === 'string' && isIP(ctx.value) !== 0, messageKey: () => 'ip' },\n ipv4: { validate: (ctx) => typeof ctx.value === 'string' && isIPv4(ctx.value), messageKey: () => 'ipv4' },\n ipv6: { validate: (ctx) => typeof ctx.value === 'string' && isIPv6(ctx.value), messageKey: () => 'ipv6' },\n mac_address: { validate: (ctx) => typeof ctx.value === 'string' && MAC_RE.test(ctx.value), messageKey: () => 'mac_address' },\n active_url: { validate: (ctx) => hasAddress(ctx.value), messageKey: () => 'active_url' },\n}\n","import type { BuiltinRule } from '../parse'\nimport { isNumeric } from './type'\n\n/** Laravel's `preg_match('/[^0-9]/', $value)` check: a number or text made only of digits. */\nconst onlyDigits = (value: unknown): boolean => (typeof value === 'string' || typeof value === 'number') && /^\\d+$/.test(String(value))\n\n/** Laravel's ensureExponentWithinAllowedRange(): a written exponent past ±1000 isn't read. */\nconst MAX_EXPONENT = 1000\n\n/**\n * A decimal number's digits and its power of ten (`'1.25'` → 125n and -2; `'1e3'` → 1n and 3), for exact remainders;\n * undefined when its written exponent is past ±1000.\n */\nfunction decimal(text: string): { digits: bigint; exponent: number } | undefined {\n const [, sign = '', whole = '', fraction = '', power = '0'] = /^\\s*([+-]?)(\\d*)(?:\\.(\\d*))?(?:[eE]([+-]?\\d+))?\\s*$/.exec(text) ?? []\n if (Math.abs(Number(power)) > MAX_EXPONENT) return undefined\n return { digits: BigInt(`${sign}${whole}${fraction}` || '0'), exponent: Number(power) - fraction.length }\n}\n\n/** Laravel's validateMultipleOf(), in decimals as BigDecimal is (0.3 is a multiple of 0.1); an exponent past ±1000 fails. */\nfunction isMultipleOf(value: unknown, divisor: string): boolean {\n if (!isNumeric(value) || !isNumeric(divisor)) return false\n const a = decimal(String(value))\n const b = decimal(divisor)\n if (a === undefined || b === undefined) return false\n const exponent = Math.min(a.exponent, b.exponent)\n const numerator = a.digits * 10n ** BigInt(a.exponent - exponent)\n const denominator = b.digits * 10n ** BigInt(b.exponent - exponent)\n if (denominator === 0n) return false\n return numerator % denominator === 0n\n}\n\n/**\n * Laravel's validateDecimal(): a number with exactly `min` decimal places, or between `min` and `max`. Laravel's\n * `/^[+-]?\\d*\\.?(\\d*)$/`, written with the dot and its digits as one optional group: the same strings and places,\n * without the two runs of digits that make a long number with an exponent backtrack quadratically.\n */\nfunction hasDecimals(value: unknown, min: string, max: string | undefined): boolean {\n if (!isNumeric(value)) return false\n const match = /^[+-]?\\d*(?:\\.(\\d*))?$/.exec(String(value).trim())\n if (match === null) return false\n const places = match[1] ?? ''\n return max === undefined ? places.length === Number(min) : places.length >= Number(min) && places.length <= Number(max)\n}\n\nconst length = (value: unknown): number => String(value).length\n\nexport const numericRules: Record<string, BuiltinRule> = {\n decimal: {\n validate: (ctx) => hasDecimals(ctx.value, ctx.parameters[0] ?? '', ctx.parameters[1]),\n messageKey: () => 'decimal',\n replacements: (ctx) => ({ decimal: ctx.parameters[1] === undefined ? (ctx.parameters[0] ?? '') : `${ctx.parameters[0]}-${ctx.parameters[1]}` }),\n },\n digits_between: {\n validate: (ctx) => onlyDigits(ctx.value) && length(ctx.value) >= Number(ctx.parameters[0]) && length(ctx.value) <= Number(ctx.parameters[1]),\n messageKey: () => 'digits_between',\n replacements: (ctx) => ({ min: ctx.parameters[0] ?? '', max: ctx.parameters[1] ?? '' }),\n },\n max_digits: {\n validate: (ctx) => onlyDigits(ctx.value) && length(ctx.value) <= Number(ctx.parameters[0]),\n messageKey: () => 'max_digits',\n replacements: (ctx) => ({ max: ctx.parameters[0] ?? '' }),\n },\n min_digits: {\n validate: (ctx) => onlyDigits(ctx.value) && length(ctx.value) >= Number(ctx.parameters[0]),\n messageKey: () => 'min_digits',\n replacements: (ctx) => ({ min: ctx.parameters[0] ?? '' }),\n },\n multiple_of: {\n validate: (ctx) => isMultipleOf(ctx.value, ctx.parameters[0] ?? ''),\n messageKey: () => 'multiple_of',\n replacements: (ctx) => ({ value: ctx.parameters[0] ?? '' }),\n },\n}\n","import { Arr } from '@orieljs/support'\nimport type { BuiltinRule, RuleContext } from '../parse'\nimport { isEmptyValue } from '../parse'\nimport { otherAccepted, otherDeclined } from './acceptance'\nimport { displayName, displayableValue, fieldList, otherAndValue, otherAndValues, otherFieldMatches } from './dependent'\n\nfunction isFieldPresent(field: string, data: Record<string, unknown>): boolean {\n return Arr.has(data, field) && !isEmptyValue(Arr.get(data, field))\n}\n\nfunction anyPresent(fields: string[], data: Record<string, unknown>): boolean {\n return fields.some((field) => isFieldPresent(field, data))\n}\n\nfunction allPresent(fields: string[], data: Record<string, unknown>): boolean {\n return fields.every((field) => isFieldPresent(field, data))\n}\n\n/** Laravel's Arr::hasAny() and Arr::has() on several keys: whether any (or every) key is there, whatever its value. */\nconst hasAnyKey = (fields: string[], data: Record<string, unknown>): boolean => fields.some((field) => Arr.has(data, field))\nconst hasEveryKey = (fields: string[], data: Record<string, unknown>): boolean => fields.length > 0 && fields.every((field) => Arr.has(data, field))\n\n/** `:other` and `:value` for the `_unless` rules that show the first value listed (Laravel's replaceMissingUnless()). */\nconst otherAndFirstValue = (ctx: RuleContext): Record<string, string> => ({\n other: displayName(ctx, ctx.parameters[0] ?? ''),\n value: displayableValue(ctx.parameters[1]),\n})\n\nconst otherName = (ctx: RuleContext): Record<string, string> => ({ other: displayName(ctx, ctx.parameters[0] ?? '') })\n\nexport const presenceRules: Record<string, BuiltinRule> = {\n required: {\n implicit: true,\n validate: (ctx: RuleContext) => !isEmptyValue(ctx.value),\n messageKey: () => 'required',\n },\n required_if: {\n implicit: true,\n // Laravel: nothing is required while the other field is missing.\n validate: (ctx: RuleContext) => !Arr.has(ctx.data, ctx.parameters[0] ?? '') || !otherFieldMatches(ctx) || !isEmptyValue(ctx.value),\n messageKey: () => 'required_if',\n replacements: otherAndValue,\n },\n required_unless: {\n implicit: true,\n validate: (ctx: RuleContext) => otherFieldMatches(ctx) || !isEmptyValue(ctx.value),\n messageKey: () => 'required_unless',\n replacements: otherAndValues,\n },\n required_with: {\n implicit: true,\n validate: (ctx: RuleContext) => !anyPresent(ctx.parameters, ctx.data) || !isEmptyValue(ctx.value),\n messageKey: () => 'required_with',\n replacements: fieldList,\n },\n required_with_all: {\n implicit: true,\n validate: (ctx: RuleContext) => !allPresent(ctx.parameters, ctx.data) || !isEmptyValue(ctx.value),\n messageKey: () => 'required_with_all',\n replacements: fieldList,\n },\n required_without: {\n implicit: true,\n validate: (ctx: RuleContext) => ctx.parameters.every((f) => isFieldPresent(f, ctx.data)) || !isEmptyValue(ctx.value),\n messageKey: () => 'required_without',\n replacements: fieldList,\n },\n required_without_all: {\n implicit: true,\n validate: (ctx: RuleContext) => anyPresent(ctx.parameters, ctx.data) || !isEmptyValue(ctx.value),\n messageKey: () => 'required_without_all',\n replacements: fieldList,\n },\n required_if_accepted: {\n implicit: true,\n validate: (ctx) => !otherAccepted(ctx.data, ctx.parameters[0]) || !isEmptyValue(ctx.value),\n messageKey: () => 'required_if_accepted',\n replacements: otherName,\n },\n required_if_declined: {\n implicit: true,\n validate: (ctx) => !otherDeclined(ctx.data, ctx.parameters[0]) || !isEmptyValue(ctx.value),\n messageKey: () => 'required_if_declined',\n replacements: otherName,\n },\n\n /** The key is there, whatever its value (null and '' included). */\n present: { implicit: true, validate: (ctx) => Arr.has(ctx.data, ctx.attribute), messageKey: () => 'present' },\n present_if: {\n implicit: true,\n validate: (ctx) => !otherFieldMatches(ctx) || Arr.has(ctx.data, ctx.attribute),\n messageKey: () => 'present_if',\n replacements: otherAndValue,\n },\n present_unless: {\n implicit: true,\n validate: (ctx) => otherFieldMatches(ctx) || Arr.has(ctx.data, ctx.attribute),\n messageKey: () => 'present_unless',\n replacements: otherAndFirstValue,\n },\n present_with: {\n implicit: true,\n validate: (ctx) => !hasAnyKey(ctx.parameters, ctx.data) || Arr.has(ctx.data, ctx.attribute),\n messageKey: () => 'present_with',\n replacements: fieldList,\n },\n present_with_all: {\n implicit: true,\n validate: (ctx) => !hasEveryKey(ctx.parameters, ctx.data) || Arr.has(ctx.data, ctx.attribute),\n messageKey: () => 'present_with_all',\n replacements: fieldList,\n },\n\n /** A key that is there must not be empty; a missing key passes. */\n filled: { implicit: true, validate: (ctx) => !Arr.has(ctx.data, ctx.attribute) || !isEmptyValue(ctx.value), messageKey: () => 'filled' },\n\n /** The key is not there at all (null counts as there). */\n missing: { implicit: true, validate: (ctx) => !Arr.has(ctx.data, ctx.attribute), messageKey: () => 'missing' },\n missing_if: {\n implicit: true,\n validate: (ctx) => !otherFieldMatches(ctx) || !Arr.has(ctx.data, ctx.attribute),\n messageKey: () => 'missing_if',\n replacements: otherAndValue,\n },\n missing_unless: {\n implicit: true,\n validate: (ctx) => otherFieldMatches(ctx) || !Arr.has(ctx.data, ctx.attribute),\n messageKey: () => 'missing_unless',\n replacements: otherAndFirstValue,\n },\n missing_with: {\n implicit: true,\n validate: (ctx) => !hasAnyKey(ctx.parameters, ctx.data) || !Arr.has(ctx.data, ctx.attribute),\n messageKey: () => 'missing_with',\n replacements: fieldList,\n },\n missing_with_all: {\n implicit: true,\n validate: (ctx) => !hasEveryKey(ctx.parameters, ctx.data) || !Arr.has(ctx.data, ctx.attribute),\n messageKey: () => 'missing_with_all',\n replacements: fieldList,\n },\n}\n","import { Arr } from '@orieljs/support'\nimport type { BuiltinRule } from '../parse'\nimport { isEmptyValue } from '../parse'\nimport { otherAccepted, otherDeclined } from './acceptance'\nimport { displayName, fieldList, otherAndValue, otherAndValues, otherFieldMatches } from './dependent'\n\n/**\n * The prohibited family. Not implicit, as in Laravel: a missing or blank field never runs them, and so passes; an\n * explicit null runs them and passes too (null is empty).\n */\nexport const prohibitedRules: Record<string, BuiltinRule> = {\n prohibited: { validate: (ctx) => isEmptyValue(ctx.value), messageKey: () => 'prohibited' },\n prohibited_if: {\n validate: (ctx) => !otherFieldMatches(ctx) || isEmptyValue(ctx.value),\n messageKey: () => 'prohibited_if',\n replacements: otherAndValue,\n },\n prohibited_unless: {\n validate: (ctx) => otherFieldMatches(ctx) || isEmptyValue(ctx.value),\n messageKey: () => 'prohibited_unless',\n replacements: otherAndValues,\n },\n prohibited_if_accepted: {\n validate: (ctx) => !otherAccepted(ctx.data, ctx.parameters[0]) || isEmptyValue(ctx.value),\n messageKey: () => 'prohibited_if_accepted',\n replacements: (ctx) => ({ other: displayName(ctx, ctx.parameters[0] ?? '') }),\n },\n prohibited_if_declined: {\n validate: (ctx) => !otherDeclined(ctx.data, ctx.parameters[0]) || isEmptyValue(ctx.value),\n messageKey: () => 'prohibited_if_declined',\n replacements: (ctx) => ({ other: displayName(ctx, ctx.parameters[0] ?? '') }),\n },\n /** While this field has a value, every field named must be missing or empty. */\n prohibits: {\n validate: (ctx) => isEmptyValue(ctx.value) || ctx.parameters.every((field) => isEmptyValue(Arr.get(ctx.data, field))),\n messageKey: () => 'prohibits',\n replacements: (ctx) => ({ other: fieldList(ctx).values! }),\n },\n}\n","import { Arr } from '@orieljs/support'\nimport type { BuiltinRule, RuleContext } from '../parse'\nimport { isUploadedFileLike } from '../parse'\nimport { displayName } from './dependent'\nimport { isNumeric } from './type'\n\ntype SizeType = 'numeric' | 'array' | 'file' | 'string'\n\nfunction hasAny(ctx: RuleContext, names: string[]): boolean {\n return names.some((name) => ctx.ruleNames.includes(name))\n}\n\n/** Laravel's numericRules: the rules that make the size rules measure a number. */\nconst NUMERIC_RULES = ['numeric', 'integer', 'decimal']\n\n/** A JSON object is a PHP associative array, so it's counted like one. */\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n if (typeof value !== 'object' || value === null) return false\n const proto: unknown = Object.getPrototypeOf(value)\n return proto === Object.prototype || proto === null\n}\n\n/**\n * What a size rule measures and which message family it reports, decided in one place so the check and the\n * message always agree (Laravel's getSize + getAttributeType):\n * - numeric/integer/decimal rule: the number itself (a non-numeric value falls back to its string length, which the\n * numeric rule rejects anyway);\n * - an array (or plain object): its item count;\n * - an uploaded file: its size in fractional kilobytes;\n * - a file/image rule on something that isn't a file: NaN, so every size comparison fails;\n * - anything else: the length of its string form (a number without a numeric rule counts its digits).\n */\nfunction measure(ctx: RuleContext, value: unknown = ctx.value, numeric = hasAny(ctx, NUMERIC_RULES)): { type: SizeType; size: number } {\n if (numeric) {\n return { type: 'numeric', size: isNumeric(value) ? Number(value) : stringLength(value) }\n }\n if (Array.isArray(value)) return { type: 'array', size: value.length }\n if (isUploadedFileLike(value)) return { type: 'file', size: value.size / 1024 }\n if (hasAny(ctx, ['file', 'image'])) return { type: 'file', size: Number.NaN }\n if (isPlainObject(value)) return { type: 'array', size: Object.keys(value).length }\n if (hasAny(ctx, ['array'])) return { type: 'array', size: stringLength(value) }\n return { type: 'string', size: stringLength(value) }\n}\n\nfunction stringLength(value: unknown): number {\n if (value === null || value === undefined) return 0\n return [...String(value)].length\n}\n\nfunction sizeOf(ctx: RuleContext): number {\n return measure(ctx).size\n}\n\ntype Comparison = 'gt' | 'gte' | 'lt' | 'lte'\n\nconst COMPARE: Record<Comparison, (a: number, b: number) => boolean> = {\n gt: (a, b) => a > b,\n gte: (a, b) => a >= b,\n lt: (a, b) => a < b,\n lte: (a, b) => a <= b,\n}\n\n/** PHP's gettype(), as Laravel's isSameType() compares it (a list and an object are both arrays). */\nfunction kind(value: unknown): string {\n if (value === null || value === undefined) return 'null'\n if (Array.isArray(value) || isPlainObject(value)) return 'array'\n if (typeof value === 'number') return Number.isInteger(value) ? 'integer' : 'double'\n return typeof value\n}\n\n/**\n * Laravel's validateGt() and the others: a numeric value is a number (shouldBeNumeric()); against a number literal\n * only a numeric value compares; against another field, two numbers by value, else two values of one kind by size\n * (text length, item count, kilobytes).\n */\nfunction compareSizes(ctx: RuleContext, rule: Comparison): boolean {\n const parameter = ctx.parameters[0] ?? ''\n const other = Arr.get<unknown>(ctx.data, parameter)\n const numeric = hasAny(ctx, NUMERIC_RULES) || isNumeric(ctx.value)\n if ((other === null || other === undefined) && isNumeric(ctx.value) && isNumeric(parameter)) {\n return COMPARE[rule](Number(String(ctx.value).trim()), Number(parameter.trim()))\n }\n if (isNumeric(parameter)) return false\n if (numeric && isNumeric(ctx.value) && isNumeric(other)) return COMPARE[rule](Number(String(ctx.value).trim()), Number(String(other).trim()))\n if (kind(ctx.value) !== kind(other)) return false\n return COMPARE[rule](measure(ctx, ctx.value, numeric).size, measure(ctx, other, numeric).size)\n}\n\n/** `:value`: the other field's size, or the parameter itself (a number, or a field that isn't there). */\nfunction comparedValue(ctx: RuleContext): Record<string, string> {\n const parameter = ctx.parameters[0] ?? ''\n const other = Arr.get<unknown>(ctx.data, parameter)\n if (other === null || other === undefined) return { value: displayName(ctx, parameter) }\n return { value: String(measure(ctx, other, hasAny(ctx, NUMERIC_RULES) || isNumeric(ctx.value)).size) }\n}\n\nconst comparison = (rule: Comparison): BuiltinRule => ({\n validate: (ctx) => compareSizes(ctx, rule),\n messageKey: (ctx) => `${rule}.${measure(ctx, ctx.value, hasAny(ctx, NUMERIC_RULES) || isNumeric(ctx.value)).type}`,\n replacements: comparedValue,\n})\n\nfunction sizeType(ctx: RuleContext): SizeType {\n return measure(ctx).type\n}\n\nexport const sizeRules: Record<string, BuiltinRule> = {\n max: {\n validate: (ctx) => sizeOf(ctx) <= Number(ctx.parameters[0]),\n messageKey: (ctx) => `max.${sizeType(ctx)}`,\n replacements: (ctx) => ({ max: ctx.parameters[0] ?? '' }),\n },\n min: {\n validate: (ctx) => sizeOf(ctx) >= Number(ctx.parameters[0]),\n messageKey: (ctx) => `min.${sizeType(ctx)}`,\n replacements: (ctx) => ({ min: ctx.parameters[0] ?? '' }),\n },\n between: {\n validate: (ctx) => {\n const size = sizeOf(ctx)\n return size >= Number(ctx.parameters[0]) && size <= Number(ctx.parameters[1])\n },\n messageKey: (ctx) => `between.${sizeType(ctx)}`,\n replacements: (ctx) => ({ min: ctx.parameters[0] ?? '', max: ctx.parameters[1] ?? '' }),\n },\n size: {\n validate: (ctx) => sizeOf(ctx) === Number(ctx.parameters[0]),\n messageKey: (ctx) => `size.${sizeType(ctx)}`,\n replacements: (ctx) => ({ size: ctx.parameters[0] ?? '' }),\n },\n gt: comparison('gt'),\n gte: comparison('gte'),\n lt: comparison('lt'),\n lte: comparison('lte'),\n in: { validate: (ctx) => isListed(ctx.value, ctx.parameters, ctx.ruleNames), messageKey: () => 'in' },\n not_in: { validate: (ctx) => !isListed(ctx.value, ctx.parameters, ctx.ruleNames), messageKey: () => 'not_in' },\n}\n\n/**\n * Laravel's validateIn(): the value's text is one of `list`. An array or an object never is, unless the field also has\n * `array`: then every item must be a listed scalar. `not_in` is its opposite, arrays included.\n */\nexport function isListed(value: unknown, list: readonly string[], ruleNames: readonly string[]): boolean {\n if (Array.isArray(value) && ruleNames.includes('array')) {\n return value.every((item) => (typeof item !== 'object' || item === null) && list.includes(String(item)))\n }\n return (typeof value !== 'object' || value === null) && list.includes(String(value))\n}\n","import { InvalidRuleParameterError } from '../errors'\nimport type { BuiltinRule } from '../parse'\n\n/** PHP's DateTimeZone region groups (timezone:Europe, …); timezone_identifiers_list(ALL) is these regions and UTC. */\nconst REGIONS = ['Africa', 'America', 'Antarctica', 'Arctic', 'Asia', 'Atlantic', 'Australia', 'Europe', 'Indian', 'Pacific']\n\n/** Each segment of a zone name in its own case: `America/Argentina/Buenos_Aires`, `America/Port-au-Prince`. */\nconst ZONE_RE = /^[A-Z][A-Za-z_-]*(?:\\/[A-Z][A-Za-z0-9_+-]*)+$/\n\n/**\n * The old names ICU (and so Node's Intl and Intl.Locale's zone lists) still gives these zones, with their IANA names\n * (PHP's). Node reads `Asia/Kolkata` as `Asia/Calcutta`; Bun keeps whichever name it was given.\n */\nconst ICU_NAMES: Record<string, string> = {\n 'Africa/Asmera': 'Africa/Asmara',\n 'America/Buenos_Aires': 'America/Argentina/Buenos_Aires',\n 'America/Catamarca': 'America/Argentina/Catamarca',\n 'America/Cordoba': 'America/Argentina/Cordoba',\n 'America/Jujuy': 'America/Argentina/Jujuy',\n 'America/Mendoza': 'America/Argentina/Mendoza',\n 'America/Coral_Harbour': 'America/Atikokan',\n 'America/Indianapolis': 'America/Indiana/Indianapolis',\n 'America/Louisville': 'America/Kentucky/Louisville',\n 'America/Godthab': 'America/Nuuk',\n 'Asia/Saigon': 'Asia/Ho_Chi_Minh',\n 'Asia/Katmandu': 'Asia/Kathmandu',\n 'Asia/Calcutta': 'Asia/Kolkata',\n 'Asia/Rangoon': 'Asia/Yangon',\n 'Atlantic/Faeroe': 'Atlantic/Faroe',\n 'Europe/Kiev': 'Europe/Kyiv',\n 'Pacific/Truk': 'Pacific/Chuuk',\n 'Pacific/Enderbury': 'Pacific/Kanton',\n 'Pacific/Ponape': 'Pacific/Pohnpei',\n}\n\n/** The name the runtime reads the zone as (in its own case), or undefined when the runtime doesn't know the zone. */\nfunction resolve(zone: string): string | undefined {\n try {\n return new Intl.DateTimeFormat('en-US', { timeZone: zone }).resolvedOptions().timeZone\n } catch {\n return undefined\n }\n}\n\n/** The zone's IANA name as the runtime reads it, or undefined when the runtime doesn't know the zone. */\nfunction canonical(zone: string): string | undefined {\n const name = resolve(zone)\n return name === undefined ? undefined : (ICU_NAMES[name] ?? name)\n}\n\n/**\n * Whether a zone the runtime knows is written in its own case, as PHP's strict in_array() needs (`Europe/London`, not\n * `Europe/LONDON`). Intl reads a name in any case and answers it in its own: the name itself (Bun always, Node for a\n * zone), or the old name in ICU_NAMES (Node's `Asia/Calcutta` for `Asia/Kolkata`). Node answers some links with the\n * zone they point to (`Europe/Belfast` → `Europe/London`), which says nothing of the link's case: those are checked by\n * their shape only, as before.\n */\nfunction isInOwnCase(value: string, name: string): boolean {\n const lower = value.toLowerCase()\n for (const spelling of [name, ICU_NAMES[name]]) {\n if (spelling !== undefined && spelling.toLowerCase() === lower) return spelling === value\n }\n return true\n}\n\n/** The zones of a country, from the runtime's ICU data (Intl.Locale's getTimeZones(), timeZones before Node 23). */\nfunction countryZones(country: string): string[] {\n const locale = new Intl.Locale(`und-${country.toUpperCase()}`) as Intl.Locale & { getTimeZones?: () => string[]; timeZones?: string[] }\n return locale.getTimeZones?.() ?? locale.timeZones ?? []\n}\n\nconst inRegion = (zone: string, region?: string): boolean =>\n zone === 'UTC' ? region === undefined || region === 'UTC' : ZONE_RE.test(zone) && (region === undefined ? REGIONS : [region]).includes(zone.split('/')[0]!)\n\n/**\n * Laravel's timezone rule, against the runtime's IANA data instead of PHP's lists (Node and Bun ship different ICU\n * builds, and PHP's lists can't be read here):\n * - every group takes a name only in its own case (see isInOwnCase());\n * - `timezone` (`all`): a zone in one of PHP's regions, or UTC; Oriel can't tell a region's old link names\n * (Asia/Calcutta) from its zones, so those pass too;\n * - `timezone:<region>`: a zone in that region (`timezone:Europe`), `timezone:utc` only UTC;\n * - `timezone:all_with_bc`: any name the runtime knows, links included (US/Eastern, Etc/GMT+5);\n * - `timezone:per_country,US`: a zone of that country.\n */\nfunction isTimezone(value: unknown, group = 'all', country?: string): boolean {\n if (typeof value !== 'string') return false\n const resolved = resolve(value)\n if (resolved === undefined || !isInOwnCase(value, resolved)) return false\n const name = group.toLowerCase()\n if (name === 'all') return inRegion(value)\n if (name === 'all_with_bc') return /^[A-Z]/.test(value)\n if (name === 'per_country') {\n const zone = canonical(value)\n return inRegion(value) && countryZones(country ?? '').some((candidate) => canonical(candidate) === zone)\n }\n const region = name === 'utc' ? 'UTC' : REGIONS.find((candidate) => candidate.toLowerCase() === name)\n if (region === undefined) throw new InvalidRuleParameterError('timezone', group, 'expected all, all_with_bc, per_country, utc or a region such as Europe')\n return inRegion(value, region)\n}\n\nexport const timezoneRules: Record<string, BuiltinRule> = {\n timezone: { validate: (ctx) => isTimezone(ctx.value, ctx.parameters[0], ctx.parameters[1]), messageKey: () => 'timezone' },\n}\n","import type { BuiltinRule } from './parse'\nimport { acceptanceRules } from './rules/acceptance'\nimport { arrayRules } from './rules/array'\nimport { authRules } from './rules/auth'\nimport { databaseRules } from './rules/database'\nimport { dateRules } from './rules/date'\nimport { excludeRules } from './rules/exclude'\nimport { fileRules } from './rules/file'\nimport { formatRules } from './rules/format'\nimport { networkRules } from './rules/network'\nimport { numericRules } from './rules/numeric'\nimport { presenceRules } from './rules/presence'\nimport { prohibitedRules } from './rules/prohibited'\nimport { sizeRules } from './rules/size'\nimport { timezoneRules } from './rules/timezone'\nimport { typeRules } from './rules/type'\n\n/** Every built-in rule, merged. Later tasks (database rules) add their own spread here. */\nexport const builtinRules: Record<string, BuiltinRule> = {\n ...presenceRules,\n ...acceptanceRules,\n ...prohibitedRules,\n ...excludeRules,\n ...typeRules,\n ...arrayRules,\n ...formatRules,\n ...dateRules,\n ...networkRules,\n ...timezoneRules,\n ...sizeRules,\n ...numericRules,\n ...fileRules,\n ...databaseRules,\n ...authRules,\n}\n","import type { TypedValidationRule } from '@orieljs/contracts'\nimport { applyReplacements, DEFAULT_MESSAGES } from '../messages'\n\nlet defaultRule: PasswordRule | (() => PasswordRule) | undefined\n\n/**\n * Laravel's mixedCase pattern, `/(\\p{Ll}+.*\\p{Lu})|(\\p{Lu}+.*\\p{Ll})/u`, matches when one line (`.` stops at a line\n * break) holds a lower and an upper case letter. Checked line by line, since that pattern backtracks cubically on a\n * long run of letters in one case.\n */\nfunction hasMixedCase(value: string): boolean {\n return value.split(/[\\n\\r\\u2028\\u2029]/).some((line) => /\\p{Ll}/u.test(line) && /\\p{Lu}/u.test(line))\n}\n\n/**\n * Laravel's Illuminate\\Validation\\Rules\\Password: a string of at least `min` characters (8 by default), plus the\n * checks you add: letters(), mixedCase(), numbers(), symbols(), max(). Every failing check adds its own message.\n * Rule.password() returns the application default (PasswordRule.defaults()). (Laravel's uncompromised() is not\n * ported: it calls an outside service.)\n */\nexport class PasswordRule implements TypedValidationRule<{ value: string }> {\n /** A passing value is a string (for the validated data's type); never set at run time. */\n declare readonly __typing?: { value: string }\n #min: number\n #max: number | undefined\n #letters = false\n #mixedCase = false\n #numbers = false\n #symbols = false\n\n constructor(min = 8) {\n this.#min = Math.max(1, min)\n }\n\n /** A password rule of at least `size` characters: PasswordRule.min(12).mixedCase(). */\n static min(size: number): PasswordRule {\n return new PasswordRule(size)\n }\n\n /**\n * With an argument, sets the default (Laravel's Password::defaults(fn () => ...), in a provider's boot());\n * `null` resets it. Without one, returns a copy of the default: PasswordRule.min(8) unless set.\n */\n static defaults(): PasswordRule\n static defaults(rule: PasswordRule | (() => PasswordRule) | null): void\n static defaults(rule?: PasswordRule | (() => PasswordRule) | null): PasswordRule | void {\n if (rule !== undefined) {\n defaultRule = rule ?? undefined\n return\n }\n const resolved = typeof defaultRule === 'function' ? defaultRule() : defaultRule\n return resolved === undefined ? new PasswordRule(8) : resolved.#copy()\n }\n\n min(size: number): this {\n this.#min = Math.max(1, size)\n return this\n }\n\n max(size: number): this {\n this.#max = size\n return this\n }\n\n /** At least one letter. */\n letters(): this {\n this.#letters = true\n return this\n }\n\n /** At least one uppercase and one lowercase letter. */\n mixedCase(): this {\n this.#mixedCase = true\n return this\n }\n\n /** At least one number. */\n numbers(): this {\n this.#numbers = true\n return this\n }\n\n /** At least one symbol (punctuation, a symbol or a space). */\n symbols(): this {\n this.#symbols = true\n return this\n }\n\n validate(_attribute: string, value: unknown, fail: (message: string) => void): void {\n // :attribute stays for the Validator to fill, with the field's custom attribute name when it has one.\n const say = (key: string, replacements: Record<string, string> = {}) => fail(applyReplacements(DEFAULT_MESSAGES[key]!, replacements))\n if (typeof value !== 'string') return say('string')\n const length = [...value].length\n if (length < this.#min) say('min.string', { min: String(this.#min) })\n if (this.#max !== undefined && length > this.#max) say('max.string', { max: String(this.#max) })\n // Laravel's order and patterns (mixedCase's as hasMixedCase() checks it).\n if (this.#mixedCase && !hasMixedCase(value)) say('password.mixed')\n if (this.#letters && !/\\p{L}/u.test(value)) say('password.letters')\n if (this.#symbols && !/\\p{Z}|\\p{S}|\\p{P}/u.test(value)) say('password.symbols')\n if (this.#numbers && !/\\p{N}/u.test(value)) say('password.numbers')\n }\n\n #copy(): PasswordRule {\n const copy = new PasswordRule(this.#min)\n copy.#max = this.#max\n copy.#letters = this.#letters\n copy.#mixedCase = this.#mixedCase\n copy.#numbers = this.#numbers\n copy.#symbols = this.#symbols\n return copy\n }\n}\n","import type { InValue, RuleTyping, TypedValidationRule, UploadedFile, ValidationRule } from '@orieljs/contracts'\nimport { applyReplacements, DEFAULT_MESSAGES, defaultAttributeName } from './messages'\nimport type { ExpandingRule } from './parse'\nimport { alike } from './rules/array'\nimport { guessColumn, matchingRecordExists } from './rules/database'\nimport { PasswordRule } from './rules/password'\nimport { isListed } from './rules/size'\n\n/**\n * Base for the fluent builders. Each one reports under a built-in rule name (`in`, `unique`, `exists`), so when it\n * runs inside a Validator its failure goes through exactly the same lookup as the string rule: custom messages\n * (\"email.unique\", \"items.*.email.unique\", \"unique\"), custom attributes, then the default text. Called directly\n * as a plain ValidationRule, validate() fails with the default English message.\n */\nexport abstract class BuiltinRuleObject<T extends RuleTyping = Record<never, never>> implements TypedValidationRule<T> {\n abstract readonly ruleName: string\n /** What a passing value is, for the validated data's type (`T`); never set at run time. */\n declare readonly __typing?: T\n\n /** `ruleNames`: the field's named rules, when it runs inside a Validator (`Rule.in()` reads `array`). */\n abstract passes(attribute: string, value: unknown, data: Record<string, unknown>, expandedFromWildcard?: boolean, ruleNames?: readonly string[]): boolean | Promise<boolean>\n\n /** The parameters its message shows (`:values` of Rule.doesntContain()), as the string rule's would be. */\n messageParameters(): string[] {\n return []\n }\n\n // Declares all 4 contract parameters so a subclass's inferred type (from `Rule.in(...)` etc.) still accepts a\n // call with the full 4-arg ValidationRule.validate signature, as Rule.test.ts makes.\n async validate(attribute: string, value: unknown, fail: (message: string) => void, data: Record<string, unknown>, expandedFromWildcard = false): Promise<void> {\n if (await this.passes(attribute, value, data, expandedFromWildcard)) return\n fail(applyReplacements(DEFAULT_MESSAGES[this.ruleName]!, { attribute: defaultAttributeName(attribute), values: this.messageParameters().join(', ') }))\n }\n}\n\n/**\n * What `Rule.in(values)` lets through. A list the compiler only knows as `string[]` says nothing: any value whose text\n * is listed passes (the number 1 for '1'), so `string` would be too narrow. A rule string known only as `string` is\n * treated the same way.\n */\ntype InTyping<V> = string extends V ? Record<never, never> : { value: InValue<V>; each: InValue<V> }\n\nclass InRule<V> extends BuiltinRuleObject<InTyping<V>> {\n readonly ruleName = 'in'\n\n constructor(private readonly values: readonly V[]) {\n super()\n }\n\n passes(_attribute: string, value: unknown, _data?: Record<string, unknown>, _expanded?: boolean, ruleNames: readonly string[] = []): boolean {\n return isListed(value, this.values.map(String), ruleNames)\n }\n}\n\nclass NotInRule extends BuiltinRuleObject {\n readonly ruleName = 'not_in'\n\n constructor(private readonly values: readonly unknown[]) {\n super()\n }\n\n passes(_attribute: string, value: unknown, _data?: Record<string, unknown>, _expanded?: boolean, ruleNames: readonly string[] = []): boolean {\n return !isListed(value, this.values.map(String), ruleNames)\n }\n}\n\n/** A TypeScript enum, or an `as const` object of string and number values. */\ntype EnumLike = Record<string, string | number>\n\n/**\n * The enum's values. A numeric enum's reverse mapping is left out: TypeScript adds `'-1': 'Unknown'` for\n * `Unknown = -1`, a key that is the text of a number member and names that member.\n */\nconst enumValues = (type: EnumLike): Array<string | number> =>\n Object.entries(type)\n .filter(([key, value]) => !(typeof value === 'string' && typeof type[value] === 'number' && String(type[value]) === key))\n .map(([, value]) => value)\n\n/**\n * Laravel's Rule::enum(): one of the enum's values; for a numeric enum, its number or exactly the text of it (a form\n * sends text: `'1'`, not `'1.0'` or `'01'`). only() and except() narrow the values.\n */\nclass EnumRule<E extends EnumLike> extends BuiltinRuleObject<{ value: InValue<E[keyof E]> }> {\n readonly ruleName = 'enum'\n #only: unknown[] = []\n #except: unknown[] = []\n\n constructor(private readonly type: E) {\n super()\n }\n\n only(values: E[keyof E] | ReadonlyArray<E[keyof E]>): this {\n this.#only = Array.isArray(values) ? [...(values as ReadonlyArray<E[keyof E]>)] : [values]\n return this\n }\n\n except(values: E[keyof E] | ReadonlyArray<E[keyof E]>): this {\n this.#except = Array.isArray(values) ? [...(values as ReadonlyArray<E[keyof E]>)] : [values]\n return this\n }\n\n passes(_attribute: string, value: unknown): boolean {\n const match = enumValues(this.type).find((candidate) => candidate === value || (typeof candidate === 'number' && typeof value === 'string' && String(candidate) === value))\n if (match === undefined) return false\n return this.#only.length > 0 ? this.#only.includes(match) : !this.#except.includes(match)\n }\n}\n\n/** Laravel's Rule::contains() and Rule::doesntContain(): every value is an item of the array, or none is. */\nclass ContainsRule extends BuiltinRuleObject<{ value: unknown[] }> {\n constructor(\n readonly ruleName: 'contains' | 'doesnt_contain',\n private readonly values: readonly unknown[],\n ) {\n super()\n }\n\n passes(_attribute: string, value: unknown): boolean {\n if (!Array.isArray(value)) return false\n const found = (needle: unknown) => value.some((item) => alike(item, needle))\n return this.ruleName === 'contains' ? this.values.every(found) : !this.values.some(found)\n }\n\n override messageParameters(): string[] {\n return this.values.map(String)\n }\n}\n\n/** Rules for the field: a rule string, a list, or a callback given the data that returns one. */\ntype RuleSet = string | ReadonlyArray<string | ValidationRule> | ((data: Record<string, unknown>) => string | ReadonlyArray<string | ValidationRule>)\n\n/**\n * Base for the builders that stand for string rules (Laravel's RequiredIf, ConditionalRules, ArrayRule, Dimensions):\n * the Validator puts the rules expandRules() returns in their place, so they run only inside a Validator.\n */\nabstract class ExpandingRuleObject<T extends RuleTyping = Record<never, never>> implements ExpandingRule, TypedValidationRule<T> {\n declare readonly __typing?: T\n\n abstract expandRules(data: Record<string, unknown>): string | ReadonlyArray<string | ValidationRule>\n\n validate(): never {\n throw new Error(`${this.constructor.name} stands for string rules: use it in a Validator's rules.`)\n }\n}\n\n/** Rule.requiredIf(), Rule.excludeIf(), Rule.prohibitedIf(): the rule when the condition holds, else nothing. */\nclass ConditionalRule<T extends RuleTyping = Record<never, never>> extends ExpandingRuleObject<T> {\n constructor(\n private readonly rule: 'required' | 'exclude' | 'prohibited',\n private readonly condition: boolean | (() => boolean),\n ) {\n super()\n }\n\n expandRules(): string {\n return (typeof this.condition === 'function' ? this.condition() : this.condition) ? this.rule : ''\n }\n}\n\n/** Laravel's ConditionalRules (Rule.when() and Rule.unless()): one set of rules or the other, chosen from the data. */\nclass ConditionalRules extends ExpandingRuleObject {\n constructor(\n private readonly condition: boolean | ((data: Record<string, unknown>) => boolean),\n private readonly rules: RuleSet,\n private readonly defaultRules: RuleSet,\n private readonly negate = false,\n ) {\n super()\n }\n\n expandRules(data: Record<string, unknown>): string | ReadonlyArray<string | ValidationRule> {\n const holds = (typeof this.condition === 'function' ? this.condition(data) : this.condition) !== this.negate\n const chosen = holds ? this.rules : this.defaultRules\n return typeof chosen === 'function' ? chosen(data) : chosen\n }\n}\n\n/** Laravel's Rule::array(): `array`, or `array:a,b` (an object whose keys are among those named). */\nclass ArrayRule<K extends string> extends ExpandingRuleObject<{ value: [K] extends [never] ? unknown[] : { [P in K]?: unknown } }> {\n constructor(private readonly keys: readonly K[]) {\n super()\n }\n\n expandRules(): string {\n return this.keys.length === 0 ? 'array' : `array:${this.keys.join(',')}`\n }\n}\n\ntype DimensionConstraints = Partial<Record<'width' | 'height' | 'min_width' | 'min_height' | 'max_width' | 'max_height' | 'ratio', number>>\n\n/** Laravel's Rule::dimensions(): the dimensions rule, from an object or fluently (`.maxWidth(1000).ratio(3 / 2)`). */\nclass DimensionsRule extends ExpandingRuleObject<{ value: UploadedFile }> {\n readonly #constraints: DimensionConstraints\n\n constructor(constraints: DimensionConstraints) {\n super()\n this.#constraints = { ...constraints }\n }\n\n width(pixels: number): this {\n return this.set('width', pixels)\n }\n height(pixels: number): this {\n return this.set('height', pixels)\n }\n minWidth(pixels: number): this {\n return this.set('min_width', pixels)\n }\n minHeight(pixels: number): this {\n return this.set('min_height', pixels)\n }\n maxWidth(pixels: number): this {\n return this.set('max_width', pixels)\n }\n maxHeight(pixels: number): this {\n return this.set('max_height', pixels)\n }\n /** Width over height: `ratio(3 / 2)`. */\n ratio(ratio: number): this {\n return this.set('ratio', ratio)\n }\n\n /** `dimensions:max_width=1000,ratio=1.5`, Laravel's __toString(). */\n override toString(): string {\n return `dimensions:${Object.entries(this.#constraints)\n .map(([key, value]) => `${key}=${value}`)\n .join(',')}`\n }\n\n expandRules(): string {\n return this.toString()\n }\n\n private set(key: keyof DimensionConstraints, value: number): this {\n this.#constraints[key] = value\n return this\n }\n}\n\n/** Structural shape of Database's Model — duck-typed so this package never imports `@orieljs/database` (B27). */\ninterface ModelInstanceLike {\n getKey(): unknown\n getKeyName(): string\n}\n\nfunction isModelInstance(value: unknown): value is ModelInstanceLike {\n return (\n typeof value === 'object' &&\n value !== null &&\n typeof (value as ModelInstanceLike).getKey === 'function' &&\n typeof (value as ModelInstanceLike).getKeyName === 'function'\n )\n}\n\nclass UniqueRule extends BuiltinRuleObject {\n readonly ruleName = 'unique'\n private exceptId: unknown\n private idColumnName: string | undefined\n\n constructor(\n private readonly table: string,\n private readonly column?: string,\n ) {\n super()\n }\n\n /**\n * Excludes the current record from the uniqueness check. Laravel's `Rule::unique('users')->ignore($user)` accepts\n * a model directly (the common case: \"update your profile without changing your email\"), so a model instance is\n * bound by its key (`getKey()`/`getKeyName()`), not the object itself — the object would reach the query builder\n * as an opaque value and either be rejected by the driver or stringified (B27). A plain id still works as before;\n * null (or \"NULL\") excludes nothing.\n */\n ignore(id: unknown, idColumn?: string): this {\n if (isModelInstance(id)) {\n this.exceptId = id.getKey()\n this.idColumnName = idColumn ?? id.getKeyName()\n } else {\n this.exceptId = id\n this.idColumnName = idColumn ?? 'id'\n }\n return this\n }\n\n async passes(attribute: string, value: unknown, _data?: Record<string, unknown>, expandedFromWildcard = false): Promise<boolean> {\n const column = this.column ?? guessColumn(attribute, expandedFromWildcard)\n return !(await matchingRecordExists(this.table, column, value, this.exceptId, this.idColumnName ?? 'id'))\n }\n}\n\nclass ExistsRule extends BuiltinRuleObject {\n readonly ruleName = 'exists'\n\n constructor(\n private readonly table: string,\n private readonly column?: string,\n ) {\n super()\n }\n\n passes(attribute: string, value: unknown, _data?: Record<string, unknown>, expandedFromWildcard = false): Promise<boolean> {\n return matchingRecordExists(this.table, this.column ?? guessColumn(attribute, expandedFromWildcard), value)\n }\n}\n\n/** Fluent rule-object builders, for when a plain string rule can't express what's needed (e.g. .ignore()). */\nexport const Rule = {\n /** One of `values`, compared as text (as `in:a,b`); typed as those values: `Rule.in(['draft', 'publish'])`. */\n in: <const V extends readonly unknown[]>(values: V): InRule<V[number]> => new InRule<V[number]>(values),\n /** None of `values`, compared as text (as `not_in:a,b`). */\n notIn: (values: readonly unknown[]): NotInRule => new NotInRule(values),\n /** One of a TypeScript enum's values (or an `as const` object's): `Rule.enum(Status)`, `.only([…])`, `.except([…])`. */\n enum: <E extends EnumLike>(type: E): EnumRule<E> => new EnumRule(type),\n /** An array holding every one of `values`. */\n contains: (values: readonly unknown[]): ContainsRule => new ContainsRule('contains', values),\n /** An array holding none of `values`. */\n doesntContain: (values: readonly unknown[]): ContainsRule => new ContainsRule('doesnt_contain', values),\n /** `required` when the condition (or the callback) holds. */\n requiredIf: (condition: boolean | (() => boolean)): ConditionalRule => new ConditionalRule('required', condition),\n /** `exclude` when the condition (or the callback) holds; the key is optional, as `exclude_if` makes it. */\n excludeIf: (condition: boolean | (() => boolean)): ConditionalRule<{ presence: 'optional' }> =>\n new ConditionalRule<{ presence: 'optional' }>('exclude', condition),\n /** `prohibited` when the condition (or the callback) holds. */\n prohibitedIf: (condition: boolean | (() => boolean)): ConditionalRule => new ConditionalRule('prohibited', condition),\n /** `rules` when the condition (or the callback, given the data) holds, else `defaultRules`. */\n when: (condition: boolean | ((data: Record<string, unknown>) => boolean), rules: RuleSet, defaultRules: RuleSet = []): ConditionalRules =>\n new ConditionalRules(condition, rules, defaultRules),\n /** `rules` unless the condition (or the callback, given the data) holds, else `defaultRules`. */\n unless: (condition: boolean | ((data: Record<string, unknown>) => boolean), rules: RuleSet, defaultRules: RuleSet = []): ConditionalRules =>\n new ConditionalRules(condition, rules, defaultRules, true),\n /** `array`, or with keys `array:name,email` (an object whose keys are among those named). */\n array: <const K extends string = never>(keys: readonly K[] = []): ArrayRule<K> => new ArrayRule<K>(keys),\n /** The dimensions rule: `Rule.dimensions().maxWidth(1000).ratio(3 / 2)`, or `Rule.dimensions({ min_width: 100 })`. */\n dimensions: (constraints: DimensionConstraints = {}): DimensionsRule => new DimensionsRule(constraints),\n unique: (table: string, column?: string): UniqueRule => new UniqueRule(table, column),\n exists: (table: string, column?: string): ExistsRule => new ExistsRule(table, column),\n /** Laravel's Password::defaults(): the application's password rule (at least 8 characters unless PasswordRule.defaults() changed it). */\n password: (): PasswordRule => PasswordRule.defaults(),\n}\n","import type { InferValidatedType, Rules, Validator } from '@orieljs/contracts'\nimport { Arr } from '@orieljs/support'\nimport { UnknownValidationRuleError, ValidationErrorImpl } from './errors'\nimport { MessageBagImpl } from './MessageBag'\nimport { BuiltinRuleObject } from './Rule'\nimport { applyReplacements, DEFAULT_MESSAGES, defaultAttributeName } from './messages'\nimport type { BuiltinRule, ParsedRule, RuleContext } from './parse'\nimport { expandWildcardKeys, parseRuleSpec, UNSAFE_KEYS } from './parse'\n\nconst SKIPPED_MODIFIERS = new Set(['bail', 'nullable', 'sometimes'])\n\n/**\n * Laravel's dependentRules: the rules whose parameters name other fields. Under a wildcard their `*`s are filled with\n * the row's keys, so `items.*.ends_at: 'after:items.*.starts_at'` compares each row with its own start.\n */\nconst DEPENDENT_RULES: ReadonlySet<string> = new Set([\n 'after', 'after_or_equal', 'before', 'before_or_equal', 'confirmed', 'different', 'exclude_if', 'exclude_unless',\n 'exclude_with', 'exclude_without', 'gt', 'gte', 'lt', 'lte', 'accepted_if', 'declined_if', 'required_if',\n 'required_if_accepted', 'required_if_declined', 'required_unless', 'required_with', 'required_with_all',\n 'required_without', 'required_without_all', 'present_if', 'present_unless', 'present_with', 'present_with_all',\n 'prohibited', 'prohibited_if', 'prohibited_if_accepted', 'prohibited_if_declined', 'prohibited_unless', 'prohibits',\n 'missing_if', 'missing_unless', 'missing_with', 'missing_with_all', 'same', 'unique',\n])\n\n/** The keys a field's wildcards matched: `items.*.tags.*` and `items.2.tags.0` → ['2', '0']. */\nfunction wildcardKeys(pattern: string, field: string): string[] {\n const fieldSegments = field.split('.')\n return pattern.split('.').flatMap((segment, index) => (segment === '*' ? [fieldSegments[index] ?? '*'] : []))\n}\n\n/** Fills each `*` of each parameter with the row's keys, in order (Laravel's replaceAsterisksInParameters). */\nfunction fillWildcards(parameters: string[], keys: string[]): string[] {\n if (keys.length === 0) return parameters\n return parameters.map((parameter) => {\n let index = 0\n return parameter.replace(/\\*/g, () => keys[index++] ?? '*')\n })\n}\n\nfunction patternMatcher(pattern: string): RegExp {\n return new RegExp(`^${pattern.split('.').map((segment) => (segment === '*' ? '[^.]+' : segment.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&'))).join('\\\\.')}$`)\n}\n\n/**\n * Rebuilds a nested structure from flat dot-paths, the way Laravel's validated() does for wildcard fields.\n * `Arr.undot` (from @orieljs/support) always builds plain objects; it can't know \"items.0\"/\"items.1\" should\n * become an array. This walks the same way, then promotes any container it created itself whose keys are exactly\n * \"0\", \"1\", \"2\", … in order into a real array. Leaf values copied from the input (a Date, an uploaded file, an\n * object that happens to have \"0\"/\"1\" keys) are returned untouched, by identity. A path with a segment in\n * UNSAFE_KEYS is dropped, so nothing can be written through to Object.prototype. The input is never mutated.\n */\nfunction buildNested(flat: Record<string, unknown>): Record<string, unknown> {\n const root: Record<string, unknown> = {}\n const created = new Set<object>([root])\n for (const [path, value] of Object.entries(flat)) {\n const parts = path.split('.')\n if (parts.some((part) => UNSAFE_KEYS.has(part))) continue\n let current = root\n for (const part of parts.slice(0, -1)) {\n const existing = Object.hasOwn(current, part) ? current[part] : undefined\n if (typeof existing === 'object' && existing !== null && created.has(existing)) {\n current = existing as Record<string, unknown>\n continue\n }\n const container = cloneContainer(existing)\n created.add(container)\n current[part] = container\n current = container\n }\n current[parts.at(-1)!] = value\n }\n return arrayify(root, created) as Record<string, unknown>\n}\n\nfunction isPlainContainer(value: unknown): value is Record<string, unknown> {\n if (Array.isArray(value)) return true\n if (typeof value !== 'object' || value === null) return false\n const proto: unknown = Object.getPrototypeOf(value)\n return proto === Object.prototype || proto === null\n}\n\n/**\n * A fresh container to write a child path into. When a parent key was already copied from the input (rules on both\n * \"user\" and \"user.name\"), its plain contents are kept (Laravel returns the whole parent) but copied, so the input\n * is never mutated. Anything else (missing, a scalar, a class instance) starts empty.\n */\nfunction cloneContainer(existing: unknown): Record<string, unknown> {\n const container: Record<string, unknown> = {}\n if (!isPlainContainer(existing)) return container\n for (const [key, value] of Object.entries(existing)) {\n if (!UNSAFE_KEYS.has(key)) container[key] = value\n }\n return container\n}\n\n/** Marks a list item an exclude rule took out, until the validated data is built (then the item is dropped). */\nconst EXCLUDED = Symbol('excluded')\n\n/**\n * The data without the excluded paths, as Laravel's removeAttribute() leaves it. Only the plain containers along each\n * path are copied (the input is never mutated); a list item becomes EXCLUDED so the other items keep their indexes\n * while the validated data is built.\n */\nfunction withoutPaths(data: Record<string, unknown>, paths: Iterable<string>): Record<string, unknown> {\n const root: Record<string, unknown> = { ...data }\n const copies = new Set<object>([root])\n for (const path of paths) {\n const parts = path.split('.')\n const leaf = parts.pop()!\n let node: Record<string, unknown> | undefined = root\n for (const part of parts) {\n const child: unknown = Object.hasOwn(node, part) ? node[part] : undefined\n if (!isPlainContainer(child)) {\n node = undefined\n break\n }\n const copy = copies.has(child) ? child : ((Array.isArray(child) ? [...child] : { ...child }) as Record<string, unknown>)\n copies.add(copy)\n node[part] = copy\n node = copy\n }\n if (node === undefined || !Object.hasOwn(node, leaf)) continue\n if (Array.isArray(node)) node[Number(leaf)] = EXCLUDED\n else delete node[leaf]\n }\n return root\n}\n\n/**\n * Drops the EXCLUDED marks from the validated data (only containers it built or copied can hold one): a list closes\n * up, and an object built from a sparse match loses the key.\n */\nfunction dropExcluded(node: unknown, seen = new Set<unknown>()): void {\n if (typeof node !== 'object' || node === null || seen.has(node)) return\n seen.add(node)\n if (Array.isArray(node)) {\n // In place, without spreading the list into a call (Node's stack can't take a list of 150,000 or so).\n if (node.includes(EXCLUDED)) {\n let kept = 0\n for (const item of node) if (item !== EXCLUDED) node[kept++] = item\n node.length = kept\n }\n } else if (isPlainContainer(node)) {\n for (const [key, value] of Object.entries(node)) if (value === EXCLUDED) delete node[key]\n }\n if (isPlainContainer(node)) for (const value of Object.values(node)) dropExcluded(value, seen)\n}\n\n/**\n * A node of the excluded paths' tree: a run of whole segments (joined by dots), the runs that follow it keyed by their\n * first segment, and whether an excluded path ends here. A run holds every segment no other path branches from, so\n * the tree keeps a node or two per excluded path however many dots the paths hold.\n */\ninterface ExcludedRun {\n run: string\n readonly next: Map<string, ExcludedRun>\n excluded: boolean\n}\n\n/** Where the segment of `path` that starts at `start` ends: the next dot, else the end of the path. */\nfunction segmentEnd(path: string, start: number): number {\n const dot = path.indexOf('.', start)\n return dot === -1 ? path.length : dot\n}\n\nfunction arrayify(node: unknown, created: ReadonlySet<object>): unknown {\n if (node === null || typeof node !== 'object' || !created.has(node)) return node\n const entries = Object.entries(node as Record<string, unknown>).map(([k, v]) => [k, arrayify(v, created)] as const)\n const keys = entries.map(([k]) => k)\n const isArrayLike = keys.length > 0 && keys.every((k, i) => k === String(i))\n return isArrayLike ? entries.map(([, v]) => v) : Object.fromEntries(entries)\n}\n\n/**\n * Runs each field's rules the way Laravel's Validator does:\n * - a missing key, or a string that is blank after trimming, only runs implicit rules (the required* family and\n * accepted); every other rule, including ValidationRule objects, is skipped for it;\n * - an explicit null runs every rule unless the field is `nullable` (then only implicit rules run), so\n * `{ age: null }` still fails `integer`;\n * - `sometimes` skips a missing field entirely;\n * - a field stops validating after its first failure under `bail`, or after any implicit rule fails.\n */\nexport class ValidatorImpl<R extends Rules = Rules> implements Validator<R> {\n private bag: MessageBagImpl | undefined\n private ranPromise: Promise<boolean> | undefined\n private readonly afterCallbacks: Array<(validator: Validator) => void | Promise<void>> = []\n private parsedRules: Map<string, ParsedRule[]> | undefined\n /** The fields an exclude rule took out (with their children). */\n private readonly excluded = new Set<string>()\n /** The same fields as a tree of segment runs from the root, so a lookup reads the field once. */\n private readonly excludedRuns: ExcludedRun = { run: '', next: new Map(), excluded: false }\n /** What the rules keep while one pass runs (RuleContext.cache); a new pass starts with a new one. */\n private cache = new Map<string, unknown>()\n\n constructor(\n private readonly data: Record<string, unknown>,\n private readonly rules: R,\n private readonly customMessages: Record<string, string>,\n private readonly customAttributes: Record<string, string>,\n private readonly registry: Record<string, BuiltinRule>,\n private readonly errorBagName = 'default',\n ) {}\n\n after(callback: (validator: Validator) => void | Promise<void>): this {\n this.afterCallbacks.push(callback)\n return this\n }\n\n /** Lets an after() hook add a failure. */\n fail(field: string, message: string): void {\n this.bag ??= new MessageBagImpl()\n this.bag.add(field, message)\n }\n\n async passes(): Promise<boolean> {\n this.ranPromise ??= this.run()\n return this.ranPromise\n }\n\n async fails(): Promise<boolean> {\n return !(await this.passes())\n }\n\n errors(): MessageBagImpl {\n return this.bag ?? new MessageBagImpl()\n }\n\n async validated<T = InferValidatedType<R>>(): Promise<T> {\n if (!(await this.passes())) throw new ValidationErrorImpl(this.bag!.toObject(), this.errorBagName)\n const data = this.excluded.size === 0 ? this.data : withoutPaths(this.data, this.excluded)\n const flat: Record<string, unknown> = {}\n for (const pattern of Object.keys(this.rules)) {\n for (const field of this.fieldsFor(pattern)) {\n if (!this.isExcluded(field) && Arr.has(data, field)) flat[field] = Arr.get(data, field)\n }\n }\n // An excluded list item keeps its index until the list is built, so the list's indexes stay 0..n-1 and it is\n // still built as a list, then closes up.\n for (const path of this.excluded) {\n const parent = path.includes('.') ? path.slice(0, path.lastIndexOf('.')) : undefined\n if (parent === undefined || this.isExcluded(parent) || !Arr.has(this.data, path)) continue\n if (Array.isArray(Arr.get(this.data, parent))) flat[path] = EXCLUDED\n }\n const nested = buildNested(flat)\n if (this.excluded.size > 0) dropExcluded(nested)\n return nested as T\n }\n\n /** Takes the field (with its children) out of validation and of the validated data. */\n private exclude(field: string): void {\n this.excluded.add(field)\n let node = this.excludedRuns\n for (let start = 0; ; ) {\n const first = field.slice(start, segmentEnd(field, start))\n let next = node.next.get(first)\n if (next === undefined) {\n node.next.set(first, { run: field.slice(start), next: new Map(), excluded: true })\n return\n }\n // The whole segments the run and the field share from `start`: at least the first one.\n let same = 0\n while (same < next.run.length && start + same < field.length && next.run[same] === field[start + same]) same++\n const runEnds = same === next.run.length || next.run[same] === '.'\n const fieldEnds = start + same === field.length || field[start + same] === '.'\n if (!runEnds || !fieldEnds) same = next.run.lastIndexOf('.', same - 1)\n if (same < next.run.length) {\n // The field ends or turns off inside the run: split the run after the segments they share.\n const rest = next.run.slice(same + 1)\n const shared: ExcludedRun = { run: next.run.slice(0, same), next: new Map([[rest.slice(0, segmentEnd(rest, 0)), next]]), excluded: false }\n next.run = rest\n node.next.set(first, shared)\n next = shared\n }\n start += same\n if (start === field.length) {\n next.excluded = true\n return\n }\n node = next\n start++\n }\n }\n\n /**\n * Laravel's shouldBeExcluded(): the field, or one of its parents, was taken out by an exclude rule. The field's\n * segments are followed from the root (so `user` takes out `user.name`, not `username`) and each is read once,\n * however many fields were excluded and however many dots the field holds.\n */\n private isExcluded(field: string): boolean {\n if (this.excluded.size === 0) return false\n let node = this.excludedRuns\n for (let start = 0; ; ) {\n const next = node.next.get(field.slice(start, segmentEnd(field, start)))\n if (next === undefined) return false\n const end = start + next.run.length\n // The run must be the field's next whole segments, not the start of a longer segment.\n if (!field.startsWith(next.run, start) || (end < field.length && field[end] !== '.')) return false\n if (next.excluded) return true\n if (end === field.length) return false\n node = next\n start = end + 1\n }\n }\n\n private fieldsFor(pattern: string): string[] {\n return pattern.includes('*') ? expandWildcardKeys(pattern, this.data) : [pattern]\n }\n\n private parsed(): Map<string, ParsedRule[]> {\n this.parsedRules ??= new Map(Object.entries(this.rules).map(([pattern, spec]) => [pattern, parseRuleSpec(spec, this.data)]))\n return this.parsedRules\n }\n\n /** The rule key a concrete field falls under: itself, else the first wildcard key that matches it. */\n private patternOf(field: string): string | undefined {\n const parsed = this.parsed()\n if (parsed.has(field)) return field\n for (const pattern of parsed.keys()) if (pattern.includes('*') && patternMatcher(pattern).test(field)) return pattern\n return undefined\n }\n\n /** Laravel's getRule(): the parameters of rule `name` on `field`, or undefined when the field has no such rule. */\n private ruleParameters(field: string, name: string): string[] | undefined {\n const pattern = this.patternOf(field)\n const rule = pattern === undefined ? undefined : this.parsed().get(pattern)!.find((r) => r.kind === 'named' && r.name === name)\n return rule?.kind === 'named' ? rule.parameters : undefined\n }\n\n /** Laravel's getDisplayableAttribute(): a custom attribute for the field or its rule key, else the humanized key. */\n private displayName(field: string): string {\n const pattern = this.patternOf(field)\n return this.customAttributes[field] ?? (pattern === undefined ? undefined : this.customAttributes[pattern]) ?? defaultAttributeName(field)\n }\n\n private context(field: string, pattern: string, value: unknown, parameters: string[], ruleNames: string[]): RuleContext {\n return {\n attribute: field,\n expandedFromWildcard: pattern.includes('*'),\n value,\n parameters,\n data: this.data,\n ruleNames,\n pattern,\n cache: this.cache,\n getRule: (other, name) => this.ruleParameters(other, name),\n displayName: (other) => this.displayName(other),\n }\n }\n\n private async run(): Promise<boolean> {\n this.bag = new MessageBagImpl()\n this.cache = new Map()\n\n for (const [pattern, parsed] of this.parsed()) {\n const names = parsed.filter((r): r is Extract<ParsedRule, { kind: 'named' }> => r.kind === 'named').map((r) => r.name)\n const bail = names.includes('bail')\n const nullable = names.includes('nullable')\n const sometimes = names.includes('sometimes')\n\n for (const field of this.fieldsFor(pattern)) {\n if (this.isExcluded(field)) continue\n const present = Arr.has(this.data, field)\n if (sometimes && !present) continue\n\n const value = Arr.get(this.data, field)\n const isNull = value === null || value === undefined\n const isBlank = typeof value === 'string' && value.trim() === ''\n\n for (const rule of parsed) {\n if (rule.kind === 'named' && SKIPPED_MODIFIERS.has(rule.name)) continue\n const builtin = rule.kind === 'named' ? this.registry[rule.name] : undefined\n // Laravel's isValidatable(): an exclude rule always runs; failing it takes the field out, with no message.\n if (builtin?.excludes) {\n if (!(await this.passesExcludeRule(rule as Extract<ParsedRule, { kind: 'named' }>, builtin, field, pattern, value, names))) {\n this.exclude(field)\n break\n }\n continue\n }\n const implicit = builtin?.implicit ?? false\n // Laravel's presentOrRuleIsImplicit: a missing key or a blank string only runs implicit rules.\n if (!implicit && (!present || isBlank)) continue\n // Laravel's isNotNullIfMarkedAsNullable: nullable + null only runs implicit rules.\n if (!implicit && nullable && isNull) continue\n\n const messages = await this.runRule(rule, field, pattern, value, names)\n if (messages.length > 0) {\n for (const message of messages) this.bag.add(field, message)\n // Laravel's shouldStopValidating: bail stops at the first failure; a failed implicit rule always stops.\n if (bail || implicit) break\n }\n }\n }\n }\n\n for (const callback of this.afterCallbacks) await callback(this)\n return this.bag.isEmpty()\n }\n\n private async passesExcludeRule(\n rule: Extract<ParsedRule, { kind: 'named' }>,\n builtin: BuiltinRule,\n field: string,\n pattern: string,\n value: unknown,\n ruleNames: string[],\n ): Promise<boolean> {\n return builtin.validate(this.context(field, pattern, value, fillWildcards(rule.parameters, wildcardKeys(pattern, field)), ruleNames))\n }\n\n private async runRule(\n rule: ParsedRule,\n field: string,\n pattern: string,\n value: unknown,\n ruleNames: string[],\n ): Promise<string[]> {\n const expanded = pattern.includes('*')\n if (rule.kind === 'object') {\n if (rule.rule instanceof BuiltinRuleObject) {\n if (await rule.rule.passes(field, value, this.data, expanded, ruleNames)) return []\n const ctx = this.context(field, pattern, value, rule.rule.messageParameters(), ruleNames)\n return [this.failureMessage(rule.rule.ruleName, this.registry[rule.rule.ruleName], ctx, pattern)]\n }\n // Every fail() call is a message, as with Laravel's invokable rules (Rule.password() reports each failed check),\n // with :attribute replaced as in a built-in rule's message.\n const failures: string[] = []\n const attribute = this.displayName(field)\n await rule.rule.validate(field, value, (message) => void failures.push(applyReplacements(message, { attribute })), this.data)\n return failures\n }\n\n const builtin = this.registry[rule.name]\n if (!builtin) throw new UnknownValidationRuleError(rule.name)\n\n const parameters = DEPENDENT_RULES.has(rule.name) ? fillWildcards(rule.parameters, wildcardKeys(pattern, field)) : rule.parameters\n const ctx = this.context(field, pattern, value, parameters, ruleNames)\n if (await builtin.validate(ctx)) return []\n return [this.failureMessage(rule.name, builtin, ctx, pattern)]\n }\n\n /** Custom message (concrete field, then wildcard pattern, then rule name) or the default, with :attribute filled. */\n private failureMessage(name: string, builtin: BuiltinRule | undefined, ctx: RuleContext, pattern: string): string {\n const field = ctx.attribute\n const template =\n this.customMessages[`${field}.${name}`] ??\n this.customMessages[`${pattern}.${name}`] ??\n this.customMessages[name] ??\n builtin?.message ??\n DEFAULT_MESSAGES[builtin?.messageKey(ctx) ?? name] ??\n builtin?.defaultMessage ??\n 'The :attribute field is invalid.'\n\n const display = this.customAttributes[field] ?? this.customAttributes[pattern] ?? defaultAttributeName(field)\n return applyReplacements(template, { attribute: display, ...(builtin?.replacements?.(ctx) ?? {}) })\n }\n}\n","import type { RuleCallback, Rules, ValidationFactory } from '@orieljs/contracts'\nimport type { BuiltinRule } from './parse'\nimport { builtinRules } from './registry'\nimport { ValidatorImpl } from './Validator'\n\nexport class ValidationFactoryImpl implements ValidationFactory {\n private readonly extended: Record<string, BuiltinRule> = {}\n\n make<const R extends Rules>(\n data: Record<string, unknown>,\n rules: R,\n messages: Record<string, string> = {},\n attributes: Record<string, string> = {},\n ): ValidatorImpl<R> {\n return new ValidatorImpl(data, rules, messages, attributes, { ...builtinRules, ...this.extended })\n }\n\n /** Every rule this factory knows, built-in and extend()ed, sorted (for editors: `oriel ide:info`). */\n ruleNames(): string[] {\n return [...new Set([...Object.keys(builtinRules), ...Object.keys(this.extended)])].sort()\n }\n\n extend(name: string, callback: RuleCallback, message?: string): void {\n this.extended[name] = {\n validate: (ctx) => callback(ctx.attribute, ctx.value, ctx.parameters, ctx.data),\n messageKey: () => name,\n ...(message === undefined ? {} : { message }),\n defaultMessage: message ?? 'The :attribute field is invalid.',\n }\n }\n}\n","import type { ValidationFactory } from '@orieljs/contracts'\nimport { ValidationFactory as ValidationFactoryToken } from '@orieljs/contracts'\nimport { facade } from '@orieljs/support'\n\n/** Laravel's Validator facade: Validator.make(...)/Validator.extend(...), proxied to the resolved ValidationFactory. */\nexport const Validator = facade<ValidationFactory>(ValidationFactoryToken)\n","import { ValidationFactory as ValidationFactoryToken } from '@orieljs/contracts'\nimport { ServiceProvider } from '@orieljs/support'\nimport { ValidationFactoryImpl } from './ValidationFactory'\n\nexport class ValidationServiceProvider extends ServiceProvider {\n override register(): void {\n this.app.singleton(ValidationFactoryToken, () => new ValidationFactoryImpl())\n }\n}\n"],"mappings":";AAEO,IAAM,sBAAN,cAAkC,MAAiC;AAAA,EAIxE,YACW,QACA,WAAW,WACX,YACT;AACA,UAAM,6BAA6B;AAJ1B;AACA;AACA;AAAA,EAGX;AAAA,EALW;AAAA,EACA;AAAA,EACA;AAAA,EANF,OAAO;AAAA,EACP,SAAS;AAAA,EACA,OAAO;AAQ3B;AAOO,IAAM,sBAAN,MAAM,6BAA4B,oBAAoB;AAAA;AAAA,EAE3D,OAAO,aAAa,UAA2E;AAC7F,UAAM,SAAS,OAAO,YAAY,OAAO,QAAQ,QAAQ,EAAE,IAAI,CAAC,CAAC,OAAO,IAAI,MAAM,CAAC,OAAO,OAAO,SAAS,WAAW,CAAC,IAAI,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;AAC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AAU,EAAE,WAAW,SAAS,GAAI,SAAS,eAAe,GAAG,KAAK,CAAC,EAAG,CAAC;AAAA,EACpG;AACF;;;ACncO,IAAM,wBAAN,MAAyD;AAAA,EAC7C,WAAwC,CAAC;AAAA,EAE1D,KACE,MACA,OACA,WAAmC,CAAC,GACpC,aAAqC,CAAC,GACpB;AAClB,WAAO,IAAI,cAAc,MAAM,OAAO,UAAU,YAAY,EAAE,GAAG,cAAc,GAAG,KAAK,SAAS,CAAC;AAAA,EACnG;AAAA;AAAA,EAGA,YAAsB;AACpB,WAAO,CAAC,GAAG,oBAAI,IAAI,CAAC,GAAG,OAAO,KAAK,YAAY,GAAG,GAAG,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,KAAK;AAAA,EAC1F;AAAA,EAEA,OAAO,MAAc,UAAwB,SAAwB;AACnE,SAAK,SAAS,IAAI,IAAI;AAAA,MACpB,UAAU,CAAC,QAAQ,SAAS,IAAI,WAAW,IAAI,OAAO,IAAI,YAAY,IAAI,IAAI;AAAA,MAC9E,YAAY,MAAM;AAAA,MAClB,GAAI,YAAY,SAAY,CAAC,IAAI,EAAE,QAAQ;AAAA,MAC3C,gBAAgB,WAAW;AAAA,IAC7B;AAAA,EACF;AACF;;;AC7BA,SAAS,qBAAqB,8BAA8B;AAC5D,SAAS,cAAc;AAGhB,IAAM,YAAY,OAA0B,sBAAsB;;;ACLzE,SAAS,qBAAqBC,+BAA8B;AAC5D,SAAS,uBAAuB;AAGzB,IAAM,4BAAN,cAAwC,gBAAgB;AAAA,EACpD,WAAiB;AACxB,SAAK,IAAI,UAAUC,yBAAwB,MAAM,IAAI,sBAAsB,CAAC;AAAA,EAC9E;AACF;","names":["Arr","Arr","listed","Arr","Arr","Arr","comparison","Arr","inject","inject","Arr","length","format","format","Arr","Arr","Arr","listed","Arr","Str","Str","listed","Arr","Arr","Arr","Arr","Arr","Arr","isPlainObject","COMPARE","Arr","comparison","lower","length","Arr","Arr","ctx","ValidationFactoryToken","ValidationFactoryToken"]}
|
|
1
|
+
{"version":3,"sources":["../errors.ts","../FormRequest.ts","../messages.ts","../MessageBag.ts","../rules/acceptance.ts","../parse.ts","../rules/dependent.ts","../rules/type.ts","../rules/array.ts","../rules/auth.ts","../rules/database.ts","../rules/date.ts","../dates/phpFormat.ts","../rules/exclude.ts","../rules/file.ts","../files/dimensions.ts","../rules/format.ts","../rules/network.ts","../rules/numeric.ts","../rules/presence.ts","../rules/prohibited.ts","../rules/size.ts","../rules/timezone.ts","../registry.ts","../rules/password.ts","../Rule.ts","../Validator.ts","../ValidationFactory.ts","../facade.ts","../ValidationServiceProvider.ts"],"sourcesContent":["import type { OrielError, ValidationError } from '@orieljs/contracts'\n\nexport class ValidationErrorImpl extends Error implements ValidationError {\n readonly kind = 'Validation' as const\n readonly status = 422\n override readonly name = 'ValidationError'\n constructor(\n readonly errors: Record<string, string[]>,\n readonly errorBag = 'default',\n readonly redirectTo?: string,\n ) {\n super('The given data was invalid.')\n }\n}\n\n/**\n * Laravel's ValidationException, for failing a request by hand:\n * `throw ValidationException.withMessages({ email: __('auth.failed') })`. Rendered like any validation error: 422 JSON,\n * or a redirect back with the errors.\n */\nexport class ValidationException extends ValidationErrorImpl {\n /** Messages per field, each a string or a list. */\n static withMessages(messages: Record<string, string | readonly string[]>): ValidationException {\n const errors = Object.fromEntries(Object.entries(messages).map(([field, list]) => [field, typeof list === 'string' ? [list] : [...list]]))\n return new ValidationException(errors)\n }\n\n constructor(errors: Record<string, string[]>, errorBag = 'default', redirectTo?: string) {\n super(errors, errorBag, redirectTo)\n this.message = summarize(errors)\n }\n}\n\n/** \"The first message. (and 2 more errors)\" (Laravel's ValidationException::summarize()). */\nfunction summarize(errors: Record<string, string[]>): string {\n const messages = Object.values(errors).flat()\n if (messages.length === 0) return 'The given data was invalid.'\n const more = messages.length - 1\n return more === 0 ? messages[0]! : `${messages[0]!} (and ${more} more ${more === 1 ? 'error' : 'errors'})`\n}\n\nexport class AuthorizationErrorImpl extends Error implements OrielError {\n readonly kind = 'Authorization' as const\n readonly status = 403\n override readonly name = 'AuthorizationError'\n constructor(message = 'This action is unauthorized.') {\n super(message)\n }\n}\n\nexport class UnknownValidationRuleError extends Error implements OrielError {\n readonly kind = 'Server' as const\n readonly status = 500\n override readonly name = 'UnknownValidationRuleError'\n constructor(name: string) {\n super(`Validation rule \"${name}\" is not registered. Register it with ValidationFactory.extend() first.`)\n }\n}\n\n/** A rule was written with a parameter it can't use (a bad regex, an unparseable date). A developer error, not a user one. */\nexport class InvalidRuleParameterError extends Error implements OrielError {\n readonly kind = 'Server' as const\n readonly status = 500\n override readonly name = 'InvalidRuleParameterError'\n constructor(rule: string, parameter: string, reason: string) {\n super(`Validation rule \"${rule}\" has an invalid parameter \"${parameter}\": ${reason}`)\n }\n}\n","import type { InferValidatedType, Rules } from '@orieljs/contracts'\nimport { HttpRequest, ValidationFactory } from '@orieljs/contracts'\nimport { inject } from '@orieljs/container'\nimport { AuthorizationErrorImpl } from './errors'\n\n/** The data a FormRequest's validate() returns, typed from its rules(). */\ntype ValidatedData<F extends FormRequest> = InferValidatedType<Awaited<ReturnType<F['rules']>>>\n\n/**\n * Mirrors Illuminate\\Foundation\\Http\\FormRequest, minus dependency injection by type (Oriel resolves the current\n * request and the ValidationFactory through inject(), never through constructor parameters — see spec §3 rule 5).\n * A subclass only has to implement rules(); authorize()/messages()/attributes() default to Laravel's own defaults.\n */\nexport abstract class FormRequest {\n /** May be async, to await something first: `async rules() { const user = await request().user<User>() … }`. */\n abstract rules(): Rules | Promise<Rules>\n\n authorize(): boolean | Promise<boolean> {\n return true\n }\n\n messages(): Record<string, string> {\n return {}\n }\n\n attributes(): Record<string, string> {\n return {}\n }\n\n /**\n * `const data = await StorePostRequest.validate()` (spec §4.3). Resolves the current request and the\n * ValidationFactory from the active container, runs authorize() first (throwing AuthorizationErrorImpl if it\n * returns false), then validates request.all() against rules()/messages()/attributes() and returns the validated\n * data (or throws the 422 ValidationError — see ValidatorImpl.validated()). The data is typed from rules(): write\n * it without a return type and with `as const` (`return { title: 'required|string' } as const`), so its rule\n * strings keep their text; a rules() typed `Rules` gives `Record<string, unknown>`.\n */\n static async validate<F extends FormRequest>(this: new () => F): Promise<ValidatedData<F>> {\n const instance = new this()\n if (!(await instance.authorize())) throw new AuthorizationErrorImpl()\n\n const request = inject(HttpRequest)\n const factory = inject(ValidationFactory)\n const validator = factory.make(request.all(), await instance.rules(), instance.messages(), instance.attributes())\n return validator.validated<ValidatedData<F>>()\n }\n}\n","import { Str } from '@orieljs/support'\n\n/** Humanizes a (possibly dotted) attribute key, e.g. \"items.0.product_name\" -> \"items.0.product name\" (\"colors.*\" stays). */\nexport function defaultAttributeName(key: string): string {\n return key\n .split('.')\n .map((segment) => (segment === '*' ? segment : Str.snake(segment).replace(/_/g, ' ')))\n .join('.')\n}\n\nexport function applyReplacements(template: string, replacements: Record<string, string>): string {\n return Object.entries(replacements).reduce((message, [key, value]) => message.replaceAll(`:${key}`, value), template)\n}\n\n/** Laravel's English lang/en/validation.php, reproduced as closely as possible. */\nexport const DEFAULT_MESSAGES: Record<string, string> = {\n required: 'The :attribute field is required.',\n required_if: 'The :attribute field is required when :other is :value.',\n required_unless: 'The :attribute field is required unless :other is in :values.',\n required_with: 'The :attribute field is required when :values is present.',\n required_with_all: 'The :attribute field is required when :values are present.',\n required_without: 'The :attribute field is required when :values is not present.',\n required_without_all: 'The :attribute field is required when none of :values are present.',\n required_if_accepted: 'The :attribute field is required when :other is accepted.',\n required_if_declined: 'The :attribute field is required when :other is declined.',\n present: 'The :attribute field must be present.',\n present_if: 'The :attribute field must be present when :other is :value.',\n present_unless: 'The :attribute field must be present unless :other is :value.',\n present_with: 'The :attribute field must be present when :values is present.',\n present_with_all: 'The :attribute field must be present when :values are present.',\n filled: 'The :attribute field must have a value.',\n missing: 'The :attribute field must be missing.',\n missing_if: 'The :attribute field must be missing when :other is :value.',\n missing_unless: 'The :attribute field must be missing unless :other is :value.',\n missing_with: 'The :attribute field must be missing when :values is present.',\n missing_with_all: 'The :attribute field must be missing when :values are present.',\n prohibited: 'The :attribute field is prohibited.',\n prohibited_if: 'The :attribute field is prohibited when :other is :value.',\n prohibited_if_accepted: 'The :attribute field is prohibited when :other is accepted.',\n prohibited_if_declined: 'The :attribute field is prohibited when :other is declined.',\n prohibited_unless: 'The :attribute field is prohibited unless :other is in :values.',\n prohibits: 'The :attribute field prohibits :other from being present.',\n string: 'The :attribute field must be a string.',\n integer: 'The :attribute field must be an integer.',\n numeric: 'The :attribute field must be a number.',\n boolean: 'The :attribute field must be true or false.',\n array: 'The :attribute field must be an array.',\n list: 'The :attribute field must be a list.',\n required_array_keys: 'The :attribute field must contain entries for: :values.',\n in_array_keys: 'The :attribute field must contain at least one of the following keys: :values.',\n contains: 'The :attribute field is missing a required value.',\n doesnt_contain: 'The :attribute field must not contain any of the following: :values.',\n distinct: 'The :attribute field has a duplicate value.',\n in_array: 'The :attribute field must exist in :other.',\n email: 'The :attribute field must be a valid email address.',\n url: 'The :attribute field must be a valid URL.',\n uuid: 'The :attribute field must be a valid UUID.',\n ulid: 'The :attribute field must be a valid ULID.',\n ascii: 'The :attribute field must only contain single-byte alphanumeric characters and symbols.',\n hex_color: 'The :attribute field must be a valid hexadecimal color.',\n json: 'The :attribute field must be a valid JSON string.',\n ip: 'The :attribute field must be a valid IP address.',\n ipv4: 'The :attribute field must be a valid IPv4 address.',\n ipv6: 'The :attribute field must be a valid IPv6 address.',\n mac_address: 'The :attribute field must be a valid MAC address.',\n active_url: 'The :attribute field must be a valid URL.',\n timezone: 'The :attribute field must be a valid timezone.',\n starts_with: 'The :attribute field must start with one of the following: :values.',\n ends_with: 'The :attribute field must end with one of the following: :values.',\n doesnt_start_with: 'The :attribute field must not start with one of the following: :values.',\n doesnt_end_with: 'The :attribute field must not end with one of the following: :values.',\n alpha: 'The :attribute field must only contain letters.',\n alpha_num: 'The :attribute field must only contain letters and numbers.',\n alpha_dash: 'The :attribute field must only contain letters, numbers, dashes, and underscores.',\n regex: 'The :attribute field format is invalid.',\n not_regex: 'The :attribute field format is invalid.',\n lowercase: 'The :attribute field must be lowercase.',\n uppercase: 'The :attribute field must be uppercase.',\n current_password: 'The password is incorrect.',\n 'password.letters': 'The :attribute field must contain at least one letter.',\n 'password.mixed': 'The :attribute field must contain at least one uppercase and one lowercase letter.',\n 'password.numbers': 'The :attribute field must contain at least one number.',\n 'password.symbols': 'The :attribute field must contain at least one symbol.',\n confirmed: 'The :attribute field confirmation does not match.',\n same: 'The :attribute field must match :other.',\n different: 'The :attribute field and :other must be different.',\n accepted: 'The :attribute field must be accepted.',\n accepted_if: 'The :attribute field must be accepted when :other is :value.',\n declined: 'The :attribute field must be declined.',\n declined_if: 'The :attribute field must be declined when :other is :value.',\n digits: 'The :attribute field must be :digits digits.',\n digits_between: 'The :attribute field must be between :min and :max digits.',\n max_digits: 'The :attribute field must not have more than :max digits.',\n min_digits: 'The :attribute field must have at least :min digits.',\n decimal: 'The :attribute field must have :decimal decimal places.',\n multiple_of: 'The :attribute field must be a multiple of :value.',\n date: 'The :attribute field must be a valid date.',\n before: 'The :attribute field must be a date before :date.',\n before_or_equal: 'The :attribute field must be a date before or equal to :date.',\n after: 'The :attribute field must be a date after :date.',\n after_or_equal: 'The :attribute field must be a date after or equal to :date.',\n date_equals: 'The :attribute field must be a date equal to :date.',\n date_format: 'The :attribute field must match the format :format.',\n in: 'The selected :attribute is invalid.',\n not_in: 'The selected :attribute is invalid.',\n enum: 'The selected :attribute is invalid.',\n unique: 'The :attribute has already been taken.',\n exists: 'The selected :attribute is invalid.',\n file: 'The :attribute field must be a file.',\n image: 'The :attribute field must be an image.',\n mimes: 'The :attribute field must be a file of type: :values.',\n mimetypes: 'The :attribute field must be a file of type: :values.',\n extensions: 'The :attribute field must have one of the following extensions: :values.',\n dimensions: 'The :attribute field has invalid image dimensions.',\n 'max.string': 'The :attribute field must not be greater than :max characters.',\n 'max.numeric': 'The :attribute field must not be greater than :max.',\n 'max.array': 'The :attribute field must not have more than :max items.',\n 'max.file': 'The :attribute field must not be greater than :max kilobytes.',\n 'min.string': 'The :attribute field must be at least :min characters.',\n 'min.numeric': 'The :attribute field must be at least :min.',\n 'min.array': 'The :attribute field must have at least :min items.',\n 'min.file': 'The :attribute field must be at least :min kilobytes.',\n 'between.string': 'The :attribute field must be between :min and :max characters.',\n 'between.numeric': 'The :attribute field must be between :min and :max.',\n 'between.array': 'The :attribute field must have between :min and :max items.',\n 'between.file': 'The :attribute field must be between :min and :max kilobytes.',\n 'size.string': 'The :attribute field must be :size characters.',\n 'size.numeric': 'The :attribute field must be :size.',\n 'size.array': 'The :attribute field must contain :size items.',\n 'size.file': 'The :attribute field must be :size kilobytes.',\n 'gt.array': 'The :attribute field must have more than :value items.',\n 'gt.file': 'The :attribute field must be greater than :value kilobytes.',\n 'gt.numeric': 'The :attribute field must be greater than :value.',\n 'gt.string': 'The :attribute field must be greater than :value characters.',\n 'gte.array': 'The :attribute field must have :value items or more.',\n 'gte.file': 'The :attribute field must be greater than or equal to :value kilobytes.',\n 'gte.numeric': 'The :attribute field must be greater than or equal to :value.',\n 'gte.string': 'The :attribute field must be greater than or equal to :value characters.',\n 'lt.array': 'The :attribute field must have less than :value items.',\n 'lt.file': 'The :attribute field must be less than :value kilobytes.',\n 'lt.numeric': 'The :attribute field must be less than :value.',\n 'lt.string': 'The :attribute field must be less than :value characters.',\n 'lte.array': 'The :attribute field must not have more than :value items.',\n 'lte.file': 'The :attribute field must be less than or equal to :value kilobytes.',\n 'lte.numeric': 'The :attribute field must be less than or equal to :value.',\n 'lte.string': 'The :attribute field must be less than or equal to :value characters.',\n}\n","import type { MessageBag } from '@orieljs/contracts'\n\nexport class MessageBagImpl implements MessageBag {\n // No prototype: a field named `constructor` or `toString` is a key like any other.\n private readonly items: Record<string, string[]> = Object.create(null) as Record<string, string[]>\n\n add(key: string, message: string): void {\n ;(this.items[key] ??= []).push(message)\n }\n\n has(key: string): boolean {\n return (this.items[key]?.length ?? 0) > 0\n }\n\n first(key?: string): string | undefined {\n if (key !== undefined) return this.items[key]?.[0]\n for (const messages of Object.values(this.items)) {\n if (messages[0] !== undefined) return messages[0]\n }\n return undefined\n }\n\n get(key: string): string[] {\n return this.items[key] ?? []\n }\n\n all(): string[] {\n return Object.values(this.items).flat()\n }\n\n isEmpty(): boolean {\n return Object.keys(this.items).length === 0\n }\n\n count(): number {\n return this.all().length\n }\n\n toObject(): Record<string, string[]> {\n return structuredClone(this.items)\n }\n}\n","import { Arr } from '@orieljs/support'\nimport type { BuiltinRule } from '../parse'\nimport { isEmptyValue } from '../parse'\nimport { otherAndValue, otherFieldMatches } from './dependent'\n\nconst ACCEPTED_VALUES: unknown[] = ['yes', 'on', 1, '1', true, 'true']\nconst DECLINED_VALUES: unknown[] = ['no', 'off', 0, '0', false, 'false']\n\n/** Laravel's validateAccepted(): yes, on, 1, '1', true or 'true'. */\nexport const isAccepted = (value: unknown): boolean => !isEmptyValue(value) && ACCEPTED_VALUES.includes(value)\n\n/** Laravel's validateDeclined(): no, off, 0, '0', false or 'false'. */\nexport const isDeclined = (value: unknown): boolean => !isEmptyValue(value) && DECLINED_VALUES.includes(value)\n\n/** Whether the field the first parameter names is accepted (or declined), for the `_if_accepted` rules. */\nexport const otherAccepted = (data: Record<string, unknown>, field = ''): boolean => isAccepted(Arr.get(data, field))\nexport const otherDeclined = (data: Record<string, unknown>, field = ''): boolean => isDeclined(Arr.get(data, field))\n\nexport const acceptanceRules: Record<string, BuiltinRule> = {\n accepted: { implicit: true, validate: (ctx) => isAccepted(ctx.value), messageKey: () => 'accepted' },\n accepted_if: {\n implicit: true,\n validate: (ctx) => !otherFieldMatches(ctx) || isAccepted(ctx.value),\n messageKey: () => 'accepted_if',\n replacements: otherAndValue,\n },\n declined: { implicit: true, validate: (ctx) => isDeclined(ctx.value), messageKey: () => 'declined' },\n declined_if: {\n implicit: true,\n validate: (ctx) => !otherFieldMatches(ctx) || isDeclined(ctx.value),\n messageKey: () => 'declined_if',\n replacements: otherAndValue,\n },\n}\n","import type { ValidationRule } from '@orieljs/contracts'\nimport { Arr } from '@orieljs/support'\n\n/** Everything a single rule needs to validate one concrete field. */\nexport interface RuleContext {\n /** The concrete, wildcard-expanded field path, e.g. \"items.1.name\". */\n attribute: string\n /** True when `attribute` came from expanding a wildcard pattern such as \"items.*.email\". */\n expandedFromWildcard?: boolean\n value: unknown\n parameters: string[]\n data: Record<string, unknown>\n /** Every named rule attached to this field (for size-type resolution: numeric/array/file/string). */\n ruleNames: string[]\n /** The rule key as written, e.g. \"items.*.email\" (distinct reads every row of it). */\n pattern?: string\n /**\n * What the rules keep for one validation pass, such as every row a wildcard names: each pass starts with an empty\n * one, so nothing outlives the data it was read from. Absent when a rule runs on its own.\n */\n cache?: Map<string, unknown>\n /** The parameters of rule `name` on `field` (a concrete path), or undefined when that field has no such rule. */\n getRule?(field: string, name: string): string[] | undefined\n /** How a message names `field`: its custom attribute, else the humanized key. */\n displayName?(field: string): string\n}\n\nexport interface BuiltinRule {\n validate(ctx: RuleContext): boolean | Promise<boolean>\n /** Which DEFAULT_MESSAGES key to use, e.g. `max.${sizeType}`. Most rules return a constant name. */\n messageKey(ctx: RuleContext): string\n /** Extra :placeholder substitutions beyond :attribute (e.g. :max, :other, :values). */\n replacements?(ctx: RuleContext): Record<string, string>\n /** Used when messageKey() isn't in DEFAULT_MESSAGES (e.g. an extend()ed rule with a custom message). */\n defaultMessage?: string\n /** An extend()ed rule's own message: it wins over the default lines, as Laravel's fallback messages do. */\n message?: string\n /** Runs even when the value is missing, blank, or null under nullable (the required* family, and accepted); a failure stops the field. */\n implicit?: boolean\n /**\n * An exclude rule (`exclude`, `exclude_if`, …): it always runs, and when validate() returns false the field and its\n * children are skipped from then on and left out of the validated data, with no message.\n */\n excludes?: boolean\n}\n\nexport type ParsedRule =\n | { kind: 'named'; name: string; parameters: string[] }\n | { kind: 'object'; rule: ValidationRule }\n\nfunction splitParameters(name: string, raw: string): string[] {\n // regex/not_regex parameters are never comma-split, so a pattern containing a comma survives intact.\n return name === 'regex' || name === 'not_regex' ? [raw] : raw.split(',')\n}\n\nfunction splitOnce(value: string, separator: string): [string, string | undefined] {\n const index = value.indexOf(separator)\n return index === -1 ? [value, undefined] : [value.slice(0, index), value.slice(index + 1)]\n}\n\n/**\n * A rule object that stands for string rules (Rule.requiredIf(), Rule.when(), Rule.array(), …), as Laravel's\n * ValidationRuleParser reads them: the rules expandRules() returns, given the data, take its place.\n */\nexport interface ExpandingRule extends ValidationRule {\n expandRules(data: Record<string, unknown>): string | ReadonlyArray<string | ValidationRule>\n}\n\nfunction isExpandingRule(item: unknown): item is ExpandingRule {\n return typeof item === 'object' && item !== null && typeof (item as Partial<ExpandingRule>).expandRules === 'function'\n}\n\nexport function parseRuleSpec(spec: string | ReadonlyArray<string | ValidationRule>, data: Record<string, unknown> = {}): ParsedRule[] {\n const items = typeof spec === 'string' ? spec.split('|') : spec\n return items\n .filter((item) => item !== '')\n .flatMap((item): ParsedRule[] => {\n if (isExpandingRule(item)) return parseRuleSpec(item.expandRules(data), data)\n if (typeof item !== 'string') return [{ kind: 'object', rule: item }]\n const [name, raw] = splitOnce(item, ':')\n return [{ kind: 'named', name, parameters: raw === undefined ? [] : splitParameters(name, raw) }]\n })\n}\n\n/**\n * Laravel's definition of \"empty\" for the required family (validateRequired()): null, undefined, text that is blank\n * once trimmed, an empty array and an empty plain object (a JSON object is a PHP array). false and 0 are NOT empty.\n */\nexport function isEmptyValue(value: unknown): boolean {\n if (value === null || value === undefined) return true\n if (typeof value === 'string') return value.trim() === ''\n if (Array.isArray(value)) return value.length === 0\n if (typeof value === 'object') {\n const proto: unknown = Object.getPrototypeOf(value)\n return (proto === Object.prototype || proto === null) && Object.keys(value).length === 0\n }\n return false\n}\n\n/** Duck-types Contracts/Http's UploadedFile without importing @orieljs/http. */\nexport function isUploadedFileLike(value: unknown): value is {\n clientName: string\n mimeType: string\n size: number\n extension(): string\n arrayBuffer(): Promise<ArrayBuffer>\n} {\n return (\n typeof value === 'object' &&\n value !== null &&\n typeof (value as Record<string, unknown>).clientName === 'string' &&\n typeof (value as Record<string, unknown>).arrayBuffer === 'function'\n )\n}\n\n/**\n * Keys that must never be followed or written when walking user input: assigning through them reaches\n * Object.prototype (or a constructor) instead of a plain data slot. Mirrors the guard in Arr.set.\n */\nexport const UNSAFE_KEYS: ReadonlySet<string> = new Set(['__proto__', 'prototype', 'constructor'])\n\n/**\n * Expands a `*`-wildcard rule pattern (e.g. \"items.*.name\") into every concrete path present in `data`\n * (e.g. [\"items.0.name\", \"items.1.name\"]). A pattern with no `*` is returned unchanged. A `*` segment whose\n * container is missing, not an array and not a plain object expands to nothing for that branch, so every reported\n * error is keyed by a concrete path, never the literal pattern. Object keys in UNSAFE_KEYS are\n * treated as absent, so a JSON body like {\"items\":{\"__proto__\":{...}}} never yields a path through the prototype.\n */\nexport function expandWildcardKeys(pattern: string, data: Record<string, unknown>): string[] {\n const segments = pattern.split('.')\n let paths = ['']\n for (const segment of segments) {\n const next: string[] = []\n for (const base of paths) {\n const prefix = base === '' ? '' : `${base}.`\n if (segment !== '*') {\n next.push(`${prefix}${segment}`)\n continue\n }\n const container = Arr.get<unknown>(data, base === '' ? undefined : base)\n if (Array.isArray(container)) {\n container.forEach((_, index) => next.push(`${prefix}${index}`))\n } else if (container !== null && typeof container === 'object') {\n Object.keys(container)\n .filter((key) => !UNSAFE_KEYS.has(key))\n .forEach((key) => next.push(`${prefix}${key}`))\n }\n }\n paths = next\n }\n return paths\n}\n","import { Arr } from '@orieljs/support'\nimport { defaultAttributeName } from '../messages'\nimport type { RuleContext } from '../parse'\nimport { isNumeric } from './type'\n\n/** PHP's truthiness, for a loose comparison with true or false. */\nexport function truthy(value: unknown): boolean {\n if (typeof value === 'string') return value !== '' && value !== '0'\n if (Array.isArray(value)) return value.length > 0\n return Boolean(value)\n}\n\n/** PHP 8's `==` between a field's value and a rule parameter (text, or true/false once converted). */\nexport function looseEquals(value: unknown, parameter: string | boolean): boolean {\n if (typeof parameter === 'boolean') return truthy(value) === parameter\n if (typeof value === 'number') return isNumeric(parameter) ? Number(parameter) === value : String(value) === parameter\n if (typeof value === 'string') return isNumeric(value) && isNumeric(parameter) ? Number(value) === Number(parameter) : value === parameter\n return false\n}\n\n/**\n * Laravel's parseDependentRuleParameters() and its in_array() check, for the `_if` and `_unless` rules: whether the\n * field named by the first parameter holds one of the others. `true`/`false` match a boolean (or a field with the\n * `boolean` rule, whose '1' and '0' they then match); `null` matches a null or missing field; numbers match their text.\n */\nexport function otherFieldMatches(ctx: RuleContext): boolean {\n const [field = '', ...listed] = ctx.parameters\n const other = Arr.get<unknown>(ctx.data, field)\n let values: Array<string | boolean | null> = listed\n if (typeof other === 'boolean' || ctx.getRule?.(field, 'boolean') !== undefined) {\n values = values.map((value) => (value === 'true' ? true : value === 'false' ? false : value))\n }\n if (other === null || other === undefined) {\n values = values.map((value) => (typeof value === 'string' && value.toLowerCase() === 'null' ? null : value))\n return values.includes(null)\n }\n if (typeof other === 'boolean') return values.includes(other)\n return values.some((value) => value !== null && looseEquals(other, value))\n}\n\n/** Laravel's getDisplayableValue(): how a message shows a value (true, false, empty, array, or its text). */\nexport function displayableValue(value: unknown): string {\n if (typeof value === 'boolean') return value ? 'true' : 'false'\n if (value === null || value === undefined) return 'empty'\n if (typeof value === 'object') return 'array'\n return String(value)\n}\n\n/** Laravel's getDisplayableAttribute(): the field's custom name, else its humanized key. */\nexport function displayName(ctx: RuleContext, field: string): string {\n return ctx.displayName?.(field) ?? defaultAttributeName(field)\n}\n\n/** `:other` and `:value` for the `_if` rules: the other field's name and the value it holds. */\nexport function otherAndValue(ctx: RuleContext): Record<string, string> {\n const field = ctx.parameters[0] ?? ''\n return { other: displayName(ctx, field), value: displayableValue(Arr.get(ctx.data, field)) }\n}\n\n/** `:other` and `:values` for the `_unless` rules: the other field's name and the values listed. */\nexport function otherAndValues(ctx: RuleContext): Record<string, string> {\n return { other: displayName(ctx, ctx.parameters[0] ?? ''), values: ctx.parameters.slice(1).join(', ') }\n}\n\n/** `:values` for the `_with` rules: the fields named, joined with \" / \". */\nexport function fieldList(ctx: RuleContext): Record<string, string> {\n return { values: ctx.parameters.map((field) => displayName(ctx, field)).join(' / ') }\n}\n","import type { BuiltinRule } from '../parse'\n\nconst BOOLEAN_VALUES: unknown[] = [true, false, 0, 1, '0', '1']\n\n/** PHP's is_numeric for strings: optional surrounding whitespace and sign, decimal digits, optional exponent. */\nconst NUMERIC_STRING_RE = /^\\s*[+-]?(?:\\d+(?:\\.\\d*)?|\\.\\d+)(?:[eE][+-]?\\d+)?\\s*$/\n\n/**\n * Laravel's `numeric` (PHP is_numeric): a finite number, or a decimal string. Unlike `Number()`, it rejects\n * \"Infinity\", hex/binary/octal literals (\"0x1F\", \"0b101\", \"0o7\") and the empty string.\n */\nexport function isNumeric(value: unknown): boolean {\n if (typeof value === 'number') return Number.isFinite(value)\n return typeof value === 'string' && NUMERIC_STRING_RE.test(value)\n}\n\n/** A JSON object: what PHP calls an associative array. */\nexport function isPlainObject(value: unknown): value is Record<string, unknown> {\n if (typeof value !== 'object' || value === null || Array.isArray(value)) return false\n const proto: unknown = Object.getPrototypeOf(value)\n return proto === Object.prototype || proto === null\n}\n\nexport const typeRules: Record<string, BuiltinRule> = {\n string: { validate: (ctx) => typeof ctx.value === 'string', messageKey: () => 'string' },\n /** `integer:strict` refuses the text of a number (Laravel's is_int()). */\n integer: {\n validate: (ctx) =>\n ctx.parameters[0] === 'strict'\n ? Number.isInteger(ctx.value)\n : typeof ctx.value !== 'object' && /^-?\\d+$/.test(String(ctx.value).trim()),\n messageKey: () => 'integer',\n },\n /** `numeric:strict` refuses the text of a number. */\n numeric: {\n validate: (ctx) => (ctx.parameters[0] === 'strict' ? typeof ctx.value === 'number' && Number.isFinite(ctx.value) : isNumeric(ctx.value)),\n messageKey: () => 'numeric',\n },\n /** `boolean:strict` lets only true and false through. */\n boolean: {\n validate: (ctx) => (ctx.parameters[0] === 'strict' ? typeof ctx.value === 'boolean' : BOOLEAN_VALUES.includes(ctx.value)),\n messageKey: () => 'boolean',\n },\n /**\n * `array`: a list. `array:name,email`: an object (PHP's associative array) whose keys are all among those named, as\n * Laravel's validateArray() with keys.\n */\n array: {\n validate: (ctx) => (ctx.parameters.length === 0 ? Array.isArray(ctx.value) : isPlainObject(ctx.value) && Object.keys(ctx.value).every((key) => ctx.parameters.includes(key))),\n messageKey: () => 'array',\n },\n}\n","import { Arr } from '@orieljs/support'\nimport type { BuiltinRule, RuleContext } from '../parse'\nimport { expandWildcardKeys } from '../parse'\nimport { displayName, looseEquals, truthy } from './dependent'\nimport { isNumeric, isPlainObject } from './type'\n\n/** PHP's in_array() comparison: `==` (a number and its text are alike), or `===` when strict. */\nexport function alike(a: unknown, b: unknown, strict = false): boolean {\n if (strict || a === b) return a === b\n if (typeof b === 'string' || typeof b === 'boolean') return looseEquals(a, b)\n if (typeof a === 'string' || typeof a === 'boolean') return looseEquals(b, a)\n return false\n}\n\nconst listed = (values: readonly string[]): Record<string, string> => ({ values: values.join(', ') })\n\n/** How `distinct` and `in_array` compare: PHP's loose `==` (alike()), `===`, or text in any case. */\ntype Comparison = 'loose' | 'strict' | 'ignore_case'\n\n/** Whether `value` matches `other` under the comparison (`value` is the field's own, as alike() reads it). */\nfunction matches(value: unknown, other: unknown, comparison: Comparison): boolean {\n if (comparison === 'strict') return value === other\n if (comparison === 'loose') return alike(value, other)\n return (typeof other === 'string' || typeof other === 'number') && String(other).toLowerCase() === String(value).toLowerCase()\n}\n\n/**\n * The classes PHP's `==` keeps apart for a string or finite number: numbers and numeric text by value, other text as\n * written. Anything else (booleans, null, objects, NaN and ±Infinity) has no class and is counted another way.\n */\nfunction looseClass(value: unknown): string | undefined {\n if (typeof value === 'number') return Number.isFinite(value) ? `n:${value}` : undefined\n if (typeof value === 'string') return isNumeric(value) ? `n:${Number(value)}` : `s:${value}`\n return undefined\n}\n\nconst increment = <K>(counts: Map<K, number>, key: K): Map<K, number> => counts.set(key, (counts.get(key) ?? 0) + 1)\n\n/**\n * The values of every field a pattern names (`colors.*`, `items.*.id`), counted so that how many of them a value\n * matches is answered without reading every row again, as Laravel keeps each pattern's values for the whole pass.\n */\nclass PatternValues {\n /** By identity (SameValueZero): strict comparison, and null, undefined and objects under loose comparison. */\n private readonly identical = new Map<unknown, number>()\n /** Strings and numbers by their lower-cased text. */\n private readonly text = new Map<string, number>()\n /** Strings and finite numbers by looseClass(). */\n private readonly classes = new Map<string, number>()\n /** Booleans by value: what a string, number, null or object equals loosely besides its own class. */\n private readonly booleans = new Map<boolean, number>()\n /** Every value but a string, by PHP truthiness: what a boolean equals loosely. */\n private readonly truthiness = new Map<boolean, number>()\n /** NaN and ±Infinity, compared one by one. */\n private readonly unclassed: unknown[] = []\n\n constructor(private readonly values: readonly unknown[]) {\n for (const value of values) {\n increment(this.identical, value)\n if (typeof value === 'string' || typeof value === 'number') increment(this.text, String(value).toLowerCase())\n const loose = looseClass(value)\n if (loose !== undefined) increment(this.classes, loose)\n else if (typeof value === 'number') this.unclassed.push(value)\n if (typeof value === 'boolean') increment(this.booleans, value)\n if (typeof value !== 'string') increment(this.truthiness, truthy(value))\n }\n }\n\n /** How many of the values `value` matches under the comparison. */\n count(value: unknown, comparison: Comparison): number {\n if (comparison === 'strict') return Number.isNaN(value) ? 0 : (this.identical.get(value) ?? 0)\n if (comparison === 'ignore_case') return this.text.get(String(value).toLowerCase()) ?? 0\n if (typeof value === 'boolean') return this.truthiness.get(value) ?? 0\n const loose = looseClass(value)\n if (loose === undefined && typeof value === 'number') return this.values.filter((other) => alike(value, other)).length\n const own = loose === undefined ? (this.identical.get(value) ?? 0) : (this.classes.get(loose) ?? 0) + this.unclassed.filter((other) => alike(value, other)).length\n return own + (this.booleans.get(truthy(value)) ?? 0)\n }\n\n /** The values of the fields `pattern` names in the context's data, gathered once per validation pass. */\n static of(ctx: RuleContext, pattern: string): PatternValues {\n const key = `array:values:${pattern}`\n const cached = ctx.cache?.get(key)\n if (cached instanceof PatternValues) return cached\n const fields = expandWildcardKeys(pattern, ctx.data).filter((field) => Arr.has(ctx.data, field))\n const values = new PatternValues(fields.map((field) => Arr.get<unknown>(ctx.data, field)))\n ctx.cache?.set(key, values)\n return values\n }\n}\n\nexport const arrayRules: Record<string, BuiltinRule> = {\n list: { validate: (ctx) => Array.isArray(ctx.value), messageKey: () => 'list' },\n required_array_keys: {\n validate: (ctx) => isPlainObject(ctx.value) && ctx.parameters.every((key) => Object.hasOwn(ctx.value as object, key)),\n messageKey: () => 'required_array_keys',\n replacements: (ctx) => listed(ctx.parameters),\n },\n in_array_keys: {\n validate: (ctx) => isPlainObject(ctx.value) && ctx.parameters.some((key) => Object.hasOwn(ctx.value as object, key)),\n messageKey: () => 'in_array_keys',\n replacements: (ctx) => listed(ctx.parameters),\n },\n /** Every value named is an item of the array (compared as PHP's in_array() does). */\n contains: {\n validate: (ctx) => {\n const items = ctx.value\n return Array.isArray(items) && ctx.parameters.every((needle) => items.some((item) => alike(item, needle)))\n },\n messageKey: () => 'contains',\n },\n doesnt_contain: {\n validate: (ctx) => {\n const items = ctx.value\n return Array.isArray(items) && !ctx.parameters.some((needle) => items.some((item) => alike(item, needle)))\n },\n messageKey: () => 'doesnt_contain',\n replacements: (ctx) => listed(ctx.parameters),\n },\n /**\n * Laravel's validateDistinct(): no other field under the same wildcard holds this value. `distinct:strict` compares\n * with `===`; `distinct:ignore_case` compares text case-insensitively.\n */\n distinct: {\n validate: (ctx) => {\n const comparison: Comparison = ctx.parameters.includes('ignore_case') ? 'ignore_case' : ctx.parameters.includes('strict') ? 'strict' : 'loose'\n const own = Arr.has(ctx.data, ctx.attribute) && matches(ctx.value, Arr.get(ctx.data, ctx.attribute), comparison) ? 1 : 0\n return PatternValues.of(ctx, ctx.pattern ?? ctx.attribute).count(ctx.value, comparison) - own === 0\n },\n messageKey: () => 'distinct',\n },\n /** The value is one of the values of the fields the parameter names (`in_array:colors.*`). */\n in_array: {\n validate: (ctx) => PatternValues.of(ctx, ctx.parameters[0] ?? '').count(ctx.value, 'loose') > 0,\n messageKey: () => 'in_array',\n replacements: (ctx) => ({ other: displayName(ctx, ctx.parameters[0] ?? '') }),\n },\n}\n","import { AuthFactory, Hasher } from '@orieljs/contracts'\nimport { inject } from '@orieljs/container'\nimport type { BuiltinRule } from '../parse'\n\n/** `current_password` / `current_password:<guard>`: the value is the signed-in user's password (Laravel). */\nexport const authRules: Record<string, BuiltinRule> = {\n current_password: {\n validate: async (ctx) => {\n const guard = inject(AuthFactory).guard(ctx.parameters[0])\n if (await guard.guest()) return false\n const user = await guard.user()\n return user !== undefined && typeof ctx.value === 'string' && inject(Hasher).check(ctx.value, user.getAuthPassword())\n },\n messageKey: () => 'current_password',\n },\n}\n","import { DatabaseManager } from '@orieljs/contracts'\nimport { inject } from '@orieljs/container'\nimport type { BuiltinRule } from '../parse'\n\n/**\n * The column to query when a unique/exists rule doesn't name one: the attribute itself, except for a\n * wildcard-expanded field like \"items.0.email\", which checks the last non-numeric segment (\"email\") rather than a\n * column literally named after the path (Laravel's guessColumnForQuery).\n */\nexport function guessColumn(attribute: string, expandedFromWildcard = false): string {\n if (!expandedFromWildcard) return attribute\n return attribute.split('.').filter((segment) => !/^\\d+$/.test(segment)).at(-1) ?? attribute\n}\n\n/** Laravel's idiom `unique:users,email,NULL,id` (and an empty or null ignore) means \"exclude nothing\". */\nfunction isNoExcept(except: unknown): boolean {\n return except === undefined || except === null || except === '' || except === 'NULL'\n}\n\n/**\n * Shared query shape behind both `unique`/`exists` string rules and `Rule.unique()`/`Rule.exists()`:\n * resolve DatabaseManager, filter table/column on value, optionally exclude a record by idColumn/except, and\n * report whether any row matches. Kept in one place so a future fix to this path can't miss one of the two callers.\n */\nexport async function matchingRecordExists(\n table: string,\n column: string,\n value: unknown,\n except?: unknown,\n idColumn = 'id',\n): Promise<boolean> {\n const db = inject(DatabaseManager)\n let query = db.connection().table(table).where(column, value)\n if (!isNoExcept(except)) query = query.where(idColumn, '!=', except)\n return query.exists()\n}\n\nexport const databaseRules: Record<string, BuiltinRule> = {\n unique: {\n validate: async (ctx) => {\n const [table, column, except, idColumn] = ctx.parameters\n return !(await matchingRecordExists(table!, column || guessColumn(ctx.attribute, ctx.expandedFromWildcard), ctx.value, except, idColumn || 'id'))\n },\n messageKey: () => 'unique',\n },\n exists: {\n validate: async (ctx) => {\n const [table, column] = ctx.parameters\n return matchingRecordExists(table!, column || guessColumn(ctx.attribute, ctx.expandedFromWildcard), ctx.value)\n },\n messageKey: () => 'exists',\n },\n}\n","import { Arr } from '@orieljs/support'\nimport { assertSupportedFormat, matchesFormat, timestampWithFormat } from '../dates/phpFormat'\nimport { InvalidRuleParameterError } from '../errors'\nimport type { BuiltinRule, RuleContext } from '../parse'\nimport { displayName } from './dependent'\n\n/**\n * Shapes a string must have before it counts as a date. Date.parse alone is far too lenient (V8 reads \"1\" as the\n * year 2001), so a value needs an ISO date, a slashed/dotted/dashed day-month-year, or a month name with a number.\n */\nconst DATE_SHAPES = [\n /^\\d{4}-\\d{1,2}-\\d{1,2}(?:[T\\s].*)?$/,\n /^\\d{1,2}[/.-]\\d{1,2}[/.-]\\d{2,4}(?:\\s.*)?$/,\n /^(?=.*\\d).*\\b(?:jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)[a-z]*\\b/i,\n]\nconst DATE_ONLY_RE = /^(\\d{4})-(\\d{2})-(\\d{2})$/\n\n/**\n * Parses a user-supplied date string to epoch milliseconds, or NaN. A bare YYYY-MM-DD means local midnight, like\n * PHP's strtotime, so it compares sensibly against `today`/`tomorrow`.\n */\nfunction parseDate(value: string): number {\n const trimmed = value.trim()\n if (!DATE_SHAPES.some((shape) => shape.test(trimmed))) return Number.NaN\n const dateOnly = DATE_ONLY_RE.exec(trimmed)\n if (dateOnly) {\n const [, y, m, d] = dateOnly.map(Number) as [number, number, number, number]\n const local = new Date(y, m - 1, d)\n return local.getMonth() === m - 1 && local.getDate() === d ? local.getTime() : Number.NaN\n }\n return Date.parse(trimmed)\n}\n\nfunction startOfDay(offsetDays: number): number {\n const date = new Date()\n date.setHours(0, 0, 0, 0)\n date.setDate(date.getDate() + offsetDays)\n return date.getTime()\n}\n\nconst RELATIVE_RE = /^([+-]\\d+)\\s*(second|minute|hour|day|week|month|year)s?$/i\n\n/** strtotime's keywords (today, tomorrow, yesterday, now) and \"+N unit\"/\"-N unit\" offsets from now, or undefined. */\nfunction relativeDate(param: string): number | undefined {\n switch (param.trim().toLowerCase()) {\n case 'now':\n return Date.now()\n case 'today':\n return startOfDay(0)\n case 'tomorrow':\n return startOfDay(1)\n case 'yesterday':\n return startOfDay(-1)\n }\n const match = RELATIVE_RE.exec(param.trim())\n if (!match) return undefined\n const amount = Number(match[1])\n const date = new Date()\n switch (match[2]!.toLowerCase()) {\n case 'second':\n date.setSeconds(date.getSeconds() + amount)\n break\n case 'minute':\n date.setMinutes(date.getMinutes() + amount)\n break\n case 'hour':\n date.setHours(date.getHours() + amount)\n break\n case 'day':\n date.setDate(date.getDate() + amount)\n break\n case 'week':\n date.setDate(date.getDate() + amount * 7)\n break\n case 'month':\n date.setMonth(date.getMonth() + amount)\n break\n case 'year':\n date.setFullYear(date.getFullYear() + amount)\n break\n }\n return date.getTime()\n}\n\n/** An attribute path such as \"starts_at\" or \"event.starts_at\". */\nconst FIELD_REFERENCE_RE = /^[A-Za-z_][\\w-]*(?:\\.[\\w-]+)*$/\n\n/** What PHP's is_numeric() and is_string() let through to Laravel's date comparisons (no booleans, arrays or NaN). */\ntype DateInput = string | number\n\nconst isDateInput = (value: unknown): value is DateInput =>\n typeof value === 'string' || (typeof value === 'number' && Number.isFinite(value))\n\n/**\n * Resolves a before/after parameter, in order: another field's date value, a relative keyword/offset, a literal\n * date. A parameter shaped like a field name whose field is missing, null or not a date gives null, Laravel's \"no\n * date\" (compareDates() decides what that means). Anything else that can't be parsed is a mistake in the rule itself,\n * so it throws a 'Server' error instead of blaming the user's input.\n */\nfunction resolveDateParam(ctx: RuleContext, rule: string, param: string, format: string | undefined): number | null {\n const fieldValue = Arr.get<unknown>(ctx.data, param)\n if (isDateInput(fieldValue)) {\n // Laravel's checkDateTimeOrder(): the other field is read with its own date_format, else this field's.\n const parsed = readDate(fieldValue, ctx.getRule?.(param, 'date_format')?.[0] ?? format)\n if (!Number.isNaN(parsed)) return parsed\n }\n const relative = relativeDate(param)\n if (relative !== undefined) return relative\n const literal = readDate(param, format)\n if (!Number.isNaN(literal)) return literal\n if (FIELD_REFERENCE_RE.test(param)) return null\n throw new InvalidRuleParameterError(rule, param, 'expected a date, today/tomorrow/yesterday/now, \"+N unit\", or a field name')\n}\n\n/**\n * A date read with the format when one is given and the value fits it, else as Laravel's getDateTime() reads it: a\n * number is seconds since the epoch (Carbon::parse()), text is read as the date rule reads it.\n */\nfunction readDate(value: DateInput, format: string | undefined): number {\n if (format !== undefined) {\n const formatted = timestampWithFormat(format, String(value))\n if (!Number.isNaN(formatted)) return formatted\n }\n return typeof value === 'number' ? value * 1000 : parseDate(value)\n}\n\ntype DateRule = 'before' | 'before_or_equal' | 'after' | 'after_or_equal' | 'date_equals'\n\nconst COMPARE: Record<DateRule, (value: number, target: number) => boolean> = {\n before: (value, target) => value < target,\n before_or_equal: (value, target) => value <= target,\n after: (value, target) => value > target,\n after_or_equal: (value, target) => value >= target,\n date_equals: (value, target) => value === target,\n}\n\n/**\n * Laravel's compareDates(): the value (text or a number) against the parameter (another field's date,\n * today/tomorrow/…, or a date). When the field has date_format, the value and a literal parameter are read with that\n * format.\n */\nfunction compareDates(ctx: RuleContext, rule: DateRule): boolean {\n const format = ctx.getRule?.(ctx.attribute, 'date_format')?.[0]\n const param = ctx.parameters[0] ?? ''\n const target = resolveDateParam(ctx, rule, param, format)\n if (!isDateInput(ctx.value)) return false\n if (target === null && format !== undefined) {\n // checkDateTimeOrder(): an other field that is missing or null passes; one that holds something else fails.\n return Arr.get<unknown>(ctx.data, param) == null\n }\n const value = readDate(ctx.value, format)\n if (Number.isNaN(value)) return false\n if (target === null) {\n // compare() with a null date: PHP compares the value's timestamp with null as booleans (true unless it is 0).\n return COMPARE[rule](Math.trunc(value / 1000) === 0 ? 0 : 1, 0)\n }\n return COMPARE[rule](value, target)\n}\n\n/**\n * Laravel's replaceBefore(): `:date` is the parameter as written when it reads as a date (a keyword, a date, or a\n * literal in the field's date_format), else the name of the field it refers to.\n */\nfunction dateReplacement(ctx: RuleContext): Record<string, string> {\n const param = ctx.parameters[0] ?? ''\n const format = ctx.getRule?.(ctx.attribute, 'date_format')?.[0]\n const isDate = relativeDate(param) !== undefined || !Number.isNaN(readDate(param, format))\n return { date: isDate && !Arr.has(ctx.data, param) ? param : displayName(ctx, param) }\n}\n\nconst comparison = (rule: DateRule): BuiltinRule => ({\n validate: (ctx) => compareDates(ctx, rule),\n messageKey: () => rule,\n replacements: dateReplacement,\n})\n\nexport const dateRules: Record<string, BuiltinRule> = {\n date: {\n validate: (ctx) => typeof ctx.value === 'string' && !Number.isNaN(parseDate(ctx.value)),\n messageKey: () => 'date',\n },\n before: comparison('before'),\n before_or_equal: comparison('before_or_equal'),\n after: comparison('after'),\n after_or_equal: comparison('after_or_equal'),\n date_equals: comparison('date_equals'),\n /**\n * Laravel's validateDateFormat(): the value (text, or a number) reads with one of the formats (PHP's characters,\n * `date_format:Y-m-d,d/m/Y`) and formats back to the same text, so `2026-02-30` and `2026-2-28` fail `Y-m-d`.\n */\n date_format: {\n validate: (ctx) => {\n for (const format of ctx.parameters) assertSupportedFormat('date_format', format)\n if (typeof ctx.value !== 'string' && !(typeof ctx.value === 'number' && Number.isFinite(ctx.value))) return false\n const text = String(ctx.value)\n return ctx.parameters.some((format) => matchesFormat(format, text))\n },\n messageKey: () => 'date_format',\n replacements: (ctx) => ({ format: ctx.parameters[0] ?? '' }),\n },\n}\n","import { InvalidRuleParameterError } from '../errors'\n\n/**\n * PHP's DateTime::createFromFormat('!' . $format) and DateTime::format($format), for the format characters a date\n * format rule can round-trip: d j D l S F M m n Y y a A g h G H i s v u O P p U, `\\` to escape a character, and any\n * other character as itself. Unparsed fields are those of 1970-01-01 00:00:00, as with PHP's leading `!`.\n */\n\nconst DAYS = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']\nconst MONTHS = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']\n\n/** PHP's format characters this module doesn't read: a format using one is a mistake in the rule. */\nconst UNSUPPORTED = new Set(['z', 'W', 't', 'L', 'o', 'X', 'x', 'B', 'e', 'I', 'T', 'Z', 'c', 'r', 'N', 'w', '#', '?', '*', '+'])\n\ninterface Fields {\n year: number\n month: number\n day: number\n hour: number\n minute: number\n second: number\n micro: number\n /** Minutes east of UTC, when the value names its offset. */\n offset: number | undefined\n /** Seconds since the epoch, when the format has U. */\n unix: number | undefined\n}\n\nconst pad = (value: number, length: number): string => String(Math.abs(value)).padStart(length, '0')\n\nfunction suffix(day: number): string {\n if (day % 100 >= 11 && day % 100 <= 13) return 'th'\n return ['th', 'st', 'nd', 'rd'][day % 10] ?? 'th'\n}\n\nfunction formatOffset(offset: number, colon: boolean): string {\n const sign = offset < 0 ? '-' : '+'\n return `${sign}${pad(Math.trunc(Math.abs(offset) / 60), 2)}${colon ? ':' : ''}${pad(Math.abs(offset) % 60, 2)}`\n}\n\n/** Reads the value against the format; undefined when it doesn't fit (PHP's createFromFormat() returning false). */\nfunction parse(format: string, value: string): Fields | undefined {\n const fields: Fields = { year: 1970, month: 1, day: 1, hour: 0, minute: 0, second: 0, micro: 0, offset: undefined, unix: undefined }\n let meridiem: 'am' | 'pm' | undefined\n let twelveHour = false\n let position = 0\n\n const digits = (min: number, max: number): number | undefined => {\n const match = new RegExp(`^\\\\d{${min},${max}}`).exec(value.slice(position))\n if (!match) return undefined\n position += match[0].length\n return Number(match[0])\n }\n const word = (names: readonly string[], short: boolean): number | undefined => {\n const match = /^[A-Za-z]+/.exec(value.slice(position))\n if (!match) return undefined\n const text = match[0].toLowerCase()\n const index = names.findIndex((name) => name.toLowerCase() === text || (short && name.slice(0, 3).toLowerCase() === text))\n if (index === -1) return undefined\n position += match[0].length\n return index\n }\n const offset = (colon: 'required' | 'none' | 'z'): number | undefined => {\n const rest = value.slice(position)\n if (colon === 'z' && rest.startsWith('Z')) {\n position += 1\n return 0\n }\n const match = (colon === 'none' ? /^([+-])(\\d{2})(\\d{2})/ : /^([+-])(\\d{2}):(\\d{2})/).exec(rest)\n if (!match) return undefined\n position += match[0].length\n return (match[1] === '-' ? -1 : 1) * (Number(match[2]) * 60 + Number(match[3]))\n }\n\n for (let i = 0; i < format.length; i++) {\n const char = format[i]!\n let read: number | undefined = 0\n switch (char) {\n case '!':\n case '|':\n continue\n case '\\\\':\n i++\n if (value[position] !== format[i]) return undefined\n position++\n continue\n case 'd':\n case 'j':\n read = digits(1, 2)\n if (read !== undefined) fields.day = read\n break\n case 'D':\n case 'l':\n read = word(DAYS, true)\n break\n case 'S':\n if (!/^(st|nd|rd|th)/i.test(value.slice(position))) return undefined\n position += 2\n break\n case 'F':\n case 'M':\n read = word(MONTHS, true)\n if (read !== undefined) fields.month = read + 1\n break\n case 'm':\n case 'n':\n read = digits(1, 2)\n if (read !== undefined) fields.month = read\n break\n case 'Y':\n read = digits(1, 4)\n if (read !== undefined) fields.year = read\n break\n case 'y':\n read = digits(2, 2)\n if (read !== undefined) fields.year = read + (read < 70 ? 2000 : 1900)\n break\n case 'a':\n case 'A': {\n const match = /^(am|pm)/i.exec(value.slice(position))\n if (!match) return undefined\n position += 2\n meridiem = match[1]!.toLowerCase() as 'am' | 'pm'\n break\n }\n case 'g':\n case 'h':\n read = digits(1, 2)\n if (read !== undefined && (read < 1 || read > 12)) return undefined\n if (read !== undefined) fields.hour = read\n twelveHour = true\n break\n case 'G':\n case 'H':\n read = digits(1, 2)\n if (read !== undefined) fields.hour = read\n break\n case 'i':\n read = digits(2, 2)\n if (read !== undefined) fields.minute = read\n break\n case 's':\n read = digits(2, 2)\n if (read !== undefined) fields.second = read\n break\n case 'v':\n read = digits(3, 3)\n if (read !== undefined) fields.micro = read * 1000\n break\n case 'u': {\n const match = /^\\d{1,6}/.exec(value.slice(position))\n read = match ? Number(match[0].padEnd(6, '0')) : undefined\n if (match) position += match[0].length\n if (read !== undefined) fields.micro = read\n break\n }\n case 'O':\n read = fields.offset = offset('none')\n break\n case 'P':\n read = fields.offset = offset('required')\n break\n case 'p':\n read = fields.offset = offset('z')\n break\n case 'U': {\n const match = /^-?\\d+/.exec(value.slice(position))\n read = match ? Number(match[0]) : undefined\n if (match) position += match[0].length\n fields.unix = read\n break\n }\n default:\n if (value[position] !== char) return undefined\n position++\n continue\n }\n if (read === undefined) return undefined\n }\n if (position !== value.length) return undefined\n if (twelveHour && meridiem !== undefined) fields.hour = (fields.hour % 12) + (meridiem === 'pm' ? 12 : 0)\n return fields\n}\n\n/**\n * The fields as a Date whose UTC fields are the value's wall clock (overflowing fields roll over, as PHP's do). The\n * setters keep years below 100 as they are (Date.UTC() would read 26 as 1926).\n */\nfunction wallClock(fields: Fields): Date {\n if (fields.unix !== undefined) return new Date(fields.unix * 1000)\n const date = new Date(0)\n date.setUTCFullYear(fields.year, fields.month - 1, fields.day)\n date.setUTCHours(fields.hour, fields.minute, fields.second, Math.floor(fields.micro / 1000))\n return date\n}\n\n/** PHP's DateTime::format() for the supported characters, reading the UTC fields of `date` in the value's offset. */\nfunction format(format: string, date: Date, micro: number, offset: number): string {\n let out = ''\n for (let i = 0; i < format.length; i++) {\n const char = format[i]!\n const day = date.getUTCDate()\n const hour = date.getUTCHours()\n switch (char) {\n case '!':\n case '|':\n break\n case '\\\\':\n i++\n out += format[i] ?? ''\n break\n case 'd': out += pad(day, 2); break\n case 'j': out += String(day); break\n case 'D': out += DAYS[date.getUTCDay()]!.slice(0, 3); break\n case 'l': out += DAYS[date.getUTCDay()]!; break\n case 'S': out += suffix(day); break\n case 'F': out += MONTHS[date.getUTCMonth()]!; break\n case 'M': out += MONTHS[date.getUTCMonth()]!.slice(0, 3); break\n case 'm': out += pad(date.getUTCMonth() + 1, 2); break\n case 'n': out += String(date.getUTCMonth() + 1); break\n case 'Y': out += pad(date.getUTCFullYear(), 4); break\n case 'y': out += pad(date.getUTCFullYear() % 100, 2); break\n case 'a': out += hour < 12 ? 'am' : 'pm'; break\n case 'A': out += hour < 12 ? 'AM' : 'PM'; break\n case 'g': out += String(hour % 12 || 12); break\n case 'h': out += pad(hour % 12 || 12, 2); break\n case 'G': out += String(hour); break\n case 'H': out += pad(hour, 2); break\n case 'i': out += pad(date.getUTCMinutes(), 2); break\n case 's': out += pad(date.getUTCSeconds(), 2); break\n case 'v': out += pad(Math.floor(micro / 1000), 3); break\n case 'u': out += pad(micro, 6); break\n case 'O': out += formatOffset(offset, false); break\n case 'P': out += formatOffset(offset, true); break\n case 'p': out += offset === 0 ? 'Z' : formatOffset(offset, true); break\n case 'U': out += String(Math.floor(date.getTime() / 1000)); break\n default: out += char\n }\n }\n return out\n}\n\n/** Throws InvalidRuleParameterError for a format character this module can't read (a developer error, a 500). */\nexport function assertSupportedFormat(rule: string, dateFormat: string): void {\n for (let i = 0; i < dateFormat.length; i++) {\n if (dateFormat[i] === '\\\\') i++\n else if (UNSUPPORTED.has(dateFormat[i]!)) {\n throw new InvalidRuleParameterError(rule, dateFormat, `the format character \"${dateFormat[i]!}\" is not supported`)\n }\n }\n}\n\n/** Laravel's validateDateFormat() for one format: the value reads with it and formats back to the same text. */\nexport function matchesFormat(dateFormat: string, value: string): boolean {\n const fields = parse(dateFormat, value)\n if (!fields) return false\n const offset = fields.offset ?? 0\n return format(dateFormat, wallClock(fields), fields.micro, offset) === value\n}\n\n/**\n * The epoch milliseconds the value names when read with the format, or NaN. A value without an offset (and without U)\n * is local time, like the other date rules' bare dates.\n */\nexport function timestampWithFormat(dateFormat: string, value: string): number {\n const fields = parse(dateFormat, value)\n if (!fields) return Number.NaN\n if (fields.unix !== undefined) return fields.unix * 1000\n const utc = wallClock(fields).getTime()\n if (fields.offset !== undefined) return utc - fields.offset * 60_000\n const local = new Date(0)\n local.setFullYear(fields.year, fields.month - 1, fields.day)\n local.setHours(fields.hour, fields.minute, fields.second, Math.floor(fields.micro / 1000))\n return local.getTime()\n}\n","import { Arr } from '@orieljs/support'\nimport type { BuiltinRule } from '../parse'\nimport { isEmptyValue } from '../parse'\nimport { otherFieldMatches } from './dependent'\n\n/** Laravel's exclude rules: validate() returning false takes the field out (BuiltinRule.excludes). */\nexport const excludeRules: Record<string, BuiltinRule> = {\n exclude: { excludes: true, validate: () => false, messageKey: () => 'exclude' },\n /** Excluded when the other field holds one of the values; nothing happens while the other field is missing. */\n exclude_if: {\n excludes: true,\n validate: (ctx) => !Arr.has(ctx.data, ctx.parameters[0] ?? '') || !otherFieldMatches(ctx),\n messageKey: () => 'exclude_if',\n },\n exclude_unless: { excludes: true, validate: (ctx) => otherFieldMatches(ctx), messageKey: () => 'exclude_unless' },\n /** Excluded while the other field's key is there. */\n exclude_with: { excludes: true, validate: (ctx) => !Arr.has(ctx.data, ctx.parameters[0] ?? ''), messageKey: () => 'exclude_with' },\n /** Excluded while any field named is missing or empty. */\n exclude_without: {\n excludes: true,\n validate: (ctx) => !ctx.parameters.some((field) => isEmptyValue(Arr.get(ctx.data, field))),\n messageKey: () => 'exclude_without',\n },\n}\n","import { FileType } from '@orieljs/support'\nimport { InvalidRuleParameterError } from '../errors'\nimport { imageDimensions, type Dimensions } from '../files/dimensions'\nimport type { BuiltinRule, RuleContext } from '../parse'\nimport { isUploadedFileLike } from '../parse'\n\nconst { BINARY_AND_MARKUP_TYPES, detectFileType, EMPTY, RASTER_IMAGES, SVG, TEXT } = FileType\ntype DetectedType = FileType.DetectedType\n\ninterface Upload {\n clientName: string\n arrayBuffer(): Promise<ArrayBuffer>\n}\n\n/** What an upload's bytes show: its type and, for a raster image, its pixel size. */\ninterface Inspection {\n type: DetectedType\n dimensions: Dimensions | undefined\n}\n\nconst inspections = new WeakMap<object, Promise<Inspection>>()\n\n/** Reads an upload's bytes once per file object, however many file rules look at it. */\nfunction inspect(file: Upload): Promise<Inspection> {\n let inspection = inspections.get(file)\n if (!inspection) {\n inspection = file.arrayBuffer().then((buffer) => {\n const bytes = new Uint8Array(buffer)\n const type = detectFileType(bytes)\n return { type, dimensions: RASTER_IMAGES.has(type.mime) ? imageDimensions(bytes, type.mime) : undefined }\n })\n inspections.set(file, inspection)\n }\n return inspection\n}\n\n/** The extension of the file name the client sent, lower-cased ('' when it has none). */\nfunction clientExtension(file: Upload): string {\n const name = file.clientName.slice(Math.max(file.clientName.lastIndexOf('/'), file.clientName.lastIndexOf('\\\\')) + 1)\n const dot = name.lastIndexOf('.')\n return dot === -1 ? '' : name.slice(dot + 1).trim().toLowerCase()\n}\n\nconst PHP_EXTENSIONS: ReadonlySet<string> = new Set(['php', 'php3', 'php4', 'php5', 'php7', 'php8', 'phtml', 'phar'])\n\n/** Laravel's shouldBlockPhpUpload(): a file named like a PHP script fails the file rules unless the list names php. */\nconst blocksPhp = (file: Upload, allowed: readonly string[]): boolean => !allowed.includes('php') && PHP_EXTENSIONS.has(clientExtension(file))\n\n/** Text formats whose bytes look like any plain text: the client's extension tells them apart, for text bytes only. */\nconst TEXT_FORMATS: ReadonlySet<string> = new Set(['txt', 'text', 'csv', 'tsv', 'json', 'md'])\n\n/** The extensions of the formats recognised by their bytes: a file name alone never earns one. */\nconst RECOGNISED_EXTENSIONS: ReadonlySet<string> = new Set(BINARY_AND_MARKUP_TYPES.flatMap(({ extensions }) => extensions))\n\nconst lower = (values: readonly string[]): string[] => values.map((value) => value.trim().toLowerCase())\n\n/**\n * mimes: the detected type must be one the list names (jpg and jpeg are one, as in Laravel).\n * - A format recognised by its bytes (images, SVG, PDF, HTML, XML) passes only by its own extensions.\n * - Plain text passes `txt`, or the client's extension when that names no recognised format (`csv`, `json`, `yaml`, …).\n * - Bytes no format matches (docx, zip, mp4, …) pass by the client's extension, unless that extension names a\n * recognised format or a text format, which the bytes would have shown.\n * - An empty file fails.\n */\nfunction meetsMimes(type: DetectedType, extension: string, allowed: ReadonlySet<string>): boolean {\n if (type === EMPTY) return false\n if (type === TEXT && allowed.has('txt')) return true\n if (type !== TEXT && type.extensions.length > 0) return type.extensions.some((name) => allowed.has(name))\n if (!allowed.has(extension) || RECOGNISED_EXTENSIONS.has(extension)) return false\n return type === TEXT || !TEXT_FORMATS.has(extension)\n}\n\nfunction allowedExtensions(ctx: RuleContext): Set<string> {\n const allowed = new Set(lower(ctx.parameters))\n if (allowed.has('jpg') || allowed.has('jpeg')) allowed.add('jpg').add('jpeg')\n return allowed\n}\n\nconst listed = (ctx: RuleContext): Record<string, string> => ({ values: ctx.parameters.join(', ') })\n\nconst DIMENSION_KEYS = ['width', 'height', 'min_width', 'min_height', 'max_width', 'max_height', 'ratio'] as const\ntype DimensionKey = (typeof DIMENSION_KEYS)[number]\ntype DimensionConstraints = Partial<Record<DimensionKey, number>>\n\n/** 'min_width=800' → ['min_width', '800']. */\nfunction namedParameter(parameter: string): [string, string] {\n const at = parameter.indexOf('=')\n return at === -1 ? [parameter, ''] : [parameter.slice(0, at), parameter.slice(at + 1)]\n}\n\n/** '3/2' or '1.5' (Laravel reads a ratio as a number, optionally over a whole number). */\nfunction parseRatio(value: string): number | undefined {\n const match = /^(\\d+(?:\\.\\d+)?|\\.\\d+)(?:\\/(\\d+))?$/.exec(value.trim())\n if (!match) return undefined\n const ratio = Number(match[1]) / Number(match[2] ?? 1)\n return Number.isFinite(ratio) && ratio > 0 ? ratio : undefined\n}\n\n/** dimensions' parameters as numbers. A name Oriel doesn't know or a value it can't read is a developer error. */\nfunction dimensionConstraints(parameters: readonly string[]): DimensionConstraints {\n if (parameters.length === 0) throw new InvalidRuleParameterError('dimensions', '', `expected one or more of ${DIMENSION_KEYS.join(', ')}`)\n const constraints: DimensionConstraints = {}\n for (const parameter of parameters) {\n const [key, value] = namedParameter(parameter)\n if (!(DIMENSION_KEYS as readonly string[]).includes(key)) {\n throw new InvalidRuleParameterError('dimensions', parameter, `expected one of ${DIMENSION_KEYS.join(', ')}`)\n }\n const number = key === 'ratio' ? parseRatio(value) : /^\\d+$/.test(value) ? Number(value) : undefined\n if (number === undefined) {\n throw new InvalidRuleParameterError('dimensions', parameter, key === 'ratio' ? 'expected a ratio such as 3/2 or 1.5' : 'expected a whole number of pixels')\n }\n constraints[key as DimensionKey] = number\n }\n return constraints\n}\n\n/** Laravel's failsBasicDimensionChecks() and failsRatioCheck(), inverted. */\nfunction meetsDimensions(constraints: DimensionConstraints, { width, height }: Dimensions): boolean {\n const { width: exactWidth, height: exactHeight, min_width, max_width, min_height, max_height, ratio } = constraints\n if (exactWidth !== undefined && width !== exactWidth) return false\n if (exactHeight !== undefined && height !== exactHeight) return false\n if (min_width !== undefined && width < min_width) return false\n if (max_width !== undefined && width > max_width) return false\n if (min_height !== undefined && height < min_height) return false\n if (max_height !== undefined && height > max_height) return false\n // The tolerance is Laravel's: about one pixel at the image's size.\n return ratio === undefined || Math.abs(ratio - width / height) <= 1 / (Math.max((width + height) / 2, height) + 1)\n}\n\nexport const fileRules: Record<string, BuiltinRule> = {\n file: { validate: (ctx) => isUploadedFileLike(ctx.value), messageKey: () => 'file' },\n\n /** A JPEG, PNG, GIF, WebP, AVIF or BMP by its bytes; SVG only as `image:allow_svg` (Laravel 12). */\n image: {\n validate: async (ctx) => {\n if (!isUploadedFileLike(ctx.value) || blocksPhp(ctx.value, [])) return false\n const { type } = await inspect(ctx.value)\n return RASTER_IMAGES.has(type.mime) || (type === SVG && ctx.parameters.includes('allow_svg'))\n },\n messageKey: () => 'image',\n },\n\n mimes: {\n validate: async (ctx) => {\n if (!isUploadedFileLike(ctx.value)) return false\n const allowed = allowedExtensions(ctx)\n if (blocksPhp(ctx.value, [...allowed])) return false\n return meetsMimes((await inspect(ctx.value)).type, clientExtension(ctx.value), allowed)\n },\n messageKey: () => 'mimes',\n replacements: listed,\n },\n\n /**\n * The detected MIME type is listed, or its `type/*` wildcard is. `image/*` includes SVG (`image/svg+xml`), as in\n * Laravel: the rule for photos is `image`.\n */\n mimetypes: {\n validate: async (ctx) => {\n if (!isUploadedFileLike(ctx.value)) return false\n const allowed = lower(ctx.parameters)\n if (blocksPhp(ctx.value, allowed)) return false\n const { mime } = (await inspect(ctx.value)).type\n return allowed.includes(mime) || allowed.includes(`${mime.split('/')[0]}/*`)\n },\n messageKey: () => 'mimetypes',\n replacements: listed,\n },\n\n /**\n * The pixel size read from the image's header meets every constraint: width, height, min_width, max_width,\n * min_height, max_height, ratio. SVG and images whose header can't be read fail.\n */\n dimensions: {\n validate: async (ctx) => {\n const constraints = dimensionConstraints(ctx.parameters)\n if (!isUploadedFileLike(ctx.value)) return false\n const { dimensions } = await inspect(ctx.value)\n return dimensions !== undefined && meetsDimensions(constraints, dimensions)\n },\n messageKey: () => 'dimensions',\n replacements: (ctx) => Object.fromEntries(ctx.parameters.map(namedParameter)),\n },\n\n /** The client file name's extension is listed (Laravel 11). It checks the name only: pair it with mimes or image. */\n extensions: {\n validate: (ctx) => {\n if (!isUploadedFileLike(ctx.value)) return false\n const allowed = lower(ctx.parameters)\n return !blocksPhp(ctx.value, allowed) && allowed.includes(clientExtension(ctx.value))\n },\n messageKey: () => 'extensions',\n replacements: listed,\n },\n}\n","/** An image's size in pixels, as its header declares it (what PHP's getimagesize() reports for Laravel). */\nexport interface Dimensions {\n readonly width: number\n readonly height: number\n}\n\ntype Reader = (view: DataView) => Dimensions | undefined\n\n/** JPEG frame headers (SOF0–SOF15, without DHT, JPG and DAC), baseline, progressive or lossless. */\nconst FRAME_MARKERS: ReadonlySet<number> = new Set([0xc0, 0xc1, 0xc2, 0xc3, 0xc5, 0xc6, 0xc7, 0xc9, 0xca, 0xcb, 0xcd, 0xce, 0xcf])\n\n/** The steps (a fill byte, a marker or a segment each) a JPEG gets to reach its frame header; real ones need a few dozen. */\nconst MAX_JPEG_STEPS = 1024\n\n/** The boxes one ISO-BMFF walk reads; real images have a handful at each level. */\nconst MAX_BOXES = 1024\n\nconst fourcc = (view: DataView, offset: number): string =>\n String.fromCharCode(view.getUint8(offset), view.getUint8(offset + 1), view.getUint8(offset + 2), view.getUint8(offset + 3))\n\nconst u24le = (view: DataView, offset: number): number =>\n view.getUint8(offset) | (view.getUint8(offset + 1) << 8) | (view.getUint8(offset + 2) << 16)\n\nconst READERS: Record<string, Reader> = {\n 'image/png': (view) => (fourcc(view, 12) === 'IHDR' ? { width: view.getUint32(16), height: view.getUint32(20) } : undefined),\n 'image/gif': (view) => ({ width: view.getUint16(6, true), height: view.getUint16(8, true) }),\n 'image/bmp': (view) =>\n view.getUint32(14, true) === 12\n ? { width: view.getUint16(18, true), height: view.getUint16(20, true) }\n : { width: Math.abs(view.getInt32(18, true)), height: Math.abs(view.getInt32(22, true)) },\n 'image/jpeg': jpeg,\n 'image/webp': webp,\n 'image/avif': avif,\n}\n\n/** The size declared in the header of an image of the given detected type, or undefined when it can't be read. */\nexport function imageDimensions(bytes: Uint8Array, mime: string): Dimensions | undefined {\n const reader = READERS[mime]\n if (!reader) return undefined\n try {\n const size = reader(new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength))\n return size && size.width > 0 && size.height > 0 ? size : undefined\n } catch (error) {\n // A header cut short reads past the end of the bytes: the image has no readable size.\n if (error instanceof RangeError) return undefined\n throw error\n }\n}\n\n/** Walks the marker segments to the first frame header. */\nfunction jpeg(view: DataView): Dimensions | undefined {\n let offset = 2\n for (let step = 0; step < MAX_JPEG_STEPS && offset + 4 <= view.byteLength; step++) {\n if (view.getUint8(offset) !== 0xff) return undefined\n const marker = view.getUint8(offset + 1)\n if (marker === 0xff) offset += 1 // a fill byte\n else if (marker === 0xd8 || marker === 0x01 || (marker >= 0xd0 && marker <= 0xd7)) offset += 2 // no length\n else if (marker === 0xd9 || marker === 0xda) return undefined // the image ends, or its data starts, before any frame header\n else if (FRAME_MARKERS.has(marker)) return { height: view.getUint16(offset + 5), width: view.getUint16(offset + 7) }\n else offset += 2 + view.getUint16(offset + 2)\n }\n return undefined\n}\n\n/** VP8 (lossy), VP8L (lossless) or VP8X (extended) chunks. */\nfunction webp(view: DataView): Dimensions | undefined {\n const chunk = fourcc(view, 12)\n if (chunk === 'VP8 ') {\n if (view.getUint8(23) !== 0x9d || view.getUint8(24) !== 0x01 || view.getUint8(25) !== 0x2a) return undefined\n return { width: view.getUint16(26, true) & 0x3fff, height: view.getUint16(28, true) & 0x3fff }\n }\n if (chunk === 'VP8L') {\n if (view.getUint8(20) !== 0x2f) return undefined\n const bits = view.getUint32(21, true)\n return { width: (bits & 0x3fff) + 1, height: ((bits >>> 14) & 0x3fff) + 1 }\n }\n if (chunk === 'VP8X') return { width: u24le(view, 24) + 1, height: u24le(view, 27) + 1 }\n return undefined\n}\n\ninterface Box {\n type: string\n /** Where the box's content starts. */\n start: number\n end: number\n}\n\n/** The ISO-BMFF boxes between start and end. */\nfunction* boxes(view: DataView, start: number, end: number): Generator<Box> {\n let offset = start\n for (let count = 0; count < MAX_BOXES && offset + 8 <= end; count++) {\n let size = view.getUint32(offset)\n let header = 8\n if (size === 1) {\n size = Number(view.getBigUint64(offset + 8))\n header = 16\n } else if (size === 0) {\n size = end - offset\n }\n if (size < header || offset + size > end) return\n yield { type: fourcc(view, offset + 4), start: offset + header, end: offset + size }\n offset += size\n }\n}\n\nconst findBox = (view: DataView, start: number, end: number, type: string): Box | undefined => {\n for (const box of boxes(view, start, end)) if (box.type === type) return box\n return undefined\n}\n\n/** The largest ispe (image spatial extents) property in meta → iprp → ipco: the primary image, not a thumbnail. */\nfunction avif(view: DataView): Dimensions | undefined {\n const meta = findBox(view, 0, view.byteLength, 'meta')\n // meta is a full box: its version and flags come before its children.\n const iprp = meta && findBox(view, meta.start + 4, meta.end, 'iprp')\n const ipco = iprp && findBox(view, iprp.start, iprp.end, 'ipco')\n if (!ipco) return undefined\n let largest: Dimensions | undefined\n for (const box of boxes(view, ipco.start, ipco.end)) {\n if (box.type !== 'ispe') continue\n const size = { width: view.getUint32(box.start + 4), height: view.getUint32(box.start + 8) }\n if (!largest || size.width * size.height > largest.width * largest.height) largest = size\n }\n return largest\n}\n","import { Arr, Str } from '@orieljs/support'\nimport type { BuiltinRule, RuleContext } from '../parse'\nimport { InvalidRuleParameterError } from '../errors'\nimport { displayName } from './dependent'\n\n/** voku/portable-ascii's is_ascii(), which Laravel's ascii rule uses: printable ASCII, tab, line feed, carriage return (and 0x10, 0x13). */\nconst ASCII_RE = /^[\\x09\\x10\\x13\\x0A\\x0D\\x20-\\x7E]*$/\nconst HEX_COLOR_RE = /^#(?:(?:[0-9a-f]{3}){1,2}|(?:[0-9a-f]{4}){1,2})$/i\nconst ALPHA_RE = /^[A-Za-z]+$/\nconst ALPHA_NUM_RE = /^[A-Za-z0-9]+$/\nconst ALPHA_DASH_RE = /^[A-Za-z0-9_-]+$/\n\n/**\n * `/^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/`, checked in one pass instead of with that pattern (which backtracks quadratically on\n * an address with many dots): one `@` with text before it, no whitespace, and a dot in the domain that is neither its\n * first nor its last character.\n */\nfunction isEmail(value: string): boolean {\n const at = value.indexOf('@')\n if (at < 1 || value.includes('@', at + 1) || /\\s/.test(value)) return false\n return value.slice(at + 2, -1).includes('.')\n}\n\n/** Laravel's Str::isUuid($value, $version): any version, or the one named (1–8, `nil`/`0`, `max`). */\nfunction isUuid(value: unknown, version: string | undefined): boolean {\n if (!Str.isUuid(value)) return false\n if (version === undefined) return true\n const hex = value.replaceAll('-', '').toLowerCase()\n if (version === 'nil' || version === '0') return /^0+$/.test(hex)\n if (version === 'max') return /^f+$/.test(hex)\n // A numbered version also needs the RFC 4122 variant (the 17th digit 8, 9, a or b), as ramsey/uuid's getVersion() does.\n return !/^0+$|^f+$/.test(hex) && hex[12] === version && '89ab'.includes(hex[16]!)\n}\n\n/** Str::isUrl()'s default schemes (Laravel 12), a regex alternation as Laravel writes it. */\nconst URL_PROTOCOLS =\n 'aaa|aaas|about|acap|acct|acd|acr|adiumxtra|adt|afp|afs|aim|amss|android|appdata|apt|ark|attachment|' +\n 'aw|barion|beshare|bitcoin|bitcoincash|blob|bolo|browserext|calculator|callto|cap|cast|casts|chrome|' +\n 'chrome-extension|cid|coap|coap\\\\+tcp|coap\\\\+ws|coaps|coaps\\\\+tcp|coaps\\\\+ws|com-eventbrite-attendee|' +\n 'content|conti|crid|cvs|dab|data|dav|diaspora|dict|did|dis|dlna-playcontainer|dlna-playsingle|dns|' +\n 'dntp|dpp|drm|drop|dtn|dvb|ed2k|elsi|example|facetime|fax|feed|feedready|file|filesystem|finger|' +\n 'first-run-pen-experience|fish|fm|ftp|fuchsia-pkg|geo|gg|git|gizmoproject|go|gopher|graph|gtalk|h323|' +\n 'ham|hcap|hcp|http|https|hxxp|hxxps|hydrazone|iax|icap|icon|im|imap|info|iotdisco|ipn|ipp|ipps|irc|' +\n 'irc6|ircs|iris|iris\\\\.beep|iris\\\\.lwz|iris\\\\.xpc|iris\\\\.xpcs|isostore|itms|jabber|jar|jms|keyparc|lastfm|' +\n 'ldap|ldaps|leaptofrogans|lorawan|lvlt|magnet|mailserver|mailto|maps|market|message|mid|mms|modem|' +\n 'mongodb|moz|ms-access|ms-browser-extension|ms-calculator|ms-drive-to|ms-enrollment|ms-excel|' +\n 'ms-eyecontrolspeech|ms-gamebarservices|ms-gamingoverlay|ms-getoffice|ms-help|ms-infopath|ms-inputapp|' +\n 'ms-lockscreencomponent-config|ms-media-stream-id|ms-mixedrealitycapture|ms-mobileplans|ms-officeapp|' +\n 'ms-people|ms-project|ms-powerpoint|ms-publisher|ms-restoretabcompanion|ms-screenclip|ms-screensketch|' +\n 'ms-search|ms-search-repair|ms-secondary-screen-controller|ms-secondary-screen-setup|ms-settings|' +\n 'ms-settings-airplanemode|ms-settings-bluetooth|ms-settings-camera|ms-settings-cellular|' +\n 'ms-settings-cloudstorage|ms-settings-connectabledevices|ms-settings-displays-topology|' +\n 'ms-settings-emailandaccounts|ms-settings-language|ms-settings-location|ms-settings-lock|' +\n 'ms-settings-nfctransactions|ms-settings-notifications|ms-settings-power|ms-settings-privacy|' +\n 'ms-settings-proximity|ms-settings-screenrotation|ms-settings-wifi|ms-settings-workplace|ms-spd|' +\n 'ms-sttoverlay|ms-transit-to|ms-useractivityset|ms-virtualtouchpad|ms-visio|ms-walk-to|ms-whiteboard|' +\n 'ms-whiteboard-cmd|ms-word|msnim|msrp|msrps|mss|mtqp|mumble|mupdate|mvn|news|nfs|ni|nih|nntp|notes|' +\n 'ocf|oid|onenote|onenote-cmd|opaquelocktoken|openpgp4fpr|pack|palm|paparazzi|payto|pkcs11|platform|' +\n 'pop|pres|prospero|proxy|pwid|psyc|pttp|qb|query|redis|rediss|reload|res|resource|rmi|rsync|rtmfp|' +\n 'rtmp|rtsp|rtsps|rtspu|s3|secondlife|service|session|sftp|sgn|shttp|sieve|simpleledger|sip|sips|skype|' +\n 'smb|sms|smtp|snews|snmp|soap\\\\.beep|soap\\\\.beeps|soldat|spiffe|spotify|ssh|steam|stun|stuns|submit|svn|' +\n 'tag|teamspeak|tel|teliaeid|telnet|tftp|tg|things|thismessage|tip|tn3270|tool|ts3server|turn|turns|tv|' +\n 'udp|unreal|urn|ut2004|v-event|vemmi|ventrilo|videotex|vnc|view-source|wais|webcal|wpid|ws|wss|wtai|' +\n 'wyciwyg|xcon|xcon-userid|xfire|xmlrpc\\\\.beep|xmlrpc\\\\.beeps|xmpp|xri|ymsgr|z39\\\\.50|z39\\\\.50r|z39\\\\.50s'\n\n/** RFC 3986's IPv6address, as Str::isUrl() writes it: h16 groups, `::`, and an IPv4 address in the last 32 bits. */\nconst H16 = '[0-9a-f]{1,4}'\nconst OCTET = '(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9])'\nconst LS32 = `(?:${H16}:${H16}|(?:${OCTET}\\\\.){3}${OCTET})`\nconst IPV6 = [\n `(?:${H16}:){6}${LS32}`,\n `::(?:${H16}:){5}${LS32}`,\n `(?:${H16})?::(?:${H16}:){4}${LS32}`,\n `(?:(?:${H16}:){0,1}${H16})?::(?:${H16}:){3}${LS32}`,\n `(?:(?:${H16}:){0,2}${H16})?::(?:${H16}:){2}${LS32}`,\n `(?:(?:${H16}:){0,3}${H16})?::${H16}:${LS32}`,\n `(?:(?:${H16}:){0,4}${H16})?::${LS32}`,\n `(?:(?:${H16}:){0,5}${H16})?::${H16}`,\n `(?:(?:${H16}:){0,6}${H16})?::`,\n].join('|')\n\nconst URL_USER = '(?:[_.\\\\p{L}\\\\p{N}-]|%[0-9A-Fa-f]{2})+'\n\n/**\n * Laravel's domain name, `([\\pL\\pN\\pS\\-\\_\\.])+(\\.?([\\pL\\pN]|xn\\-\\-[\\pL\\pN-]+)+\\.?)`, written so it can't backtrack\n * exponentially (JS has no backtrack limit; PCRE stops and returns false). It is the same set of strings: a run of\n * letters, numbers, symbols, `-`, `_` and `.` (taken whole, since nothing after the host can continue it) that ends in a\n * letter or number, or in an `xn--` label, either followed by one optional dot, with at least one character before.\n */\nconst URL_DOMAIN =\n '(?=(?<domain>[\\\\p{L}\\\\p{N}\\\\p{S}\\\\-_.]+))\\\\k<domain>' +\n '(?<=[\\\\p{L}\\\\p{N}\\\\p{S}\\\\-_.](?:[\\\\p{L}\\\\p{N}]|xn--[\\\\p{L}\\\\p{N}-]+)\\\\.?)'\n\n/**\n * Str::isUrl()'s pattern (derived from Symfony's UrlValidator 5.0.7, (c) Fabien Potencier), with PCRE's `ixu` as JS's\n * `iu`: PHP's `u` also turns on Unicode `\\d`, so `\\d` is `\\p{Nd}`, and PCRE's `$` also matches before a final line feed.\n */\nfunction urlPattern(protocols: string): RegExp {\n return new RegExp(\n `^(?:${protocols})://` +\n `(?:(?:${URL_USER}:)?${URL_USER}@)?` +\n `(?:${URL_DOMAIN}|\\\\p{Nd}{1,3}\\\\.\\\\p{Nd}{1,3}\\\\.\\\\p{Nd}{1,3}\\\\.\\\\p{Nd}{1,3}|\\\\[(?:${IPV6})\\\\])` +\n '(?::[0-9]+)?' +\n \"(?:/(?:[\\\\p{L}\\\\p{N}\\\\-._~!$&'()*+,;=:@]|%[0-9A-Fa-f]{2})*)*\" +\n \"(?:\\\\?(?:[\\\\p{L}\\\\p{N}\\\\-._~!$&'\\\\[\\\\]()*+,;=:@/?]|%[0-9A-Fa-f]{2})*)?\" +\n \"(?:#(?:[\\\\p{L}\\\\p{N}\\\\-._~!$&'()*+,;=:@/?]|%[0-9A-Fa-f]{2})*)?\" +\n '\\\\n?$',\n 'iu',\n )\n}\n\nconst URL_RE = urlPattern(URL_PROTOCOLS)\nconst urlPatterns = new Map<string, RegExp>()\n\n/**\n * Laravel's url rule (Str::isUrl): one of Laravel's schemes followed by `://`, an optional `user:password@`, a host (a\n * domain name, which may hold letters of any script, an IPv4 address or a bracketed IPv6 address), an optional port,\n * then a path, query and fragment of URL characters and `%` escapes only. So `javascript:` and `mailto:` fail, and so\n * do spaces, quotes, `<`, `\\` and bad escapes. `url:http,https` names the schemes allowed instead (case-insensitive,\n * written into the pattern as Laravel does).\n */\nfunction isUrl(value: unknown, protocols: readonly string[]): boolean {\n if (typeof value !== 'string') return false\n if (protocols.length === 0) return URL_RE.test(value)\n const list = protocols.join('|')\n let pattern = urlPatterns.get(list)\n if (pattern === undefined) {\n try {\n pattern = urlPattern(list)\n } catch (error) {\n throw new InvalidRuleParameterError(\n 'url',\n protocols.join(','),\n error instanceof Error ? error.message : String(error),\n )\n }\n urlPatterns.set(list, pattern)\n }\n return pattern.test(value)\n}\n\n/** Laravel's Str::startsWith() and endsWith(): text or a number, against any non-empty parameter. */\nfunction edges(value: unknown, parameters: readonly string[], end: boolean): boolean {\n if (typeof value !== 'string' && typeof value !== 'number') return false\n const text = String(value)\n return parameters.some((needle) => needle !== '' && (end ? text.endsWith(needle) : text.startsWith(needle)))\n}\n\nconst isText = (value: unknown): boolean => typeof value === 'string' || typeof value === 'number'\n\nconst listed = (ctx: RuleContext): Record<string, string> => ({ values: ctx.parameters.join(', ') })\n\nfunction compileRegex(raw: string): RegExp {\n const match = /^\\/(.*)\\/([a-z]*)$/.exec(raw)\n try {\n return match ? new RegExp(match[1]!, match[2]) : new RegExp(raw)\n } catch (error) {\n throw new InvalidRuleParameterError('regex', raw, error instanceof Error ? error.message : String(error))\n }\n}\n\nexport const formatRules: Record<string, BuiltinRule> = {\n email: { validate: (ctx) => typeof ctx.value === 'string' && isEmail(ctx.value), messageKey: () => 'email' },\n url: { validate: (ctx) => isUrl(ctx.value, ctx.parameters), messageKey: () => 'url' },\n uuid: { validate: (ctx) => isUuid(ctx.value, ctx.parameters[0]), messageKey: () => 'uuid' },\n ulid: { validate: (ctx) => Str.isUlid(ctx.value), messageKey: () => 'ulid' },\n ascii: { validate: (ctx) => isText(ctx.value) && ASCII_RE.test(String(ctx.value)), messageKey: () => 'ascii' },\n hex_color: { validate: (ctx) => typeof ctx.value === 'string' && HEX_COLOR_RE.test(ctx.value), messageKey: () => 'hex_color' },\n /** Text that parses as JSON (a JSON body's own numbers and objects are not \"a JSON string\"). */\n json: {\n validate: (ctx) => {\n if (typeof ctx.value !== 'string') return false\n try {\n JSON.parse(ctx.value)\n return true\n } catch {\n return false\n }\n },\n messageKey: () => 'json',\n },\n starts_with: { validate: (ctx) => edges(ctx.value, ctx.parameters, false), messageKey: () => 'starts_with', replacements: listed },\n ends_with: { validate: (ctx) => edges(ctx.value, ctx.parameters, true), messageKey: () => 'ends_with', replacements: listed },\n doesnt_start_with: {\n validate: (ctx) => isText(ctx.value) && !edges(ctx.value, ctx.parameters, false),\n messageKey: () => 'doesnt_start_with',\n replacements: listed,\n },\n doesnt_end_with: {\n validate: (ctx) => isText(ctx.value) && !edges(ctx.value, ctx.parameters, true),\n messageKey: () => 'doesnt_end_with',\n replacements: listed,\n },\n alpha: { validate: (ctx) => typeof ctx.value === 'string' && ALPHA_RE.test(ctx.value), messageKey: () => 'alpha' },\n alpha_num: {\n validate: (ctx) => typeof ctx.value === 'string' && ALPHA_NUM_RE.test(ctx.value),\n messageKey: () => 'alpha_num',\n },\n alpha_dash: {\n validate: (ctx) => typeof ctx.value === 'string' && ALPHA_DASH_RE.test(ctx.value),\n messageKey: () => 'alpha_dash',\n },\n lowercase: {\n validate: (ctx) => (typeof ctx.value === 'string' || typeof ctx.value === 'number') && String(ctx.value).toLowerCase() === String(ctx.value),\n messageKey: () => 'lowercase',\n },\n uppercase: {\n validate: (ctx) => (typeof ctx.value === 'string' || typeof ctx.value === 'number') && String(ctx.value).toUpperCase() === String(ctx.value),\n messageKey: () => 'uppercase',\n },\n regex: {\n validate: (ctx) => typeof ctx.value === 'string' && compileRegex(ctx.parameters[0] ?? '').test(ctx.value),\n messageKey: () => 'regex',\n },\n /** Laravel's validateNotRegex(): text or a number that the pattern does not match. */\n not_regex: {\n validate: (ctx) => isText(ctx.value) && !compileRegex(ctx.parameters[0] ?? '').test(String(ctx.value)),\n messageKey: () => 'not_regex',\n },\n /** `confirmed` matches `<field>_confirmation`; `confirmed:repeat_password` names the other field (Laravel 12). */\n confirmed: {\n validate: (ctx: RuleContext) => ctx.value === Arr.get(ctx.data, ctx.parameters[0] || `${ctx.attribute}_confirmation`),\n messageKey: () => 'confirmed',\n },\n same: {\n validate: (ctx) => ctx.value === Arr.get(ctx.data, ctx.parameters[0] ?? ''),\n messageKey: () => 'same',\n replacements: (ctx) => ({ other: displayName(ctx, ctx.parameters[0] ?? '') }),\n },\n different: {\n validate: (ctx) => ctx.value !== Arr.get(ctx.data, ctx.parameters[0] ?? ''),\n messageKey: () => 'different',\n replacements: (ctx) => ({ other: displayName(ctx, ctx.parameters[0] ?? '') }),\n },\n digits: {\n validate: (ctx) =>\n typeof ctx.value !== 'object' && new RegExp(`^\\\\d{${ctx.parameters[0]}}$`).test(String(ctx.value)),\n messageKey: () => 'digits',\n replacements: (ctx) => ({ digits: ctx.parameters[0] ?? '' }),\n },\n}\n","import { lookup } from 'node:dns/promises'\nimport { isIP, isIPv4, isIPv6 } from 'node:net'\nimport type { BuiltinRule } from '../parse'\n\n/** PHP's FILTER_VALIDATE_MAC: six pairs joined by one `-` or `:` throughout, or three groups of four joined by `.`. */\nconst MAC_RE = /^(?:[0-9a-f]{2}([-:])(?:[0-9a-f]{2}\\1){4}[0-9a-f]{2}|[0-9a-f]{4}\\.[0-9a-f]{4}\\.[0-9a-f]{4})$/i\n\n/** The lookup active_url asks, held in an object so a test can replace it. Not exported from the package. */\nexport const resolver = { lookup }\n\n/**\n * Laravel's active_url: the URL's host has an address (an A or AAAA record). Asked of the system's resolver, so a name\n * the machine knows (localhost, /etc/hosts) counts too.\n */\nasync function hasAddress(value: unknown): Promise<boolean> {\n if (typeof value !== 'string') return false\n let host: string\n try {\n host = new URL(value).hostname\n } catch {\n return false\n }\n if (host === '') return false\n try {\n return (await resolver.lookup(host.replace(/^\\[|\\]$/g, ''), { all: true })).length > 0\n } catch {\n return false\n }\n}\n\nexport const networkRules: Record<string, BuiltinRule> = {\n ip: { validate: (ctx) => typeof ctx.value === 'string' && isIP(ctx.value) !== 0, messageKey: () => 'ip' },\n ipv4: { validate: (ctx) => typeof ctx.value === 'string' && isIPv4(ctx.value), messageKey: () => 'ipv4' },\n ipv6: { validate: (ctx) => typeof ctx.value === 'string' && isIPv6(ctx.value), messageKey: () => 'ipv6' },\n mac_address: { validate: (ctx) => typeof ctx.value === 'string' && MAC_RE.test(ctx.value), messageKey: () => 'mac_address' },\n active_url: { validate: (ctx) => hasAddress(ctx.value), messageKey: () => 'active_url' },\n}\n","import type { BuiltinRule } from '../parse'\nimport { isNumeric } from './type'\n\n/** Laravel's `preg_match('/[^0-9]/', $value)` check: a number or text made only of digits. */\nconst onlyDigits = (value: unknown): boolean => (typeof value === 'string' || typeof value === 'number') && /^\\d+$/.test(String(value))\n\n/** Laravel's ensureExponentWithinAllowedRange(): a written exponent past ±1000 isn't read. */\nconst MAX_EXPONENT = 1000\n\n/**\n * A decimal number's digits and its power of ten (`'1.25'` → 125n and -2; `'1e3'` → 1n and 3), for exact remainders;\n * undefined when its written exponent is past ±1000.\n */\nfunction decimal(text: string): { digits: bigint; exponent: number } | undefined {\n const [, sign = '', whole = '', fraction = '', power = '0'] = /^\\s*([+-]?)(\\d*)(?:\\.(\\d*))?(?:[eE]([+-]?\\d+))?\\s*$/.exec(text) ?? []\n if (Math.abs(Number(power)) > MAX_EXPONENT) return undefined\n return { digits: BigInt(`${sign}${whole}${fraction}` || '0'), exponent: Number(power) - fraction.length }\n}\n\n/** Laravel's validateMultipleOf(), in decimals as BigDecimal is (0.3 is a multiple of 0.1); an exponent past ±1000 fails. */\nfunction isMultipleOf(value: unknown, divisor: string): boolean {\n if (!isNumeric(value) || !isNumeric(divisor)) return false\n const a = decimal(String(value))\n const b = decimal(divisor)\n if (a === undefined || b === undefined) return false\n const exponent = Math.min(a.exponent, b.exponent)\n const numerator = a.digits * 10n ** BigInt(a.exponent - exponent)\n const denominator = b.digits * 10n ** BigInt(b.exponent - exponent)\n if (denominator === 0n) return false\n return numerator % denominator === 0n\n}\n\n/**\n * Laravel's validateDecimal(): a number with exactly `min` decimal places, or between `min` and `max`. Laravel's\n * `/^[+-]?\\d*\\.?(\\d*)$/`, written with the dot and its digits as one optional group: the same strings and places,\n * without the two runs of digits that make a long number with an exponent backtrack quadratically.\n */\nfunction hasDecimals(value: unknown, min: string, max: string | undefined): boolean {\n if (!isNumeric(value)) return false\n const match = /^[+-]?\\d*(?:\\.(\\d*))?$/.exec(String(value).trim())\n if (match === null) return false\n const places = match[1] ?? ''\n return max === undefined ? places.length === Number(min) : places.length >= Number(min) && places.length <= Number(max)\n}\n\nconst length = (value: unknown): number => String(value).length\n\nexport const numericRules: Record<string, BuiltinRule> = {\n decimal: {\n validate: (ctx) => hasDecimals(ctx.value, ctx.parameters[0] ?? '', ctx.parameters[1]),\n messageKey: () => 'decimal',\n replacements: (ctx) => ({ decimal: ctx.parameters[1] === undefined ? (ctx.parameters[0] ?? '') : `${ctx.parameters[0]}-${ctx.parameters[1]}` }),\n },\n digits_between: {\n validate: (ctx) => onlyDigits(ctx.value) && length(ctx.value) >= Number(ctx.parameters[0]) && length(ctx.value) <= Number(ctx.parameters[1]),\n messageKey: () => 'digits_between',\n replacements: (ctx) => ({ min: ctx.parameters[0] ?? '', max: ctx.parameters[1] ?? '' }),\n },\n max_digits: {\n validate: (ctx) => onlyDigits(ctx.value) && length(ctx.value) <= Number(ctx.parameters[0]),\n messageKey: () => 'max_digits',\n replacements: (ctx) => ({ max: ctx.parameters[0] ?? '' }),\n },\n min_digits: {\n validate: (ctx) => onlyDigits(ctx.value) && length(ctx.value) >= Number(ctx.parameters[0]),\n messageKey: () => 'min_digits',\n replacements: (ctx) => ({ min: ctx.parameters[0] ?? '' }),\n },\n multiple_of: {\n validate: (ctx) => isMultipleOf(ctx.value, ctx.parameters[0] ?? ''),\n messageKey: () => 'multiple_of',\n replacements: (ctx) => ({ value: ctx.parameters[0] ?? '' }),\n },\n}\n","import { Arr } from '@orieljs/support'\nimport type { BuiltinRule, RuleContext } from '../parse'\nimport { isEmptyValue } from '../parse'\nimport { otherAccepted, otherDeclined } from './acceptance'\nimport { displayName, displayableValue, fieldList, otherAndValue, otherAndValues, otherFieldMatches } from './dependent'\n\nfunction isFieldPresent(field: string, data: Record<string, unknown>): boolean {\n return Arr.has(data, field) && !isEmptyValue(Arr.get(data, field))\n}\n\nfunction anyPresent(fields: string[], data: Record<string, unknown>): boolean {\n return fields.some((field) => isFieldPresent(field, data))\n}\n\nfunction allPresent(fields: string[], data: Record<string, unknown>): boolean {\n return fields.every((field) => isFieldPresent(field, data))\n}\n\n/** Laravel's Arr::hasAny() and Arr::has() on several keys: whether any (or every) key is there, whatever its value. */\nconst hasAnyKey = (fields: string[], data: Record<string, unknown>): boolean => fields.some((field) => Arr.has(data, field))\nconst hasEveryKey = (fields: string[], data: Record<string, unknown>): boolean => fields.length > 0 && fields.every((field) => Arr.has(data, field))\n\n/** `:other` and `:value` for the `_unless` rules that show the first value listed (Laravel's replaceMissingUnless()). */\nconst otherAndFirstValue = (ctx: RuleContext): Record<string, string> => ({\n other: displayName(ctx, ctx.parameters[0] ?? ''),\n value: displayableValue(ctx.parameters[1]),\n})\n\nconst otherName = (ctx: RuleContext): Record<string, string> => ({ other: displayName(ctx, ctx.parameters[0] ?? '') })\n\nexport const presenceRules: Record<string, BuiltinRule> = {\n required: {\n implicit: true,\n validate: (ctx: RuleContext) => !isEmptyValue(ctx.value),\n messageKey: () => 'required',\n },\n required_if: {\n implicit: true,\n // Laravel: nothing is required while the other field is missing.\n validate: (ctx: RuleContext) => !Arr.has(ctx.data, ctx.parameters[0] ?? '') || !otherFieldMatches(ctx) || !isEmptyValue(ctx.value),\n messageKey: () => 'required_if',\n replacements: otherAndValue,\n },\n required_unless: {\n implicit: true,\n validate: (ctx: RuleContext) => otherFieldMatches(ctx) || !isEmptyValue(ctx.value),\n messageKey: () => 'required_unless',\n replacements: otherAndValues,\n },\n required_with: {\n implicit: true,\n validate: (ctx: RuleContext) => !anyPresent(ctx.parameters, ctx.data) || !isEmptyValue(ctx.value),\n messageKey: () => 'required_with',\n replacements: fieldList,\n },\n required_with_all: {\n implicit: true,\n validate: (ctx: RuleContext) => !allPresent(ctx.parameters, ctx.data) || !isEmptyValue(ctx.value),\n messageKey: () => 'required_with_all',\n replacements: fieldList,\n },\n required_without: {\n implicit: true,\n validate: (ctx: RuleContext) => ctx.parameters.every((f) => isFieldPresent(f, ctx.data)) || !isEmptyValue(ctx.value),\n messageKey: () => 'required_without',\n replacements: fieldList,\n },\n required_without_all: {\n implicit: true,\n validate: (ctx: RuleContext) => anyPresent(ctx.parameters, ctx.data) || !isEmptyValue(ctx.value),\n messageKey: () => 'required_without_all',\n replacements: fieldList,\n },\n required_if_accepted: {\n implicit: true,\n validate: (ctx) => !otherAccepted(ctx.data, ctx.parameters[0]) || !isEmptyValue(ctx.value),\n messageKey: () => 'required_if_accepted',\n replacements: otherName,\n },\n required_if_declined: {\n implicit: true,\n validate: (ctx) => !otherDeclined(ctx.data, ctx.parameters[0]) || !isEmptyValue(ctx.value),\n messageKey: () => 'required_if_declined',\n replacements: otherName,\n },\n\n /** The key is there, whatever its value (null and '' included). */\n present: { implicit: true, validate: (ctx) => Arr.has(ctx.data, ctx.attribute), messageKey: () => 'present' },\n present_if: {\n implicit: true,\n validate: (ctx) => !otherFieldMatches(ctx) || Arr.has(ctx.data, ctx.attribute),\n messageKey: () => 'present_if',\n replacements: otherAndValue,\n },\n present_unless: {\n implicit: true,\n validate: (ctx) => otherFieldMatches(ctx) || Arr.has(ctx.data, ctx.attribute),\n messageKey: () => 'present_unless',\n replacements: otherAndFirstValue,\n },\n present_with: {\n implicit: true,\n validate: (ctx) => !hasAnyKey(ctx.parameters, ctx.data) || Arr.has(ctx.data, ctx.attribute),\n messageKey: () => 'present_with',\n replacements: fieldList,\n },\n present_with_all: {\n implicit: true,\n validate: (ctx) => !hasEveryKey(ctx.parameters, ctx.data) || Arr.has(ctx.data, ctx.attribute),\n messageKey: () => 'present_with_all',\n replacements: fieldList,\n },\n\n /** A key that is there must not be empty; a missing key passes. */\n filled: { implicit: true, validate: (ctx) => !Arr.has(ctx.data, ctx.attribute) || !isEmptyValue(ctx.value), messageKey: () => 'filled' },\n\n /** The key is not there at all (null counts as there). */\n missing: { implicit: true, validate: (ctx) => !Arr.has(ctx.data, ctx.attribute), messageKey: () => 'missing' },\n missing_if: {\n implicit: true,\n validate: (ctx) => !otherFieldMatches(ctx) || !Arr.has(ctx.data, ctx.attribute),\n messageKey: () => 'missing_if',\n replacements: otherAndValue,\n },\n missing_unless: {\n implicit: true,\n validate: (ctx) => otherFieldMatches(ctx) || !Arr.has(ctx.data, ctx.attribute),\n messageKey: () => 'missing_unless',\n replacements: otherAndFirstValue,\n },\n missing_with: {\n implicit: true,\n validate: (ctx) => !hasAnyKey(ctx.parameters, ctx.data) || !Arr.has(ctx.data, ctx.attribute),\n messageKey: () => 'missing_with',\n replacements: fieldList,\n },\n missing_with_all: {\n implicit: true,\n validate: (ctx) => !hasEveryKey(ctx.parameters, ctx.data) || !Arr.has(ctx.data, ctx.attribute),\n messageKey: () => 'missing_with_all',\n replacements: fieldList,\n },\n}\n","import { Arr } from '@orieljs/support'\nimport type { BuiltinRule } from '../parse'\nimport { isEmptyValue } from '../parse'\nimport { otherAccepted, otherDeclined } from './acceptance'\nimport { displayName, fieldList, otherAndValue, otherAndValues, otherFieldMatches } from './dependent'\n\n/**\n * The prohibited family. Not implicit, as in Laravel: a missing or blank field never runs them, and so passes; an\n * explicit null runs them and passes too (null is empty).\n */\nexport const prohibitedRules: Record<string, BuiltinRule> = {\n prohibited: { validate: (ctx) => isEmptyValue(ctx.value), messageKey: () => 'prohibited' },\n prohibited_if: {\n validate: (ctx) => !otherFieldMatches(ctx) || isEmptyValue(ctx.value),\n messageKey: () => 'prohibited_if',\n replacements: otherAndValue,\n },\n prohibited_unless: {\n validate: (ctx) => otherFieldMatches(ctx) || isEmptyValue(ctx.value),\n messageKey: () => 'prohibited_unless',\n replacements: otherAndValues,\n },\n prohibited_if_accepted: {\n validate: (ctx) => !otherAccepted(ctx.data, ctx.parameters[0]) || isEmptyValue(ctx.value),\n messageKey: () => 'prohibited_if_accepted',\n replacements: (ctx) => ({ other: displayName(ctx, ctx.parameters[0] ?? '') }),\n },\n prohibited_if_declined: {\n validate: (ctx) => !otherDeclined(ctx.data, ctx.parameters[0]) || isEmptyValue(ctx.value),\n messageKey: () => 'prohibited_if_declined',\n replacements: (ctx) => ({ other: displayName(ctx, ctx.parameters[0] ?? '') }),\n },\n /** While this field has a value, every field named must be missing or empty. */\n prohibits: {\n validate: (ctx) => isEmptyValue(ctx.value) || ctx.parameters.every((field) => isEmptyValue(Arr.get(ctx.data, field))),\n messageKey: () => 'prohibits',\n replacements: (ctx) => ({ other: fieldList(ctx).values! }),\n },\n}\n","import { Arr } from '@orieljs/support'\nimport type { BuiltinRule, RuleContext } from '../parse'\nimport { isUploadedFileLike } from '../parse'\nimport { displayName } from './dependent'\nimport { isNumeric } from './type'\n\ntype SizeType = 'numeric' | 'array' | 'file' | 'string'\n\nfunction hasAny(ctx: RuleContext, names: string[]): boolean {\n return names.some((name) => ctx.ruleNames.includes(name))\n}\n\n/** Laravel's numericRules: the rules that make the size rules measure a number. */\nconst NUMERIC_RULES = ['numeric', 'integer', 'decimal']\n\n/** A JSON object is a PHP associative array, so it's counted like one. */\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n if (typeof value !== 'object' || value === null) return false\n const proto: unknown = Object.getPrototypeOf(value)\n return proto === Object.prototype || proto === null\n}\n\n/**\n * What a size rule measures and which message family it reports, decided in one place so the check and the\n * message always agree (Laravel's getSize + getAttributeType):\n * - numeric/integer/decimal rule: the number itself (a non-numeric value falls back to its string length, which the\n * numeric rule rejects anyway);\n * - an array (or plain object): its item count;\n * - an uploaded file: its size in fractional kilobytes;\n * - a file/image rule on something that isn't a file: NaN, so every size comparison fails;\n * - anything else: the length of its string form (a number without a numeric rule counts its digits).\n */\nfunction measure(ctx: RuleContext, value: unknown = ctx.value, numeric = hasAny(ctx, NUMERIC_RULES)): { type: SizeType; size: number } {\n if (numeric) {\n return { type: 'numeric', size: isNumeric(value) ? Number(value) : stringLength(value) }\n }\n if (Array.isArray(value)) return { type: 'array', size: value.length }\n if (isUploadedFileLike(value)) return { type: 'file', size: value.size / 1024 }\n if (hasAny(ctx, ['file', 'image'])) return { type: 'file', size: Number.NaN }\n if (isPlainObject(value)) return { type: 'array', size: Object.keys(value).length }\n if (hasAny(ctx, ['array'])) return { type: 'array', size: stringLength(value) }\n return { type: 'string', size: stringLength(value) }\n}\n\nfunction stringLength(value: unknown): number {\n if (value === null || value === undefined) return 0\n return [...String(value)].length\n}\n\nfunction sizeOf(ctx: RuleContext): number {\n return measure(ctx).size\n}\n\ntype Comparison = 'gt' | 'gte' | 'lt' | 'lte'\n\nconst COMPARE: Record<Comparison, (a: number, b: number) => boolean> = {\n gt: (a, b) => a > b,\n gte: (a, b) => a >= b,\n lt: (a, b) => a < b,\n lte: (a, b) => a <= b,\n}\n\n/** PHP's gettype(), as Laravel's isSameType() compares it (a list and an object are both arrays). */\nfunction kind(value: unknown): string {\n if (value === null || value === undefined) return 'null'\n if (Array.isArray(value) || isPlainObject(value)) return 'array'\n if (typeof value === 'number') return Number.isInteger(value) ? 'integer' : 'double'\n return typeof value\n}\n\n/**\n * Laravel's validateGt() and the others: a numeric value is a number (shouldBeNumeric()); against a number literal\n * only a numeric value compares; against another field, two numbers by value, else two values of one kind by size\n * (text length, item count, kilobytes).\n */\nfunction compareSizes(ctx: RuleContext, rule: Comparison): boolean {\n const parameter = ctx.parameters[0] ?? ''\n const other = Arr.get<unknown>(ctx.data, parameter)\n const numeric = hasAny(ctx, NUMERIC_RULES) || isNumeric(ctx.value)\n if ((other === null || other === undefined) && isNumeric(ctx.value) && isNumeric(parameter)) {\n return COMPARE[rule](Number(String(ctx.value).trim()), Number(parameter.trim()))\n }\n if (isNumeric(parameter)) return false\n if (numeric && isNumeric(ctx.value) && isNumeric(other)) return COMPARE[rule](Number(String(ctx.value).trim()), Number(String(other).trim()))\n if (kind(ctx.value) !== kind(other)) return false\n return COMPARE[rule](measure(ctx, ctx.value, numeric).size, measure(ctx, other, numeric).size)\n}\n\n/** `:value`: the other field's size, or the parameter itself (a number, or a field that isn't there). */\nfunction comparedValue(ctx: RuleContext): Record<string, string> {\n const parameter = ctx.parameters[0] ?? ''\n const other = Arr.get<unknown>(ctx.data, parameter)\n if (other === null || other === undefined) return { value: displayName(ctx, parameter) }\n return { value: String(measure(ctx, other, hasAny(ctx, NUMERIC_RULES) || isNumeric(ctx.value)).size) }\n}\n\nconst comparison = (rule: Comparison): BuiltinRule => ({\n validate: (ctx) => compareSizes(ctx, rule),\n messageKey: (ctx) => `${rule}.${measure(ctx, ctx.value, hasAny(ctx, NUMERIC_RULES) || isNumeric(ctx.value)).type}`,\n replacements: comparedValue,\n})\n\nfunction sizeType(ctx: RuleContext): SizeType {\n return measure(ctx).type\n}\n\nexport const sizeRules: Record<string, BuiltinRule> = {\n max: {\n validate: (ctx) => sizeOf(ctx) <= Number(ctx.parameters[0]),\n messageKey: (ctx) => `max.${sizeType(ctx)}`,\n replacements: (ctx) => ({ max: ctx.parameters[0] ?? '' }),\n },\n min: {\n validate: (ctx) => sizeOf(ctx) >= Number(ctx.parameters[0]),\n messageKey: (ctx) => `min.${sizeType(ctx)}`,\n replacements: (ctx) => ({ min: ctx.parameters[0] ?? '' }),\n },\n between: {\n validate: (ctx) => {\n const size = sizeOf(ctx)\n return size >= Number(ctx.parameters[0]) && size <= Number(ctx.parameters[1])\n },\n messageKey: (ctx) => `between.${sizeType(ctx)}`,\n replacements: (ctx) => ({ min: ctx.parameters[0] ?? '', max: ctx.parameters[1] ?? '' }),\n },\n size: {\n validate: (ctx) => sizeOf(ctx) === Number(ctx.parameters[0]),\n messageKey: (ctx) => `size.${sizeType(ctx)}`,\n replacements: (ctx) => ({ size: ctx.parameters[0] ?? '' }),\n },\n gt: comparison('gt'),\n gte: comparison('gte'),\n lt: comparison('lt'),\n lte: comparison('lte'),\n in: { validate: (ctx) => isListed(ctx.value, ctx.parameters, ctx.ruleNames), messageKey: () => 'in' },\n not_in: { validate: (ctx) => !isListed(ctx.value, ctx.parameters, ctx.ruleNames), messageKey: () => 'not_in' },\n}\n\n/**\n * Laravel's validateIn(): the value's text is one of `list`. An array or an object never is, unless the field also has\n * `array`: then every item must be a listed scalar. `not_in` is its opposite, arrays included.\n */\nexport function isListed(value: unknown, list: readonly string[], ruleNames: readonly string[]): boolean {\n if (Array.isArray(value) && ruleNames.includes('array')) {\n return value.every((item) => (typeof item !== 'object' || item === null) && list.includes(String(item)))\n }\n return (typeof value !== 'object' || value === null) && list.includes(String(value))\n}\n","import { InvalidRuleParameterError } from '../errors'\nimport type { BuiltinRule } from '../parse'\n\n/** PHP's DateTimeZone region groups (timezone:Europe, …); timezone_identifiers_list(ALL) is these regions and UTC. */\nconst REGIONS = ['Africa', 'America', 'Antarctica', 'Arctic', 'Asia', 'Atlantic', 'Australia', 'Europe', 'Indian', 'Pacific']\n\n/** Each segment of a zone name in its own case: `America/Argentina/Buenos_Aires`, `America/Port-au-Prince`. */\nconst ZONE_RE = /^[A-Z][A-Za-z_-]*(?:\\/[A-Z][A-Za-z0-9_+-]*)+$/\n\n/**\n * The old names ICU (and so Node's Intl and Intl.Locale's zone lists) still gives these zones, with their IANA names\n * (PHP's). Node reads `Asia/Kolkata` as `Asia/Calcutta`; Bun keeps whichever name it was given.\n */\nconst ICU_NAMES: Record<string, string> = {\n 'Africa/Asmera': 'Africa/Asmara',\n 'America/Buenos_Aires': 'America/Argentina/Buenos_Aires',\n 'America/Catamarca': 'America/Argentina/Catamarca',\n 'America/Cordoba': 'America/Argentina/Cordoba',\n 'America/Jujuy': 'America/Argentina/Jujuy',\n 'America/Mendoza': 'America/Argentina/Mendoza',\n 'America/Coral_Harbour': 'America/Atikokan',\n 'America/Indianapolis': 'America/Indiana/Indianapolis',\n 'America/Louisville': 'America/Kentucky/Louisville',\n 'America/Godthab': 'America/Nuuk',\n 'Asia/Saigon': 'Asia/Ho_Chi_Minh',\n 'Asia/Katmandu': 'Asia/Kathmandu',\n 'Asia/Calcutta': 'Asia/Kolkata',\n 'Asia/Rangoon': 'Asia/Yangon',\n 'Atlantic/Faeroe': 'Atlantic/Faroe',\n 'Europe/Kiev': 'Europe/Kyiv',\n 'Pacific/Truk': 'Pacific/Chuuk',\n 'Pacific/Enderbury': 'Pacific/Kanton',\n 'Pacific/Ponape': 'Pacific/Pohnpei',\n}\n\n/** The name the runtime reads the zone as (in its own case), or undefined when the runtime doesn't know the zone. */\nfunction resolve(zone: string): string | undefined {\n try {\n return new Intl.DateTimeFormat('en-US', { timeZone: zone }).resolvedOptions().timeZone\n } catch {\n return undefined\n }\n}\n\n/** The zone's IANA name as the runtime reads it, or undefined when the runtime doesn't know the zone. */\nfunction canonical(zone: string): string | undefined {\n const name = resolve(zone)\n return name === undefined ? undefined : (ICU_NAMES[name] ?? name)\n}\n\n/**\n * Whether a zone the runtime knows is written in its own case, as PHP's strict in_array() needs (`Europe/London`, not\n * `Europe/LONDON`). Intl reads a name in any case and answers it in its own: the name itself (Bun always, Node for a\n * zone), or the old name in ICU_NAMES (Node's `Asia/Calcutta` for `Asia/Kolkata`). Node answers some links with the\n * zone they point to (`Europe/Belfast` → `Europe/London`), which says nothing of the link's case: those are checked by\n * their shape only, as before.\n */\nfunction isInOwnCase(value: string, name: string): boolean {\n const lower = value.toLowerCase()\n for (const spelling of [name, ICU_NAMES[name]]) {\n if (spelling !== undefined && spelling.toLowerCase() === lower) return spelling === value\n }\n return true\n}\n\n/** The zones of a country, from the runtime's ICU data (Intl.Locale's getTimeZones(), timeZones before Node 23). */\nfunction countryZones(country: string): string[] {\n const locale = new Intl.Locale(`und-${country.toUpperCase()}`) as Intl.Locale & { getTimeZones?: () => string[]; timeZones?: string[] }\n return locale.getTimeZones?.() ?? locale.timeZones ?? []\n}\n\nconst inRegion = (zone: string, region?: string): boolean =>\n zone === 'UTC' ? region === undefined || region === 'UTC' : ZONE_RE.test(zone) && (region === undefined ? REGIONS : [region]).includes(zone.split('/')[0]!)\n\n/**\n * Laravel's timezone rule, against the runtime's IANA data instead of PHP's lists (Node and Bun ship different ICU\n * builds, and PHP's lists can't be read here):\n * - every group takes a name only in its own case (see isInOwnCase());\n * - `timezone` (`all`): a zone in one of PHP's regions, or UTC; Oriel can't tell a region's old link names\n * (Asia/Calcutta) from its zones, so those pass too;\n * - `timezone:<region>`: a zone in that region (`timezone:Europe`), `timezone:utc` only UTC;\n * - `timezone:all_with_bc`: any name the runtime knows, links included (US/Eastern, Etc/GMT+5);\n * - `timezone:per_country,US`: a zone of that country.\n */\nfunction isTimezone(value: unknown, group = 'all', country?: string): boolean {\n if (typeof value !== 'string') return false\n const resolved = resolve(value)\n if (resolved === undefined || !isInOwnCase(value, resolved)) return false\n const name = group.toLowerCase()\n if (name === 'all') return inRegion(value)\n if (name === 'all_with_bc') return /^[A-Z]/.test(value)\n if (name === 'per_country') {\n const zone = canonical(value)\n return inRegion(value) && countryZones(country ?? '').some((candidate) => canonical(candidate) === zone)\n }\n const region = name === 'utc' ? 'UTC' : REGIONS.find((candidate) => candidate.toLowerCase() === name)\n if (region === undefined) throw new InvalidRuleParameterError('timezone', group, 'expected all, all_with_bc, per_country, utc or a region such as Europe')\n return inRegion(value, region)\n}\n\nexport const timezoneRules: Record<string, BuiltinRule> = {\n timezone: { validate: (ctx) => isTimezone(ctx.value, ctx.parameters[0], ctx.parameters[1]), messageKey: () => 'timezone' },\n}\n","import type { BuiltinRule } from './parse'\nimport { acceptanceRules } from './rules/acceptance'\nimport { arrayRules } from './rules/array'\nimport { authRules } from './rules/auth'\nimport { databaseRules } from './rules/database'\nimport { dateRules } from './rules/date'\nimport { excludeRules } from './rules/exclude'\nimport { fileRules } from './rules/file'\nimport { formatRules } from './rules/format'\nimport { networkRules } from './rules/network'\nimport { numericRules } from './rules/numeric'\nimport { presenceRules } from './rules/presence'\nimport { prohibitedRules } from './rules/prohibited'\nimport { sizeRules } from './rules/size'\nimport { timezoneRules } from './rules/timezone'\nimport { typeRules } from './rules/type'\n\n/** Every built-in rule, merged. Later tasks (database rules) add their own spread here. */\nexport const builtinRules: Record<string, BuiltinRule> = {\n ...presenceRules,\n ...acceptanceRules,\n ...prohibitedRules,\n ...excludeRules,\n ...typeRules,\n ...arrayRules,\n ...formatRules,\n ...dateRules,\n ...networkRules,\n ...timezoneRules,\n ...sizeRules,\n ...numericRules,\n ...fileRules,\n ...databaseRules,\n ...authRules,\n}\n","import type { TypedValidationRule } from '@orieljs/contracts'\nimport { applyReplacements, DEFAULT_MESSAGES } from '../messages'\n\nlet defaultRule: PasswordRule | (() => PasswordRule) | undefined\n\n/**\n * Laravel's mixedCase pattern, `/(\\p{Ll}+.*\\p{Lu})|(\\p{Lu}+.*\\p{Ll})/u`, matches when one line (`.` stops at a line\n * break) holds a lower and an upper case letter. Checked line by line, since that pattern backtracks cubically on a\n * long run of letters in one case.\n */\nfunction hasMixedCase(value: string): boolean {\n return value.split(/[\\n\\r\\u2028\\u2029]/).some((line) => /\\p{Ll}/u.test(line) && /\\p{Lu}/u.test(line))\n}\n\n/**\n * Laravel's Illuminate\\Validation\\Rules\\Password: a string of at least `min` characters (8 by default), plus the\n * checks you add: letters(), mixedCase(), numbers(), symbols(), max(). Every failing check adds its own message.\n * Rule.password() returns the application default (PasswordRule.defaults()). (Laravel's uncompromised() is not\n * ported: it calls an outside service.)\n */\nexport class PasswordRule implements TypedValidationRule<{ value: string }> {\n /** A passing value is a string (for the validated data's type); never set at run time. */\n declare readonly __typing?: { value: string }\n #min: number\n #max: number | undefined\n #letters = false\n #mixedCase = false\n #numbers = false\n #symbols = false\n\n constructor(min = 8) {\n this.#min = Math.max(1, min)\n }\n\n /** A password rule of at least `size` characters: PasswordRule.min(12).mixedCase(). */\n static min(size: number): PasswordRule {\n return new PasswordRule(size)\n }\n\n /**\n * With an argument, sets the default (Laravel's Password::defaults(fn () => ...), in a provider's boot());\n * `null` resets it. Without one, returns a copy of the default: PasswordRule.min(8) unless set.\n */\n static defaults(): PasswordRule\n static defaults(rule: PasswordRule | (() => PasswordRule) | null): void\n static defaults(rule?: PasswordRule | (() => PasswordRule) | null): PasswordRule | void {\n if (rule !== undefined) {\n defaultRule = rule ?? undefined\n return\n }\n const resolved = typeof defaultRule === 'function' ? defaultRule() : defaultRule\n return resolved === undefined ? new PasswordRule(8) : resolved.#copy()\n }\n\n min(size: number): this {\n this.#min = Math.max(1, size)\n return this\n }\n\n max(size: number): this {\n this.#max = size\n return this\n }\n\n /** At least one letter. */\n letters(): this {\n this.#letters = true\n return this\n }\n\n /** At least one uppercase and one lowercase letter. */\n mixedCase(): this {\n this.#mixedCase = true\n return this\n }\n\n /** At least one number. */\n numbers(): this {\n this.#numbers = true\n return this\n }\n\n /** At least one symbol (punctuation, a symbol or a space). */\n symbols(): this {\n this.#symbols = true\n return this\n }\n\n validate(_attribute: string, value: unknown, fail: (message: string) => void): void {\n // :attribute stays for the Validator to fill, with the field's custom attribute name when it has one.\n const say = (key: string, replacements: Record<string, string> = {}) => fail(applyReplacements(DEFAULT_MESSAGES[key]!, replacements))\n if (typeof value !== 'string') return say('string')\n const length = [...value].length\n if (length < this.#min) say('min.string', { min: String(this.#min) })\n if (this.#max !== undefined && length > this.#max) say('max.string', { max: String(this.#max) })\n // Laravel's order and patterns (mixedCase's as hasMixedCase() checks it).\n if (this.#mixedCase && !hasMixedCase(value)) say('password.mixed')\n if (this.#letters && !/\\p{L}/u.test(value)) say('password.letters')\n if (this.#symbols && !/\\p{Z}|\\p{S}|\\p{P}/u.test(value)) say('password.symbols')\n if (this.#numbers && !/\\p{N}/u.test(value)) say('password.numbers')\n }\n\n #copy(): PasswordRule {\n const copy = new PasswordRule(this.#min)\n copy.#max = this.#max\n copy.#letters = this.#letters\n copy.#mixedCase = this.#mixedCase\n copy.#numbers = this.#numbers\n copy.#symbols = this.#symbols\n return copy\n }\n}\n","import type { InValue, RuleTyping, TypedValidationRule, UploadedFile, ValidationRule } from '@orieljs/contracts'\nimport { applyReplacements, DEFAULT_MESSAGES, defaultAttributeName } from './messages'\nimport type { ExpandingRule } from './parse'\nimport { alike } from './rules/array'\nimport { guessColumn, matchingRecordExists } from './rules/database'\nimport { PasswordRule } from './rules/password'\nimport { isListed } from './rules/size'\n\n/**\n * Base for the fluent builders. Each one reports under a built-in rule name (`in`, `unique`, `exists`), so when it\n * runs inside a Validator its failure goes through exactly the same lookup as the string rule: custom messages\n * (\"email.unique\", \"items.*.email.unique\", \"unique\"), custom attributes, then the default text. Called directly\n * as a plain ValidationRule, validate() fails with the default English message.\n */\nexport abstract class BuiltinRuleObject<T extends RuleTyping = Record<never, never>> implements TypedValidationRule<T> {\n abstract readonly ruleName: string\n /** What a passing value is, for the validated data's type (`T`); never set at run time. */\n declare readonly __typing?: T\n\n /** `ruleNames`: the field's named rules, when it runs inside a Validator (`Rule.in()` reads `array`). */\n abstract passes(attribute: string, value: unknown, data: Record<string, unknown>, expandedFromWildcard?: boolean, ruleNames?: readonly string[]): boolean | Promise<boolean>\n\n /** The parameters its message shows (`:values` of Rule.doesntContain()), as the string rule's would be. */\n messageParameters(): string[] {\n return []\n }\n\n // Declares all 4 contract parameters so a subclass's inferred type (from `Rule.in(...)` etc.) still accepts a\n // call with the full 4-arg ValidationRule.validate signature, as Rule.test.ts makes.\n async validate(attribute: string, value: unknown, fail: (message: string) => void, data: Record<string, unknown>, expandedFromWildcard = false): Promise<void> {\n if (await this.passes(attribute, value, data, expandedFromWildcard)) return\n fail(applyReplacements(DEFAULT_MESSAGES[this.ruleName]!, { attribute: defaultAttributeName(attribute), values: this.messageParameters().join(', ') }))\n }\n}\n\n/**\n * What `Rule.in(values)` lets through. A list the compiler only knows as `string[]` says nothing: any value whose text\n * is listed passes (the number 1 for '1'), so `string` would be too narrow. A rule string known only as `string` is\n * treated the same way.\n */\ntype InTyping<V> = string extends V ? Record<never, never> : { value: InValue<V>; each: InValue<V> }\n\nclass InRule<V> extends BuiltinRuleObject<InTyping<V>> {\n readonly ruleName = 'in'\n\n constructor(private readonly values: readonly V[]) {\n super()\n }\n\n passes(_attribute: string, value: unknown, _data?: Record<string, unknown>, _expanded?: boolean, ruleNames: readonly string[] = []): boolean {\n return isListed(value, this.values.map(String), ruleNames)\n }\n}\n\nclass NotInRule extends BuiltinRuleObject {\n readonly ruleName = 'not_in'\n\n constructor(private readonly values: readonly unknown[]) {\n super()\n }\n\n passes(_attribute: string, value: unknown, _data?: Record<string, unknown>, _expanded?: boolean, ruleNames: readonly string[] = []): boolean {\n return !isListed(value, this.values.map(String), ruleNames)\n }\n}\n\n/** A TypeScript enum, or an `as const` object of string and number values. */\ntype EnumLike = Record<string, string | number>\n\n/**\n * The enum's values. A numeric enum's reverse mapping is left out: TypeScript adds `'-1': 'Unknown'` for\n * `Unknown = -1`, a key that is the text of a number member and names that member.\n */\nconst enumValues = (type: EnumLike): Array<string | number> =>\n Object.entries(type)\n .filter(([key, value]) => !(typeof value === 'string' && typeof type[value] === 'number' && String(type[value]) === key))\n .map(([, value]) => value)\n\n/**\n * Laravel's Rule::enum(): one of the enum's values; for a numeric enum, its number or exactly the text of it (a form\n * sends text: `'1'`, not `'1.0'` or `'01'`). only() and except() narrow the values.\n */\nclass EnumRule<E extends EnumLike> extends BuiltinRuleObject<{ value: InValue<E[keyof E]> }> {\n readonly ruleName = 'enum'\n #only: unknown[] = []\n #except: unknown[] = []\n\n constructor(private readonly type: E) {\n super()\n }\n\n only(values: E[keyof E] | ReadonlyArray<E[keyof E]>): this {\n this.#only = Array.isArray(values) ? [...(values as ReadonlyArray<E[keyof E]>)] : [values]\n return this\n }\n\n except(values: E[keyof E] | ReadonlyArray<E[keyof E]>): this {\n this.#except = Array.isArray(values) ? [...(values as ReadonlyArray<E[keyof E]>)] : [values]\n return this\n }\n\n passes(_attribute: string, value: unknown): boolean {\n const match = enumValues(this.type).find((candidate) => candidate === value || (typeof candidate === 'number' && typeof value === 'string' && String(candidate) === value))\n if (match === undefined) return false\n return this.#only.length > 0 ? this.#only.includes(match) : !this.#except.includes(match)\n }\n}\n\n/** Laravel's Rule::contains() and Rule::doesntContain(): every value is an item of the array, or none is. */\nclass ContainsRule extends BuiltinRuleObject<{ value: unknown[] }> {\n constructor(\n readonly ruleName: 'contains' | 'doesnt_contain',\n private readonly values: readonly unknown[],\n ) {\n super()\n }\n\n passes(_attribute: string, value: unknown): boolean {\n if (!Array.isArray(value)) return false\n const found = (needle: unknown) => value.some((item) => alike(item, needle))\n return this.ruleName === 'contains' ? this.values.every(found) : !this.values.some(found)\n }\n\n override messageParameters(): string[] {\n return this.values.map(String)\n }\n}\n\n/** Rules for the field: a rule string, a list, or a callback given the data that returns one. */\ntype RuleSet = string | ReadonlyArray<string | ValidationRule> | ((data: Record<string, unknown>) => string | ReadonlyArray<string | ValidationRule>)\n\n/**\n * Base for the builders that stand for string rules (Laravel's RequiredIf, ConditionalRules, ArrayRule, Dimensions):\n * the Validator puts the rules expandRules() returns in their place, so they run only inside a Validator.\n */\nabstract class ExpandingRuleObject<T extends RuleTyping = Record<never, never>> implements ExpandingRule, TypedValidationRule<T> {\n declare readonly __typing?: T\n\n abstract expandRules(data: Record<string, unknown>): string | ReadonlyArray<string | ValidationRule>\n\n validate(): never {\n throw new Error(`${this.constructor.name} stands for string rules: use it in a Validator's rules.`)\n }\n}\n\n/** Rule.requiredIf(), Rule.excludeIf(), Rule.prohibitedIf(): the rule when the condition holds, else nothing. */\nclass ConditionalRule<T extends RuleTyping = Record<never, never>> extends ExpandingRuleObject<T> {\n constructor(\n private readonly rule: 'required' | 'exclude' | 'prohibited',\n private readonly condition: boolean | (() => boolean),\n ) {\n super()\n }\n\n expandRules(): string {\n return (typeof this.condition === 'function' ? this.condition() : this.condition) ? this.rule : ''\n }\n}\n\n/** Laravel's ConditionalRules (Rule.when() and Rule.unless()): one set of rules or the other, chosen from the data. */\nclass ConditionalRules extends ExpandingRuleObject {\n constructor(\n private readonly condition: boolean | ((data: Record<string, unknown>) => boolean),\n private readonly rules: RuleSet,\n private readonly defaultRules: RuleSet,\n private readonly negate = false,\n ) {\n super()\n }\n\n expandRules(data: Record<string, unknown>): string | ReadonlyArray<string | ValidationRule> {\n const holds = (typeof this.condition === 'function' ? this.condition(data) : this.condition) !== this.negate\n const chosen = holds ? this.rules : this.defaultRules\n return typeof chosen === 'function' ? chosen(data) : chosen\n }\n}\n\n/** Laravel's Rule::array(): `array`, or `array:a,b` (an object whose keys are among those named). */\nclass ArrayRule<K extends string> extends ExpandingRuleObject<{ value: [K] extends [never] ? unknown[] : { [P in K]?: unknown } }> {\n constructor(private readonly keys: readonly K[]) {\n super()\n }\n\n expandRules(): string {\n return this.keys.length === 0 ? 'array' : `array:${this.keys.join(',')}`\n }\n}\n\ntype DimensionConstraints = Partial<Record<'width' | 'height' | 'min_width' | 'min_height' | 'max_width' | 'max_height' | 'ratio', number>>\n\n/** Laravel's Rule::dimensions(): the dimensions rule, from an object or fluently (`.maxWidth(1000).ratio(3 / 2)`). */\nclass DimensionsRule extends ExpandingRuleObject<{ value: UploadedFile }> {\n readonly #constraints: DimensionConstraints\n\n constructor(constraints: DimensionConstraints) {\n super()\n this.#constraints = { ...constraints }\n }\n\n width(pixels: number): this {\n return this.set('width', pixels)\n }\n height(pixels: number): this {\n return this.set('height', pixels)\n }\n minWidth(pixels: number): this {\n return this.set('min_width', pixels)\n }\n minHeight(pixels: number): this {\n return this.set('min_height', pixels)\n }\n maxWidth(pixels: number): this {\n return this.set('max_width', pixels)\n }\n maxHeight(pixels: number): this {\n return this.set('max_height', pixels)\n }\n /** Width over height: `ratio(3 / 2)`. */\n ratio(ratio: number): this {\n return this.set('ratio', ratio)\n }\n\n /** `dimensions:max_width=1000,ratio=1.5`, Laravel's __toString(). */\n override toString(): string {\n return `dimensions:${Object.entries(this.#constraints)\n .map(([key, value]) => `${key}=${value}`)\n .join(',')}`\n }\n\n expandRules(): string {\n return this.toString()\n }\n\n private set(key: keyof DimensionConstraints, value: number): this {\n this.#constraints[key] = value\n return this\n }\n}\n\n/** Structural shape of Database's Model — duck-typed so this package never imports `@orieljs/database` (B27). */\ninterface ModelInstanceLike {\n getKey(): unknown\n getKeyName(): string\n}\n\nfunction isModelInstance(value: unknown): value is ModelInstanceLike {\n return (\n typeof value === 'object' &&\n value !== null &&\n typeof (value as ModelInstanceLike).getKey === 'function' &&\n typeof (value as ModelInstanceLike).getKeyName === 'function'\n )\n}\n\nclass UniqueRule extends BuiltinRuleObject {\n readonly ruleName = 'unique'\n private exceptId: unknown\n private idColumnName: string | undefined\n\n constructor(\n private readonly table: string,\n private readonly column?: string,\n ) {\n super()\n }\n\n /**\n * Excludes the current record from the uniqueness check. Laravel's `Rule::unique('users')->ignore($user)` accepts\n * a model directly (the common case: \"update your profile without changing your email\"), so a model instance is\n * bound by its key (`getKey()`/`getKeyName()`), not the object itself — the object would reach the query builder\n * as an opaque value and either be rejected by the driver or stringified (B27). A plain id still works as before;\n * null (or \"NULL\") excludes nothing.\n */\n ignore(id: unknown, idColumn?: string): this {\n if (isModelInstance(id)) {\n this.exceptId = id.getKey()\n this.idColumnName = idColumn ?? id.getKeyName()\n } else {\n this.exceptId = id\n this.idColumnName = idColumn ?? 'id'\n }\n return this\n }\n\n async passes(attribute: string, value: unknown, _data?: Record<string, unknown>, expandedFromWildcard = false): Promise<boolean> {\n const column = this.column ?? guessColumn(attribute, expandedFromWildcard)\n return !(await matchingRecordExists(this.table, column, value, this.exceptId, this.idColumnName ?? 'id'))\n }\n}\n\nclass ExistsRule extends BuiltinRuleObject {\n readonly ruleName = 'exists'\n\n constructor(\n private readonly table: string,\n private readonly column?: string,\n ) {\n super()\n }\n\n passes(attribute: string, value: unknown, _data?: Record<string, unknown>, expandedFromWildcard = false): Promise<boolean> {\n return matchingRecordExists(this.table, this.column ?? guessColumn(attribute, expandedFromWildcard), value)\n }\n}\n\n/** Fluent rule-object builders, for when a plain string rule can't express what's needed (e.g. .ignore()). */\nexport const Rule = {\n /** One of `values`, compared as text (as `in:a,b`); typed as those values: `Rule.in(['draft', 'publish'])`. */\n in: <const V extends readonly unknown[]>(values: V): InRule<V[number]> => new InRule<V[number]>(values),\n /** None of `values`, compared as text (as `not_in:a,b`). */\n notIn: (values: readonly unknown[]): NotInRule => new NotInRule(values),\n /** One of a TypeScript enum's values (or an `as const` object's): `Rule.enum(Status)`, `.only([…])`, `.except([…])`. */\n enum: <E extends EnumLike>(type: E): EnumRule<E> => new EnumRule(type),\n /** An array holding every one of `values`. */\n contains: (values: readonly unknown[]): ContainsRule => new ContainsRule('contains', values),\n /** An array holding none of `values`. */\n doesntContain: (values: readonly unknown[]): ContainsRule => new ContainsRule('doesnt_contain', values),\n /** `required` when the condition (or the callback) holds. */\n requiredIf: (condition: boolean | (() => boolean)): ConditionalRule => new ConditionalRule('required', condition),\n /** `exclude` when the condition (or the callback) holds; the key is optional, as `exclude_if` makes it. */\n excludeIf: (condition: boolean | (() => boolean)): ConditionalRule<{ presence: 'optional' }> =>\n new ConditionalRule<{ presence: 'optional' }>('exclude', condition),\n /** `prohibited` when the condition (or the callback) holds. */\n prohibitedIf: (condition: boolean | (() => boolean)): ConditionalRule => new ConditionalRule('prohibited', condition),\n /** `rules` when the condition (or the callback, given the data) holds, else `defaultRules`. */\n when: (condition: boolean | ((data: Record<string, unknown>) => boolean), rules: RuleSet, defaultRules: RuleSet = []): ConditionalRules =>\n new ConditionalRules(condition, rules, defaultRules),\n /** `rules` unless the condition (or the callback, given the data) holds, else `defaultRules`. */\n unless: (condition: boolean | ((data: Record<string, unknown>) => boolean), rules: RuleSet, defaultRules: RuleSet = []): ConditionalRules =>\n new ConditionalRules(condition, rules, defaultRules, true),\n /** `array`, or with keys `array:name,email` (an object whose keys are among those named). */\n array: <const K extends string = never>(keys: readonly K[] = []): ArrayRule<K> => new ArrayRule<K>(keys),\n /** The dimensions rule: `Rule.dimensions().maxWidth(1000).ratio(3 / 2)`, or `Rule.dimensions({ min_width: 100 })`. */\n dimensions: (constraints: DimensionConstraints = {}): DimensionsRule => new DimensionsRule(constraints),\n unique: (table: string, column?: string): UniqueRule => new UniqueRule(table, column),\n exists: (table: string, column?: string): ExistsRule => new ExistsRule(table, column),\n /** Laravel's Password::defaults(): the application's password rule (at least 8 characters unless PasswordRule.defaults() changed it). */\n password: (): PasswordRule => PasswordRule.defaults(),\n}\n","import type { InferValidatedType, Rules, Validator } from '@orieljs/contracts'\nimport { Arr } from '@orieljs/support'\nimport { UnknownValidationRuleError, ValidationErrorImpl } from './errors'\nimport { MessageBagImpl } from './MessageBag'\nimport { BuiltinRuleObject } from './Rule'\nimport { applyReplacements, DEFAULT_MESSAGES, defaultAttributeName } from './messages'\nimport type { BuiltinRule, ParsedRule, RuleContext } from './parse'\nimport { expandWildcardKeys, parseRuleSpec, UNSAFE_KEYS } from './parse'\n\n/** The flags a rule list may carry: they change how the other rules run, and aren't rules themselves. */\nexport const RULE_FLAGS = ['bail', 'nullable', 'sometimes'] as const\nconst SKIPPED_MODIFIERS = new Set<string>(RULE_FLAGS)\n\n/**\n * Laravel's dependentRules: the rules whose parameters name other fields. Under a wildcard their `*`s are filled with\n * the row's keys, so `items.*.ends_at: 'after:items.*.starts_at'` compares each row with its own start.\n */\nconst DEPENDENT_RULES: ReadonlySet<string> = new Set([\n 'after', 'after_or_equal', 'before', 'before_or_equal', 'confirmed', 'different', 'exclude_if', 'exclude_unless',\n 'exclude_with', 'exclude_without', 'gt', 'gte', 'lt', 'lte', 'accepted_if', 'declined_if', 'required_if',\n 'required_if_accepted', 'required_if_declined', 'required_unless', 'required_with', 'required_with_all',\n 'required_without', 'required_without_all', 'present_if', 'present_unless', 'present_with', 'present_with_all',\n 'prohibited', 'prohibited_if', 'prohibited_if_accepted', 'prohibited_if_declined', 'prohibited_unless', 'prohibits',\n 'missing_if', 'missing_unless', 'missing_with', 'missing_with_all', 'same', 'unique',\n])\n\n/** The keys a field's wildcards matched: `items.*.tags.*` and `items.2.tags.0` → ['2', '0']. */\nfunction wildcardKeys(pattern: string, field: string): string[] {\n const fieldSegments = field.split('.')\n return pattern.split('.').flatMap((segment, index) => (segment === '*' ? [fieldSegments[index] ?? '*'] : []))\n}\n\n/** Fills each `*` of each parameter with the row's keys, in order (Laravel's replaceAsterisksInParameters). */\nfunction fillWildcards(parameters: string[], keys: string[]): string[] {\n if (keys.length === 0) return parameters\n return parameters.map((parameter) => {\n let index = 0\n return parameter.replace(/\\*/g, () => keys[index++] ?? '*')\n })\n}\n\nfunction patternMatcher(pattern: string): RegExp {\n return new RegExp(`^${pattern.split('.').map((segment) => (segment === '*' ? '[^.]+' : segment.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&'))).join('\\\\.')}$`)\n}\n\n/**\n * Rebuilds a nested structure from flat dot-paths, the way Laravel's validated() does for wildcard fields.\n * `Arr.undot` (from @orieljs/support) always builds plain objects; it can't know \"items.0\"/\"items.1\" should\n * become an array. This walks the same way, then promotes any container it created itself whose keys are exactly\n * \"0\", \"1\", \"2\", … in order into a real array. Leaf values copied from the input (a Date, an uploaded file, an\n * object that happens to have \"0\"/\"1\" keys) are returned untouched, by identity. A path with a segment in\n * UNSAFE_KEYS is dropped, so nothing can be written through to Object.prototype. The input is never mutated.\n */\nfunction buildNested(flat: Record<string, unknown>): Record<string, unknown> {\n const root: Record<string, unknown> = {}\n const created = new Set<object>([root])\n for (const [path, value] of Object.entries(flat)) {\n const parts = path.split('.')\n if (parts.some((part) => UNSAFE_KEYS.has(part))) continue\n let current = root\n for (const part of parts.slice(0, -1)) {\n const existing = Object.hasOwn(current, part) ? current[part] : undefined\n if (typeof existing === 'object' && existing !== null && created.has(existing)) {\n current = existing as Record<string, unknown>\n continue\n }\n const container = cloneContainer(existing)\n created.add(container)\n current[part] = container\n current = container\n }\n current[parts.at(-1)!] = value\n }\n return arrayify(root, created) as Record<string, unknown>\n}\n\nfunction isPlainContainer(value: unknown): value is Record<string, unknown> {\n if (Array.isArray(value)) return true\n if (typeof value !== 'object' || value === null) return false\n const proto: unknown = Object.getPrototypeOf(value)\n return proto === Object.prototype || proto === null\n}\n\n/**\n * A fresh container to write a child path into. When a parent key was already copied from the input (rules on both\n * \"user\" and \"user.name\"), its plain contents are kept (Laravel returns the whole parent) but copied, so the input\n * is never mutated. Anything else (missing, a scalar, a class instance) starts empty.\n */\nfunction cloneContainer(existing: unknown): Record<string, unknown> {\n const container: Record<string, unknown> = {}\n if (!isPlainContainer(existing)) return container\n for (const [key, value] of Object.entries(existing)) {\n if (!UNSAFE_KEYS.has(key)) container[key] = value\n }\n return container\n}\n\n/** Marks a list item an exclude rule took out, until the validated data is built (then the item is dropped). */\nconst EXCLUDED = Symbol('excluded')\n\n/**\n * The data without the excluded paths, as Laravel's removeAttribute() leaves it. Only the plain containers along each\n * path are copied (the input is never mutated); a list item becomes EXCLUDED so the other items keep their indexes\n * while the validated data is built.\n */\nfunction withoutPaths(data: Record<string, unknown>, paths: Iterable<string>): Record<string, unknown> {\n const root: Record<string, unknown> = { ...data }\n const copies = new Set<object>([root])\n for (const path of paths) {\n const parts = path.split('.')\n const leaf = parts.pop()!\n let node: Record<string, unknown> | undefined = root\n for (const part of parts) {\n const child: unknown = Object.hasOwn(node, part) ? node[part] : undefined\n if (!isPlainContainer(child)) {\n node = undefined\n break\n }\n const copy = copies.has(child) ? child : ((Array.isArray(child) ? [...child] : { ...child }) as Record<string, unknown>)\n copies.add(copy)\n node[part] = copy\n node = copy\n }\n if (node === undefined || !Object.hasOwn(node, leaf)) continue\n if (Array.isArray(node)) node[Number(leaf)] = EXCLUDED\n else delete node[leaf]\n }\n return root\n}\n\n/**\n * Drops the EXCLUDED marks from the validated data (only containers it built or copied can hold one): a list closes\n * up, and an object built from a sparse match loses the key.\n */\nfunction dropExcluded(node: unknown, seen = new Set<unknown>()): void {\n if (typeof node !== 'object' || node === null || seen.has(node)) return\n seen.add(node)\n if (Array.isArray(node)) {\n // In place, without spreading the list into a call (Node's stack can't take a list of 150,000 or so).\n if (node.includes(EXCLUDED)) {\n let kept = 0\n for (const item of node) if (item !== EXCLUDED) node[kept++] = item\n node.length = kept\n }\n } else if (isPlainContainer(node)) {\n for (const [key, value] of Object.entries(node)) if (value === EXCLUDED) delete node[key]\n }\n if (isPlainContainer(node)) for (const value of Object.values(node)) dropExcluded(value, seen)\n}\n\n/**\n * A node of the excluded paths' tree: a run of whole segments (joined by dots), the runs that follow it keyed by their\n * first segment, and whether an excluded path ends here. A run holds every segment no other path branches from, so\n * the tree keeps a node or two per excluded path however many dots the paths hold.\n */\ninterface ExcludedRun {\n run: string\n readonly next: Map<string, ExcludedRun>\n excluded: boolean\n}\n\n/** Where the segment of `path` that starts at `start` ends: the next dot, else the end of the path. */\nfunction segmentEnd(path: string, start: number): number {\n const dot = path.indexOf('.', start)\n return dot === -1 ? path.length : dot\n}\n\nfunction arrayify(node: unknown, created: ReadonlySet<object>): unknown {\n if (node === null || typeof node !== 'object' || !created.has(node)) return node\n const entries = Object.entries(node as Record<string, unknown>).map(([k, v]) => [k, arrayify(v, created)] as const)\n const keys = entries.map(([k]) => k)\n const isArrayLike = keys.length > 0 && keys.every((k, i) => k === String(i))\n return isArrayLike ? entries.map(([, v]) => v) : Object.fromEntries(entries)\n}\n\n/**\n * Runs each field's rules the way Laravel's Validator does:\n * - a missing key, or a string that is blank after trimming, only runs implicit rules (the required* family and\n * accepted); every other rule, including ValidationRule objects, is skipped for it;\n * - an explicit null runs every rule unless the field is `nullable` (then only implicit rules run), so\n * `{ age: null }` still fails `integer`;\n * - `sometimes` skips a missing field entirely;\n * - a field stops validating after its first failure under `bail`, or after any implicit rule fails.\n */\nexport class ValidatorImpl<R extends Rules = Rules> implements Validator<R> {\n private bag: MessageBagImpl | undefined\n private ranPromise: Promise<boolean> | undefined\n private readonly afterCallbacks: Array<(validator: Validator) => void | Promise<void>> = []\n private parsedRules: Map<string, ParsedRule[]> | undefined\n /** The fields an exclude rule took out (with their children). */\n private readonly excluded = new Set<string>()\n /** The same fields as a tree of segment runs from the root, so a lookup reads the field once. */\n private readonly excludedRuns: ExcludedRun = { run: '', next: new Map(), excluded: false }\n /** What the rules keep while one pass runs (RuleContext.cache); a new pass starts with a new one. */\n private cache = new Map<string, unknown>()\n\n constructor(\n private readonly data: Record<string, unknown>,\n private readonly rules: R,\n private readonly customMessages: Record<string, string>,\n private readonly customAttributes: Record<string, string>,\n private readonly registry: Record<string, BuiltinRule>,\n private readonly errorBagName = 'default',\n ) {}\n\n after(callback: (validator: Validator) => void | Promise<void>): this {\n this.afterCallbacks.push(callback)\n return this\n }\n\n /** Lets an after() hook add a failure. */\n fail(field: string, message: string): void {\n this.bag ??= new MessageBagImpl()\n this.bag.add(field, message)\n }\n\n async passes(): Promise<boolean> {\n this.ranPromise ??= this.run()\n return this.ranPromise\n }\n\n async fails(): Promise<boolean> {\n return !(await this.passes())\n }\n\n errors(): MessageBagImpl {\n return this.bag ?? new MessageBagImpl()\n }\n\n async validated<T = InferValidatedType<R>>(): Promise<T> {\n if (!(await this.passes())) throw new ValidationErrorImpl(this.bag!.toObject(), this.errorBagName)\n const data = this.excluded.size === 0 ? this.data : withoutPaths(this.data, this.excluded)\n const flat: Record<string, unknown> = {}\n for (const pattern of Object.keys(this.rules)) {\n for (const field of this.fieldsFor(pattern)) {\n if (!this.isExcluded(field) && Arr.has(data, field)) flat[field] = Arr.get(data, field)\n }\n }\n // An excluded list item keeps its index until the list is built, so the list's indexes stay 0..n-1 and it is\n // still built as a list, then closes up.\n for (const path of this.excluded) {\n const parent = path.includes('.') ? path.slice(0, path.lastIndexOf('.')) : undefined\n if (parent === undefined || this.isExcluded(parent) || !Arr.has(this.data, path)) continue\n if (Array.isArray(Arr.get(this.data, parent))) flat[path] = EXCLUDED\n }\n const nested = buildNested(flat)\n if (this.excluded.size > 0) dropExcluded(nested)\n return nested as T\n }\n\n /** Takes the field (with its children) out of validation and of the validated data. */\n private exclude(field: string): void {\n this.excluded.add(field)\n let node = this.excludedRuns\n for (let start = 0; ; ) {\n const first = field.slice(start, segmentEnd(field, start))\n let next = node.next.get(first)\n if (next === undefined) {\n node.next.set(first, { run: field.slice(start), next: new Map(), excluded: true })\n return\n }\n // The whole segments the run and the field share from `start`: at least the first one.\n let same = 0\n while (same < next.run.length && start + same < field.length && next.run[same] === field[start + same]) same++\n const runEnds = same === next.run.length || next.run[same] === '.'\n const fieldEnds = start + same === field.length || field[start + same] === '.'\n if (!runEnds || !fieldEnds) same = next.run.lastIndexOf('.', same - 1)\n if (same < next.run.length) {\n // The field ends or turns off inside the run: split the run after the segments they share.\n const rest = next.run.slice(same + 1)\n const shared: ExcludedRun = { run: next.run.slice(0, same), next: new Map([[rest.slice(0, segmentEnd(rest, 0)), next]]), excluded: false }\n next.run = rest\n node.next.set(first, shared)\n next = shared\n }\n start += same\n if (start === field.length) {\n next.excluded = true\n return\n }\n node = next\n start++\n }\n }\n\n /**\n * Laravel's shouldBeExcluded(): the field, or one of its parents, was taken out by an exclude rule. The field's\n * segments are followed from the root (so `user` takes out `user.name`, not `username`) and each is read once,\n * however many fields were excluded and however many dots the field holds.\n */\n private isExcluded(field: string): boolean {\n if (this.excluded.size === 0) return false\n let node = this.excludedRuns\n for (let start = 0; ; ) {\n const next = node.next.get(field.slice(start, segmentEnd(field, start)))\n if (next === undefined) return false\n const end = start + next.run.length\n // The run must be the field's next whole segments, not the start of a longer segment.\n if (!field.startsWith(next.run, start) || (end < field.length && field[end] !== '.')) return false\n if (next.excluded) return true\n if (end === field.length) return false\n node = next\n start = end + 1\n }\n }\n\n private fieldsFor(pattern: string): string[] {\n return pattern.includes('*') ? expandWildcardKeys(pattern, this.data) : [pattern]\n }\n\n private parsed(): Map<string, ParsedRule[]> {\n this.parsedRules ??= new Map(Object.entries(this.rules).map(([pattern, spec]) => [pattern, parseRuleSpec(spec, this.data)]))\n return this.parsedRules\n }\n\n /** The rule key a concrete field falls under: itself, else the first wildcard key that matches it. */\n private patternOf(field: string): string | undefined {\n const parsed = this.parsed()\n if (parsed.has(field)) return field\n for (const pattern of parsed.keys()) if (pattern.includes('*') && patternMatcher(pattern).test(field)) return pattern\n return undefined\n }\n\n /** Laravel's getRule(): the parameters of rule `name` on `field`, or undefined when the field has no such rule. */\n private ruleParameters(field: string, name: string): string[] | undefined {\n const pattern = this.patternOf(field)\n const rule = pattern === undefined ? undefined : this.parsed().get(pattern)!.find((r) => r.kind === 'named' && r.name === name)\n return rule?.kind === 'named' ? rule.parameters : undefined\n }\n\n /** Laravel's getDisplayableAttribute(): a custom attribute for the field or its rule key, else the humanized key. */\n private displayName(field: string): string {\n const pattern = this.patternOf(field)\n return this.customAttributes[field] ?? (pattern === undefined ? undefined : this.customAttributes[pattern]) ?? defaultAttributeName(field)\n }\n\n private context(field: string, pattern: string, value: unknown, parameters: string[], ruleNames: string[]): RuleContext {\n return {\n attribute: field,\n expandedFromWildcard: pattern.includes('*'),\n value,\n parameters,\n data: this.data,\n ruleNames,\n pattern,\n cache: this.cache,\n getRule: (other, name) => this.ruleParameters(other, name),\n displayName: (other) => this.displayName(other),\n }\n }\n\n private async run(): Promise<boolean> {\n this.bag = new MessageBagImpl()\n this.cache = new Map()\n\n for (const [pattern, parsed] of this.parsed()) {\n const names = parsed.filter((r): r is Extract<ParsedRule, { kind: 'named' }> => r.kind === 'named').map((r) => r.name)\n const bail = names.includes('bail')\n const nullable = names.includes('nullable')\n const sometimes = names.includes('sometimes')\n\n for (const field of this.fieldsFor(pattern)) {\n if (this.isExcluded(field)) continue\n const present = Arr.has(this.data, field)\n if (sometimes && !present) continue\n\n const value = Arr.get(this.data, field)\n const isNull = value === null || value === undefined\n const isBlank = typeof value === 'string' && value.trim() === ''\n\n for (const rule of parsed) {\n if (rule.kind === 'named' && SKIPPED_MODIFIERS.has(rule.name)) continue\n const builtin = rule.kind === 'named' ? this.registry[rule.name] : undefined\n // Laravel's isValidatable(): an exclude rule always runs; failing it takes the field out, with no message.\n if (builtin?.excludes) {\n if (!(await this.passesExcludeRule(rule as Extract<ParsedRule, { kind: 'named' }>, builtin, field, pattern, value, names))) {\n this.exclude(field)\n break\n }\n continue\n }\n const implicit = builtin?.implicit ?? false\n // Laravel's presentOrRuleIsImplicit: a missing key or a blank string only runs implicit rules.\n if (!implicit && (!present || isBlank)) continue\n // Laravel's isNotNullIfMarkedAsNullable: nullable + null only runs implicit rules.\n if (!implicit && nullable && isNull) continue\n\n const messages = await this.runRule(rule, field, pattern, value, names)\n if (messages.length > 0) {\n for (const message of messages) this.bag.add(field, message)\n // Laravel's shouldStopValidating: bail stops at the first failure; a failed implicit rule always stops.\n if (bail || implicit) break\n }\n }\n }\n }\n\n for (const callback of this.afterCallbacks) await callback(this)\n return this.bag.isEmpty()\n }\n\n private async passesExcludeRule(\n rule: Extract<ParsedRule, { kind: 'named' }>,\n builtin: BuiltinRule,\n field: string,\n pattern: string,\n value: unknown,\n ruleNames: string[],\n ): Promise<boolean> {\n return builtin.validate(this.context(field, pattern, value, fillWildcards(rule.parameters, wildcardKeys(pattern, field)), ruleNames))\n }\n\n private async runRule(\n rule: ParsedRule,\n field: string,\n pattern: string,\n value: unknown,\n ruleNames: string[],\n ): Promise<string[]> {\n const expanded = pattern.includes('*')\n if (rule.kind === 'object') {\n if (rule.rule instanceof BuiltinRuleObject) {\n if (await rule.rule.passes(field, value, this.data, expanded, ruleNames)) return []\n const ctx = this.context(field, pattern, value, rule.rule.messageParameters(), ruleNames)\n return [this.failureMessage(rule.rule.ruleName, this.registry[rule.rule.ruleName], ctx, pattern)]\n }\n // Every fail() call is a message, as with Laravel's invokable rules (Rule.password() reports each failed check),\n // with :attribute replaced as in a built-in rule's message.\n const failures: string[] = []\n const attribute = this.displayName(field)\n await rule.rule.validate(field, value, (message) => void failures.push(applyReplacements(message, { attribute })), this.data)\n return failures\n }\n\n const builtin = this.registry[rule.name]\n if (!builtin) throw new UnknownValidationRuleError(rule.name)\n\n const parameters = DEPENDENT_RULES.has(rule.name) ? fillWildcards(rule.parameters, wildcardKeys(pattern, field)) : rule.parameters\n const ctx = this.context(field, pattern, value, parameters, ruleNames)\n if (await builtin.validate(ctx)) return []\n return [this.failureMessage(rule.name, builtin, ctx, pattern)]\n }\n\n /** Custom message (concrete field, then wildcard pattern, then rule name) or the default, with :attribute filled. */\n private failureMessage(name: string, builtin: BuiltinRule | undefined, ctx: RuleContext, pattern: string): string {\n const field = ctx.attribute\n const template =\n this.customMessages[`${field}.${name}`] ??\n this.customMessages[`${pattern}.${name}`] ??\n this.customMessages[name] ??\n builtin?.message ??\n DEFAULT_MESSAGES[builtin?.messageKey(ctx) ?? name] ??\n builtin?.defaultMessage ??\n 'The :attribute field is invalid.'\n\n const display = this.customAttributes[field] ?? this.customAttributes[pattern] ?? defaultAttributeName(field)\n return applyReplacements(template, { attribute: display, ...(builtin?.replacements?.(ctx) ?? {}) })\n }\n}\n","import type { RuleCallback, Rules, ValidationFactory } from '@orieljs/contracts'\nimport type { BuiltinRule } from './parse'\nimport { builtinRules } from './registry'\nimport { RULE_FLAGS, ValidatorImpl } from './Validator'\n\nexport class ValidationFactoryImpl implements ValidationFactory {\n private readonly extended: Record<string, BuiltinRule> = {}\n\n make<const R extends Rules>(\n data: Record<string, unknown>,\n rules: R,\n messages: Record<string, string> = {},\n attributes: Record<string, string> = {},\n ): ValidatorImpl<R> {\n return new ValidatorImpl(data, rules, messages, attributes, { ...builtinRules, ...this.extended })\n }\n\n /** Every rule this factory knows, built-in and extend()ed, sorted (for editors: `oriel ide:info`). */\n ruleNames(): string[] {\n return [...new Set([...Object.keys(builtinRules), ...RULE_FLAGS, ...Object.keys(this.extended)])].sort()\n }\n\n extend(name: string, callback: RuleCallback, message?: string): void {\n this.extended[name] = {\n validate: (ctx) => callback(ctx.attribute, ctx.value, ctx.parameters, ctx.data),\n messageKey: () => name,\n ...(message === undefined ? {} : { message }),\n defaultMessage: message ?? 'The :attribute field is invalid.',\n }\n }\n}\n","import type { ValidationFactory } from '@orieljs/contracts'\nimport { ValidationFactory as ValidationFactoryToken } from '@orieljs/contracts'\nimport { facade } from '@orieljs/support'\n\n/** Laravel's Validator facade: Validator.make(...)/Validator.extend(...), proxied to the resolved ValidationFactory. */\nexport const Validator = facade<ValidationFactory>(ValidationFactoryToken)\n","import { ValidationFactory as ValidationFactoryToken } from '@orieljs/contracts'\nimport { ServiceProvider } from '@orieljs/support'\nimport { ValidationFactoryImpl } from './ValidationFactory'\n\nexport class ValidationServiceProvider extends ServiceProvider {\n override register(): void {\n this.app.singleton(ValidationFactoryToken, () => new ValidationFactoryImpl())\n }\n}\n"],"mappings":";AAEO,IAAM,sBAAN,cAAkC,MAAiC;AAAA,EAIxE,YACW,QACA,WAAW,WACX,YACT;AACA,UAAM,6BAA6B;AAJ1B;AACA;AACA;AAAA,EAGX;AAAA,EALW;AAAA,EACA;AAAA,EACA;AAAA,EANF,OAAO;AAAA,EACP,SAAS;AAAA,EACA,OAAO;AAQ3B;AAOO,IAAM,sBAAN,MAAM,6BAA4B,oBAAoB;AAAA;AAAA,EAE3D,OAAO,aAAa,UAA2E;AAC7F,UAAM,SAAS,OAAO,YAAY,OAAO,QAAQ,QAAQ,EAAE,IAAI,CAAC,CAAC,OAAO,IAAI,MAAM,CAAC,OAAO,OAAO,SAAS,WAAW,CAAC,IAAI,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;AACzI,WAAO,IAAI,qBAAoB,MAAM;AAAA,EACvC;AAAA,EAEA,YAAY,QAAkC,WAAW,WAAW,YAAqB;AACvF,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EACpG;AACF;;;ACrcO,IAAM,wBAAN,MAAyD;AAAA,EAC7C,WAAwC,CAAC;AAAA,EAE1D,KACE,MACA,OACA,WAAmC,CAAC,GACpC,aAAqC,CAAC,GACpB;AAClB,WAAO,IAAI,cAAc,MAAM,OAAO,UAAU,YAAY,EAAE,GAAG,cAAc,GAAG,KAAK,SAAS,CAAC;AAAA,EACnG;AAAA;AAAA,EAGA,YAAsB;AACpB,WAAO,CAAC,GAAG,oBAAI,IAAI,CAAC,GAAG,OAAO,KAAK,YAAY,GAAG,GAAG,YAAY,GAAG,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,KAAK;AAAA,EACzG;AAAA,EAEA,OAAO,MAAc,UAAwB,SAAwB;AACnE,SAAK,SAAS,IAAI,IAAI;AAAA,MACpB,UAAU,CAAC,QAAQ,SAAS,IAAI,WAAW,IAAI,OAAO,IAAI,YAAY,IAAI,IAAI;AAAA,MAC9E,YAAY,MAAM;AAAA,MAClB,GAAI,YAAY,SAAY,CAAC,IAAI,EAAE,QAAQ;AAAA,MAC3C,gBAAgB,WAAW;AAAA,IAC7B;AAAA,EACF;AACF;;;AC7BA,SAAS,qBAAqB,8BAA8B;AAC5D,SAAS,cAAc;AAGhB,IAAM,YAAY,OAA0B,sBAAsB;;;ACLzE,SAAS,qBAAqBC,+BAA8B;AAC5D,SAAS,uBAAuB;AAGzB,IAAM,4BAAN,cAAwC,gBAAgB;AAAA,EACpD,WAAiB;AACxB,SAAK,IAAI,UAAUC,yBAAwB,MAAM,IAAI,sBAAsB,CAAC;AAAA,EAC9E;AACF;","names":["Arr","Arr","listed","Arr","Arr","Arr","comparison","Arr","inject","inject","Arr","length","format","format","Arr","Arr","Arr","listed","Arr","Str","Str","listed","Arr","Arr","Arr","Arr","Arr","Arr","isPlainObject","COMPARE","Arr","comparison","lower","length","Arr","Arr","ctx","ValidationFactoryToken","ValidationFactoryToken"]}
|