import { SchemaContext } from "../../types/context-types.mjs"; //#region ../@warlock.js/seal/src/validators/methods/required-methods.d.ts /** * Marker re-exported by the validators barrel so the dts bundler keeps this * module (and its `declare module` augmentation) in the bundled `.d.ts`. * Without a real export, side-effect-only augmentation modules get tree-shaken * out of the published types, dropping every chainable rule method. */ declare const requiredMethodsApplied = true; declare module "../base-validator.mjs" { interface BaseValidator { /** * This value must be present and has a value */ required(errorMessage?: string): this; /** * Value must be present but not necessarily has a value */ present(errorMessage?: string): this; /** * Mark the field as optional, so pass it if it has no value or has a value * Because this is the default behavior, this method is just syntactic sugar */ optional(): this & { isOptional: true; }; /** * Sugar for `.optional().nullable()` — the field may be absent OR null. * * Brands the return type with both `{ isOptional: true }` and `{ isNullable: true }` * so `Infer<>` produces `{ field?: T | null }`. * * @example * v.string().nullish() * // type: string | null | undefined * // absent → key omitted * // null → null * // "x" → "x" */ nullish(): this & { isOptional: true; isNullable: true; }; /** * Value is required if another field exists */ requiredWith(field: string, errorMessage?: string): this; /** * Value is required if another sibling field exists */ requiredWithSibling(field: string, errorMessage?: string): this; /** * Value is required if another field is missing */ requiredWithout(field: string, errorMessage?: string): this; /** * Value is required if another sibling field is missing */ requiredWithoutSibling(field: string, errorMessage?: string): this; /** * Value is required if another field equals a specific value */ requiredIf(field: string, value: any, errorMessage?: string): this; /** * Value is required if another sibling field equals a specific value */ requiredIfSibling(field: string, value: any, errorMessage?: string): this; /** * Value is required unless another field equals a specific value */ requiredUnless(field: string, value: any, errorMessage?: string): this; /** * Value is required unless another sibling field equals a specific value */ requiredUnlessSibling(field: string, value: any, errorMessage?: string): this; /** * Value is required if another field is empty */ requiredIfEmpty(field: string, errorMessage?: string): this; /** * Value is required if another sibling field is empty */ requiredIfEmptySibling(field: string, errorMessage?: string): this; /** * Value is required if another field is not empty */ requiredIfNotEmpty(field: string, errorMessage?: string): this; /** * Value is required if another sibling field is not empty */ requiredIfNotEmptySibling(field: string, errorMessage?: string): this; /** * Value is required if ALL specified fields are empty */ requiredIfAllEmpty(fields: string[], errorMessage?: string): this; /** * Value is required if ALL specified sibling fields are empty */ requiredIfAllEmptySiblings(fields: string[], errorMessage?: string): this; /** * Value is required if ANY of the specified fields is empty */ requiredIfAnyEmpty(fields: string[], errorMessage?: string): this; /** * Value is required if ANY of the specified sibling fields is empty */ requiredIfAnyEmptySiblings(fields: string[], errorMessage?: string): this; /** * Value is required if ALL specified fields are NOT empty */ requiredIfAllNotEmpty(fields: string[], errorMessage?: string): this; /** * Value is required if ALL specified sibling fields are NOT empty */ requiredIfAllNotEmptySiblings(fields: string[], errorMessage?: string): this; /** * Value is required if ANY of the specified fields is NOT empty */ requiredIfAnyNotEmpty(fields: string[], errorMessage?: string): this; /** * Value is required if ANY of the specified sibling fields is NOT empty */ requiredIfAnyNotEmptySiblings(fields: string[], errorMessage?: string): this; /** * Value is required if another field's value is in the given array */ requiredIfIn(field: string, values: any[], errorMessage?: string): this; /** * Value is required if another sibling field's value is in the given array */ requiredIfInSibling(field: string, values: any[], errorMessage?: string): this; /** * Value is required if another field's value is NOT in the given array */ requiredIfNotIn(field: string, values: any[], errorMessage?: string): this; /** * Value is required if another sibling field's value is NOT in the given array */ requiredIfNotInSibling(field: string, values: any[], errorMessage?: string): this; /** * Value is required if all specified fields exist */ requiredWithAll(fields: string[], errorMessage?: string): this; /** * Value is required if all specified sibling fields exist */ requiredWithAllSiblings(fields: string[], errorMessage?: string): this; /** * Value is required if all specified fields are missing */ requiredWithoutAll(fields: string[], errorMessage?: string): this; /** * Value is required if all specified sibling fields are missing */ requiredWithoutAllSiblings(fields: string[], errorMessage?: string): this; /** * Value is required if any of the specified fields exists */ requiredWithAny(fields: string[], errorMessage?: string): this; /** * Value is required if any of the specified sibling fields exists */ requiredWithAnySiblings(fields: string[], errorMessage?: string): this; /** * Value is required if any of the specified fields is missing */ requiredWithoutAny(fields: string[], errorMessage?: string): this; /** * Value is required if any of the specified sibling fields is missing */ requiredWithoutAnySiblings(fields: string[], errorMessage?: string): this; /** * Make this field required based on a custom callback. * * The callback receives only the `SchemaContext` (not the value), * because "required" is about surrounding conditions, not the field itself. * Return `true` if the field should be required. * * @param callback - Receives SchemaContext, returns boolean * @param errorMessage - Optional custom error message * * @example * ```ts * // Required when email notification is enabled * v.string().requiredWhen((context) => { * return context.allData.notificationMethod === 'email'; * }) * * // Required based on multiple conditions * v.string().requiredWhen((context) => { * const { role, department } = context.allData; * return role === 'manager' && department === 'finance'; * }) * ``` */ requiredWhen(callback: (context: SchemaContext) => boolean | Promise, errorMessage?: string): this; } } //# sourceMappingURL=required-methods.d.ts.map //#endregion export { requiredMethodsApplied }; //# sourceMappingURL=required-methods.d.mts.map