import { BaseLiteralType } from '../base/literal.js'; import { type FieldOptions, type Validation } from '../../types.js'; import { IS_OF_TYPE, SUBTYPE, UNIQUE_NAME } from '../../symbols.js'; /** * VineNumber represents a numeric value in the validation schema. * It accepts both string and number inputs and converts them to numbers, * with comprehensive validation for ranges, decimals, and sign constraints. * * @example * const schema = vine.number() * .min(0) * .max(100) * .decimal([0, 2]) * * const result = await vine.validate({ * schema, * data: "42.5" * }) */ export declare class VineNumber extends BaseLiteralType { options: FieldOptions & { strict?: boolean; }; /** * Static collection of all available validation rules for numbers */ static rules: { in: (options: { values: number[]; }) => Validation<{ values: number[]; }>; max: (options: { max: number; }) => Validation<{ max: number; }>; min: (options: { min: number; }) => Validation<{ min: number; }>; range: (options: { min: number; max: number; }) => Validation<{ min: number; max: number; }>; number: (options: { strict?: boolean; }) => Validation<{ strict?: boolean; }>; decimal: (options: { range: [number, number?]; }) => Validation<{ range: [number, number?]; }>; negative: (options?: undefined) => Validation; positive: (options?: undefined) => Validation; nonNegativeRule: (options?: undefined) => Validation; nonPositiveRule: (options?: undefined) => Validation; withoutDecimals: (options?: undefined) => Validation; }; /** * The subtype identifier for the literal schema field */ [SUBTYPE]: string; /** * Unique name identifier for union type resolution */ [UNIQUE_NAME]: string; /** * Type checker function to determine if a value can be converted to a number. * Required for "unionOfTypes" functionality. * * @param value - The value to check * @returns True if the value can be converted to a valid number */ [IS_OF_TYPE]: (value: unknown) => boolean; /** * Creates a new VineNumber instance with optional configuration. * * @param options - Field options like bail mode, nullability and strict mode * @param validations - Initial set of validations to apply */ constructor(options?: Partial & { strict?: boolean; }, validations?: Validation[]); /** * Enforce a minimum value for the number input. * * @param value - The minimum allowed value * @returns This number schema instance for method chaining */ min(value: number): this; /** * Enforce a maximum value for the number input. * * @param value - The maximum allowed value * @returns This number schema instance for method chaining */ max(value: number): this; /** * Enforce value to be within the range of minimum and maximum values. * * @param value - Tuple containing [min, max] values * @returns This number schema instance for method chaining */ range(value: [min: number, max: number]): this; /** * Enforces the value to be a positive number (greater than 0). * * @returns This number schema instance for method chaining * * @example * vine.number().positive() // Accepts 1, 100.5, etc. Rejects 0, -1 */ positive(): this; /** * Enforces the value to be a negative number (less than 0). * * @returns This number schema instance for method chaining * * @example * vine.number().negative() // Accepts -1, -100.5, etc. Rejects 0, 1 */ negative(): this; /** * Enforces the value to be a non-negative number (greater than or equal to 0). * * @returns This number schema instance for method chaining * * @example * vine.number().nonNegative() // Accepts 0, 1, 100.5, etc. Rejects -1 */ nonNegative(): this; /** * Enforces the value to be a non-positive number (less than or equal to 0). * * @returns This number schema instance for method chaining * * @example * vine.number().nonPositive() // Accepts 0, -1, -100.5, etc. Rejects 1 */ nonPositive(): this; /** * Enforces the value to have a fixed number or range of decimal places. * * @param range - Exact number of decimal places or [min, max] range * @returns This number schema instance for method chaining * * @example * vine.number().decimal(2) // Accepts 1.23, rejects 1.2 or 1.234 * vine.number().decimal([0, 2]) // Accepts 1, 1.2, 1.23 */ decimal(range: number | [number, number]): this; /** * Enforces the value to be an integer without decimal places. * * @returns This number schema instance for method chaining * * @example * vine.number().withoutDecimals() // Accepts 42, -10, rejects 42.5 */ withoutDecimals(): this; /** * Clones the VineNumber schema type. The applied options * and validations are copied to the new instance. * * @returns A cloned instance of this VineNumber schema */ clone(): this; /** * Enforces the value to be one of the specified allowed values. * * @param values - Array of allowed numeric values * @returns This number schema instance for method chaining * * @example * vine.number().in([1, 2, 3, 5, 8, 13]) // Only Fibonacci numbers allowed */ in(values: number[]): this; }