class-validator-extended
Version:
Additional validators for class-validator.
32 lines (31 loc) • 1.25 kB
TypeScript
import type { ValidationOptions } from 'class-validator';
import type { ConfigType, OpUnitType } from 'dayjs';
/** @hidden */
export declare const MAX_DAYJS = "maxDayjs";
/**
* Checks if the given value is a valid Dayjs object not later than `maximum`.
*
* #### Example
* ```typescript
* // Ensure the value is before the infamous Y2K.
* @MaxDayjs('2000-01-01Z', { granularity: 'day' })
* y2kSafeDate: Dayjs
* ```
*
* @category Dayjs
* @param maximum The maximum allowed value.
* @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 `maximum` 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 MaxDayjs(maximum: ConfigType, options?: {
allow_invalid?: boolean;
inclusive?: boolean;
granularity?: OpUnitType;
} & ValidationOptions): PropertyDecorator;