UNPKG

class-validator-extended

Version:
34 lines (33 loc) 1.34 kB
import type { ValidationOptions } from 'class-validator'; import type { OpUnitType } from 'dayjs'; /** @hidden */ export declare const FUTURE_DAYJS = "futureDayjs"; /** * Checks if the given value is a valid Dayjs object in the future. * * Beware that the behaviour of this check depends on the current time and can thus be difficult to test. In particular, * as time goes by the property can become invalid without ever changing its value. * * #### Example * ```typescript * // Ensure the value is in the future. * @FutureDayjs() * scheduledFor: Dayjs * ``` * * @category Dayjs * @param options * Accepts the following options (in addition to generic class-validator options): * - `allow_invalid: boolean = false` * If true, allow the Dayjs object to be invalid (see [isValid()](https://day.js.org/docs/en/parse/is-valid)). * - `inclusive: boolean = false` * If true, allow the current date as well. * - `granularity: string = 'milliseconds'` * Defines the [granularity](https://day.js.org/docs/en/manipulate/start-of#list-of-all-available-units), e.g. "day" * to ignore hours, minutes, seconds and milliseconds. */ export declare function FutureDayjs(options?: { allow_invalid?: boolean; inclusive?: boolean; granularity?: OpUnitType; } & ValidationOptions): PropertyDecorator;