import { Maybe, AnyObject, Optionals } from 'yup/lib/types'; import BaseSchema, { AnySchema } from 'yup/lib/schema'; import { TypeOf, Asserts } from 'yup/lib/util/types'; import { ObjectShape, TypeOfShape, AssertsShape } from 'yup/lib/object'; import Lazy from 'yup/lib/Lazy'; import { MixedSchema } from 'yup'; import moment, { Moment, unitOfTime } from 'moment'; declare class MomentDateSchema extends MixedSchema { _validFormats: string[]; constructor({ format, typeError }?: Options$1); _typeCheck(value: unknown): value is Moment; /** * Validate if the date is on or after a specified min */ min(min: string, message?: string): this; /** * Validate if the date is on or before a specified max */ max(max: string, message?: string): this; /** * Validate if the date is between a specified min or max * * For Inlcusivity: `[]` === include & `()` === exclude */ between(min: string, max: string, message?: string, inclusivity?: Inclusivity): this; /** * Set if the field is required and add a custom message */ isRequired(isRequired?: boolean, message?: string): this; } type Inclusivity = '()' | '[)' | '(]' | '[]'; type Options$1 = { format?: string | string[]; typeError?: string; }; declare const avDate: (options?: Options$1) => MomentDateSchema; declare class DateRangeSchema extends MixedSchema { startKey: string; endKey: string; format: string; constructor(options?: Options); /** * Convert the string to a moment object */ getValidDate(value: string | Date | Moment): moment.Moment; /** * Validate based on min and max distance between dates */ distance({ min: { value: minValue, units: minUnits, errorMessage: minErrorMessage }, max: { value: maxValue, units: maxUnits, errorMessage: maxErrorMessage }, }?: DistanceOptions): this; /** * Validate start date is after given min */ min(min: string, message?: string): this; /** * Validate end date is before given max */ max(max: string, message?: string): this; /** * Validate dates are between the set min and max */ between(min: string, max: string, message?: string): this; /** * Set the field to be required or not */ isRequired(isRequired?: boolean, msg?: string): this; typeError({ message }: { message: string; }): this; _typeCheck(range?: { startDate?: Moment; endDate?: Moment; }): range is DateRange; } type Options = { startKey?: string; endKey?: string; format?: string; }; type DateRange = { startDate?: Moment; endDate?: Moment; supportedFormats?: string[]; }; type DistanceValue = { value: number; units?: unitOfTime.DurationConstructor; errorMessage?: string; }; type DistanceOptions = { min?: DistanceValue; max?: DistanceValue; }; declare const dateRange: (opts?: Options) => DateRangeSchema; declare module 'yup' { interface StringSchema = string | undefined, TContext extends AnyObject = AnyObject, TOut extends TType = TType> extends BaseSchema { isRequired(required?: boolean, errorMessage?: string): StringSchema; npi(errorMessage?: string): StringSchema; phone(errorMessage?: string): StringSchema; } interface NumberSchema = number | undefined, TContext extends AnyObject = AnyObject, TOut extends TType = TType> extends BaseSchema { isRequired(required?: boolean, errorMessage?: string): NumberSchema; npi(errorMessage?: string): NumberSchema; phone(errorMessage?: string): NumberSchema; } interface ArraySchema, C extends AnyObject = AnyObject, TIn extends Maybe[]> = TypeOf[] | undefined, TOut extends Maybe[]> = Asserts[] | Optionals> extends BaseSchema { isRequired(required?: boolean, errorMessage?: string): ArraySchema; } interface ObjectSchema> = TypeOfShape, TOut extends Maybe> = AssertsShape | Optionals> extends BaseSchema { isRequired(required?: boolean, errorMessage?: string): ObjectSchema; } } export { avDate, dateRange };