import { JsonSchemaResult, JsonSchemaTarget } from "../standard-schema/json-schema.mjs"; import { PrimitiveValidator } from "./primitive-validator.mjs"; //#region ../@warlock.js/seal/src/validators/scalar-validator.d.ts /** * Scalar validator class * * Core validator for scalar values (string, number, boolean). * Extends PrimitiveValidator (inherits enum/in/oneOf/allowsOnly/forbids/notIn) * and additionally provides type-coercion mutators and accepted/declined rules. * * Database methods (unique, exists, etc.) are injected by the framework */ declare class ScalarValidator extends PrimitiveValidator { constructor(errorMessage?: string); /** * Add matches type */ matchesType(value: any): value is string | number | boolean; /** * Mutate the scalar value to be number */ asNumber(): this; /** * Mutate the scalar value to be string */ asString(): this; /** * Accepted value * The value will be valid if it equals 1 | "1" | true | "true" | "yes" | "y" | "on" */ accepted(errorMessage?: string): this; /** * Accepted value if another field's value equals to a specific value */ acceptedIf(field: string, value: any, errorMessage?: string): this; /** * Accepted value if another field's value is not equal to the given value */ acceptedUnless(field: string, value: any, errorMessage?: string): this; /** * Accepted value if another field is required */ acceptedIfRequired(field: string, errorMessage?: string): this; /** * Accepted value if another field is present */ acceptedIfPresent(field: string, errorMessage?: string): this; /** * Accepted value if another field is missing */ acceptedWithout(field: string, errorMessage?: string): this; /** * Declined value * The value will be valid if it equals 0 | "0" | false | "false" | "no" | "n" | "off" */ declined(errorMessage?: string): this; /** * Declined value if another field's value equals to a specific value */ declinedIf(field: string, value: any, errorMessage?: string): this; /** * Declined value if another field's value is not equal to the given value */ declinedUnless(field: string, value: any, errorMessage?: string): this; /** * Declined value if another field is required */ declinedIfRequired(field: string, errorMessage?: string): this; /** * Declined value if another field is present */ declinedIfPresent(field: string, errorMessage?: string): this; /** * Declined value if another field is missing */ declinedWithout(field: string, errorMessage?: string): this; /** * @inheritdoc * * A scalar accepts string | number | boolean. If `.in()` / `.enum()` is used, * output collapses to a simple `enum` list instead. * * @example * ```ts * v.scalar().toJsonSchema("draft-2020-12") * // → { oneOf: [{ type: "string" }, { type: "number" }, { type: "boolean" }] } * * v.scalar().in(["active", "inactive"]).toJsonSchema("draft-2020-12") * // → { enum: ["active", "inactive"] } * ``` */ toJsonSchema(_target?: JsonSchemaTarget): JsonSchemaResult; } //#endregion export { ScalarValidator }; //# sourceMappingURL=scalar-validator.d.mts.map