import { DatabaseQueryBuilderContract } from '@adonisjs/lucid/types/querybuilder'; import { Dayjs } from 'dayjs'; import { default as default_2 } from 'knex'; import { Knex } from 'knex'; import { QueryClientContract } from '@adonisjs/lucid/types/database'; export declare namespace address { export { errorCodes, ipRegex, uriRegex, uriDecode, analyzeDomain, isDomainValid, validateDomainOptions, DomainOptions_2 as DomainOptions, Analysis, analyzeEmail, isEmailValid, EmailOptions_2 as EmailOptions } } export declare interface AddRuleOptions { name: string args?: { [key: string]: any } } /** * Schema type for alternatives validation. * * @public */ export declare interface AlternativesSchema extends AnySchema { /** * Adds a conditional alternative schema type, either based on another key value, or a schema peeking into the current value. */ conditional(ref: string | Reference, options: WhenOptions | WhenOptions[]): this; conditional(ref: Schema, options: WhenSchemaOptions): this; /** * Requires the validated value to match a specific set of the provided alternative.try() schemas. * Cannot be combined with `alternatives.conditional()`. */ match(mode: 'any' | 'all' | 'one'): this; /** * Adds an alternative schema type for attempting to match against the validated value. */ try(...types: SchemaLikeWithoutArray[]): this; default(value?: DefaultableValue): this; } declare interface AlternativesSchema_2 extends AnySchema_2 { /** * Adds a conditional alternative schema type, either based on another key value, or a schema peeking into the current value. */ conditional( ref: string | Reference, options: WhenOptions | WhenOptions[] ): AlternativesSchema_2 conditional( ref: Schema_2, options: WhenSchemaOptions ): AlternativesSchema_2 /** * Requires the validated value to match a specific set of the provided alternative.try() schemas. * Cannot be combined with `alternatives.conditional()`. */ match(mode: 'any' | 'all' | 'one'): this /** * Adds an alternative schema type for attempting to match against the validated value. */ try(a: SchemaLikeWithoutArray_2): AlternativesSchema_2 try(a: SchemaLikeWithoutArray_2, b: SchemaLikeWithoutArray_2): AlternativesSchema_2 try( a: SchemaLikeWithoutArray_2, b: SchemaLikeWithoutArray_2, c: SchemaLikeWithoutArray_2 ): AlternativesSchema_2 try( a: SchemaLikeWithoutArray_2, b: SchemaLikeWithoutArray_2, c: SchemaLikeWithoutArray_2, d: SchemaLikeWithoutArray_2 ): AlternativesSchema_2 try( a: SchemaLikeWithoutArray_2, b: SchemaLikeWithoutArray_2, c: SchemaLikeWithoutArray_2, d: SchemaLikeWithoutArray_2, e: SchemaLikeWithoutArray_2 ): AlternativesSchema_2 try( a: SchemaLikeWithoutArray_2, b: SchemaLikeWithoutArray_2, c: SchemaLikeWithoutArray_2, d: SchemaLikeWithoutArray_2, e: SchemaLikeWithoutArray_2, f: SchemaLikeWithoutArray_2 ): AlternativesSchema_2 try(...types: SchemaLikeWithoutArray_2[]): this } declare interface Analysis { /** * The reason validation failed. */ error: string; /** * The error code. */ code: string; } /** * Analyzes a string to verify it is a valid domain name. * * @param domain - the domain name to validate. * @param options - optional settings. * * @return - undefined when valid, otherwise an object with single error key with a string message value. */ declare function analyzeDomain(domain: string, options?: DomainOptions_2): Analysis | null; /** * Analyzes a string to verify it is a valid email address. * * @param email - the email address to validate. * @param options - optional settings. * * @return - undefined when valid, otherwise an object with single error key with a string message value. */ declare function analyzeEmail(email: string, options?: EmailOptions_2): Analysis | null; /** * Base schema type for all validation schemas. * * This interface provides the foundation for all validation schemas with * comprehensive validation methods and options. * * @public */ export declare interface AnySchema extends Omit, '$_addRule' | '$_compile' | '$_modify' | '$_mutateRebuild' | '$_reach' | '$_super' | '$' | 'allow' | 'alter' | 'artifact' | 'bind' | 'cache' | 'cast' | 'concat' | 'custom' | 'default' | 'description' | 'disallow' | 'empty' | 'equal' | 'error' | 'example' | 'exist' | 'external' | 'extract' | 'failover' | 'forbidden' | 'fork' | 'id' | 'invalid' | 'keep' | 'label' | 'message' | 'messages' | 'meta' | 'not' | 'note' | 'only' | 'optional' | 'options' | 'preferences' | 'prefs' | 'presence' | 'raw' | 'required' | 'rule' | 'ruleset' | 'shared' | 'strict' | 'strip' | 'tag' | 'tailor' | 'unit' | 'valid' | 'warn' | 'warning' | 'when'> { /** * Parent schema object. */ $_super: Schema; /** * Adds a rule to current validation schema. */ $_addRule(rule: string | AddRuleOptions): Schema; /** * Internally compiles schema. */ $_compile(schema: SchemaLike, options?: CompileOptions): Schema; $_modify(options?: ModifyOptions): Schema; /** * Resets current schema. */ $_mutateRebuild(): this; /** * Get schema at given path. */ $_reach(path: string[]): Schema; /** * Starts a ruleset in order to apply multiple rule options. The set ends when `rule()`, `keep()`, `message()`, or `warn()` is called. */ $: this; /** * Starts a ruleset in order to apply multiple rule options. The set ends when `rule()`, `keep()`, `message()`, or `warn()` is called. */ ruleset: this; allow(...values: any[]): this; alter(targets: Record Schema>): this; artifact(id: any): this; bind(): this; cache(cache?: Cache): this; concat(schema: this): this; custom(fn: CustomValidator, description?: string): this; description(desc: string): this; disallow(...values: any[]): this; empty(schema?: SchemaLike): this; equal(...values: any[]): this; error(err: Error | ValidationErrorFunction): this; example(value: any, options?: { override: boolean; }): this; exist(): this; external(method: ExternalValidationFunction, description?: string): this; /** * Returns a sub-schema based on a path of object keys or schema ids. * * @param path - a dot `.` separated path string or a pre-split array of path keys. The keys must match the sub-schema id or object key (if no id was explicitly set). */ extract(path: string | string[]): Schema; failover(value: any): this; forbidden(): this; fork(key: string | string[] | string[][], adjuster: SchemaFunction): this; id(name?: string): this; invalid(...values: any[]): this; keep(): this; label(name: string): this; message(message: string): this; messages(messages: LanguageMessages): this; meta(meta: object): this; not(...values: any[]): this; note(...notes: string[]): this; only(): this; optional(): this; options(options: ValidationOptions): this; prefs(options: ValidationOptions): this; preferences(options: ValidationOptions): this; presence(mode: PresenceMode): this; raw(enabled?: boolean): this; required(): this; rule(options: RuleOptions): this; shared(ref: Schema): this; strict(isStrict?: boolean): this; strip(enabled?: boolean): this; tag(...tags: string[]): this; /** * Applies any assigned target alterations to a copy of the schema that were applied via `any.alter()`. */ tailor(targets: string | string[]): Schema; unit(name: string): this; valid(...values: any[]): this; warn(): this; warning(code: string, context: ValidationContext): this; when(ref: string | Reference, options: WhenOptions | WhenOptions[]): this; when(ref: Schema, options: WhenSchemaOptions): this; $_knex: KnexSchemaConnection | undefined; /** * Sets the database connection for database validation rules. * This must be called before using `.uniqueInDb()` or `.existsInDb()`. * * @param connection - A Knex instance, transaction, or connection configuration * * @example * ```typescript * import knex from 'knex' * const db = knex({ client: 'pg', connection: {...} }) * const schema = joi.string().knex(db).uniqueInDb('users', 'email') * ``` */ knex(connection: KnexSchemaConnection): this; /** * Alias for `.knex()`. Sets the database connection for database validation rules. * * @param connection - A Knex instance, transaction, or connection configuration */ db(connection: KnexSchemaConnection): this; /** * Validates that the value is unique in the specified database table and column. * Requires `.knex()` or `.db()` to be called first to set the database connection. * * @param table - The database table name (can be a Joi reference) * @param column - The column name to check (can be a Joi reference) * @param options - Optional configuration: * - `caseInsensitive`: Perform case-insensitive comparison (default: false) * - `filter`: Async function to add additional WHERE clauses to the query * * @example * ```typescript * const schema = joi.object({ * email: joi.string().email().knex(db).uniqueInDb('users', 'email'), * username: joi.string().knex(db).uniqueInDb('users', 'username', { * caseInsensitive: true, * filter: async (query) => query.where('tenant_id', tenantId) * }) * }) * ``` */ uniqueInDb(table: string | Reference, column: string | Reference, options?: DbValidationOptions): this; /** * Validates that the value exists in the specified database table and column. * Requires `.knex()` or `.db()` to be called first to set the database connection. * * @param table - The database table name (can be a Joi reference) * @param column - The column name to check (can be a Joi reference) * @param options - Optional configuration: * - `caseInsensitive`: Perform case-insensitive comparison (default: false) * - `filter`: Async function to add additional WHERE clauses to the query * * @example * ```typescript * const schema = joi.object({ * country_id: joi.number().knex(db).existsInDb('countries', 'id'), * category: joi.string().knex(db).existsInDb('categories', 'name', { * caseInsensitive: true * }) * }) * ``` */ existsInDb(table: string | Reference, column: string | Reference, options?: DbValidationOptions): this; /** * Sets a default value if the original value is `undefined`. * * @param value - The default value. Can be: * - A literal value (string, number, object, etc.) * - A reference to another schema value * - A function that returns the default value with signature `(parent, helpers) => value` * - `parent` - A clone of the object containing the value being validated * - `helpers` - Validation helper functions for custom validation logic * * @example * ```typescript * const schema = joi.string().default('hello world') * const schemaWithFunction = joi.number().default((parent, helpers) => parent.someOtherField * 2) * ``` */ default(value?: DefaultableValue): this; cast(to: 'map' | 'number' | 'set' | 'string' | 'object'): this; } declare interface AnySchema_2 extends SchemaInternals, StandardSchemaV1 { /** * Flags of current schema. */ _flags: Record /** * Starts a ruleset in order to apply multiple rule options. The set ends when `rule()`, `keep()`, `message()`, or `warn()` is called. */ $: this /** * Starts a ruleset in order to apply multiple rule options. The set ends when `rule()`, `keep()`, `message()`, or `warn()` is called. */ ruleset: this type?: Types | string /** * Whitelists a value */ allow(...values: any[]): this /** * Assign target alteration options to a schema that are applied when `any.tailor()` is called. * @param targets - an object where each key is a target name, and each value is a function that takes an schema and returns an schema. */ alter(targets: Record Schema_2>): this /** * Assigns the schema an artifact id which is included in the validation result if the rule passed validation. * @param id - any value other than undefined which will be returned as-is in the result artifacts map. */ artifact(id: any): this /** * By default, some Joi methods to function properly need to rely on the Joi instance they are attached to because * they use `this` internally. * So `Joi.string()` works but if you extract the function from it and call `string()` it won't. * `bind()` creates a new Joi instance where all the functions relying on `this` are bound to the Joi instance. */ bind(): this /** * Adds caching to the schema which will attempt to cache the validation results (success and failures) of incoming inputs. * If no cache is passed, a default cache is provisioned by using `cache.provision()` internally. */ cache(cache?: Cache): this /** * Casts the validated value to the specified type. */ cast(to: 'map' | 'number' | 'set' | 'string'): this /** * Returns a new type that is the result of adding the rules of one type to another. */ concat(schema: this): this /** * Adds a custom validation function. */ custom(fn: CustomValidator, description?: string): this /** * Sets a default value if the original value is `undefined` where: * @param value - the default value. One of: * - a literal value (string, number, object, etc.) * - a [references](#refkey-options) * - a function which returns the default value using the signature `function(parent, helpers)` where: * - `parent` - a clone of the object containing the value being validated. Note that since specifying a * `parent` argument performs cloning, do not declare format arguments if you are not using them. * - `helpers` - same as those described in [`any.custom()`](anycustomermethod_description) * * When called without any `value` on an object schema type, a default value will be automatically generated * based on the default values of the object keys. * * Note that if value is an object, any changes to the object after `default()` is called will change the * reference and any future assignment. */ default( value?: BasicType | Reference | ((parent: any, helpers: CustomHelpers) => BasicType | Reference) ): this /** * Returns a plain object representing the schema's rules and properties */ describe(): Description /** * Annotates the key */ description(desc: string): this /** * Disallows values. */ disallow(...values: any[]): this /** * Considers anything that matches the schema to be empty (undefined). Overrides any previous calls to empty. * @param schema - an object, value, or joi schema to match or an array of objects, values, and joi schemas to match. An undefined schema unsets that rule. */ empty(schema?: SchemaLike_2): this /** * Adds the provided values into the allowed whitelist and marks them as the only valid values allowed. */ equal(...values: any[]): this /** * Overrides the default joi error with a custom error if the rule fails where: * @param err - can be: * an instance of `Error` - the override error. * a `function(errors)`, taking an array of errors as argument, where it must either: * return a `string` - substitutes the error message with this text * return a single ` object` or an `Array` of it, where: * `type` - optional parameter providing the type of the error (eg. `number.min`). * `message` - optional parameter if `template` is provided, containing the text of the error. * `template` - optional parameter if `message` is provided, containing a template string, using the same format as usual joi language errors. * `context` - optional parameter, to provide context to your error if you are using the `template`. * return an `Error` - same as when you directly provide an `Error`, but you can customize the error message based on the errors. * * Note that if you provide an `Error`, it will be returned as-is, unmodified and undecorated with any of the * normal joi error properties. If validation fails and another error is found before the error * override, that error will be returned and the override will be ignored (unless the `abortEarly` * option has been set to `false`). */ error(err: Error | ValidationErrorFunction): this /** * Annotates the key with an example value, must be valid. */ example(value: any, options?: { override: boolean }): this /** * Marks a key as required which will not allow undefined as value. All keys are optional by default. */ exist(): this /** * Adds an external validation rule. * * Note that external validation rules are only called after the all other validation rules for the entire schema (from the value root) are checked. * This means that any changes made to the value by the external rules are not available to any other validation rules during the non-external validation phase. * If schema validation failed, no external validation rules are called. */ external(method: ExternalValidationFunction, description?: string): this /** * Returns a sub-schema based on a path of object keys or schema ids. * * @param path - a dot `.` separated path string or a pre-split array of path keys. The keys must match the sub-schema id or object key (if no id was explicitly set). */ extract(path: string | string[]): Schema_2 /** * Sets a failover value if the original value fails passing validation. * * @param value - the failover value. value supports references. value may be assigned a function which returns the default value. * * If value is specified as a function that accepts a single parameter, that parameter will be a context object that can be used to derive the resulting value. * Note that if value is an object, any changes to the object after `failover()` is called will change the reference and any future assignment. * Use a function when setting a dynamic value (e.g. the current time). * Using a function with a single argument performs some internal cloning which has a performance impact. * If you do not need access to the context, define the function without any arguments. */ failover(value: any): this /** * Marks a key as forbidden which will not allow any value except undefined. Used to explicitly forbid keys. */ forbidden(): this /** * Returns a new schema where each of the path keys listed have been modified. * * @param key - an array of key strings, a single key string, or an array of arrays of pre-split key strings. * @param adjuster - a function which must return a modified schema. */ fork(key: string | string[] | string[][], adjuster: SchemaFunction_2): this /** * Sets a schema id for reaching into the schema via `any.extract()`. * If no id is set, the schema id defaults to the object key it is associated with. * If the schema is used in an array or alternatives type and no id is set, the schema in unreachable. */ id(name?: string): this /** * Disallows values. */ invalid(...values: any[]): this /** * Returns a boolean indicating whether this schema contains a rule that requires asynchronous validation. */ isAsync(): boolean /** * Same as `rule({ keep: true })`. * * Note that `keep()` will terminate the current ruleset and cannot be followed by another rule option. * Use `rule()` to apply multiple rule options. */ keep(): this /** * Overrides the key name in error messages. */ label(name: string): this /** * Same as `rule({ message })`. * * Note that `message()` will terminate the current ruleset and cannot be followed by another rule option. * Use `rule()` to apply multiple rule options. */ message(message: string): this /** * Same as `any.prefs({ messages })`. * Note that while `any.message()` applies only to the last rule or ruleset, `any.messages()` applies to the entire schema. */ messages(messages: LanguageMessages): this /** * Attaches metadata to the key. */ meta(meta: object): this /** * Disallows values. */ not(...values: any[]): this /** * Annotates the key */ note(...notes: string[]): this /** * Requires the validated value to match of the provided `any.allow()` values. * It has not effect when called together with `any.valid()` since it already sets the requirements. * When used with `any.allow()` it converts it to an `any.valid()`. */ only(): this /** * Marks a key as optional which will allow undefined as values. Used to annotate the schema for readability as all keys are optional by default. */ optional(): this /** * Overrides the global validate() options for the current key and any sub-key. */ options(options: ValidationOptions): this /** * Overrides the global validate() options for the current key and any sub-key. */ prefs(options: ValidationOptions): this /** * Overrides the global validate() options for the current key and any sub-key. */ preferences(options: ValidationOptions): this /** * Sets the presence mode for the schema. */ presence(mode: PresenceMode): this /** * Outputs the original untouched value instead of the casted value. */ raw(enabled?: boolean): this /** * Marks a key as required which will not allow undefined as value. All keys are optional by default. */ required(): this /** * Applies a set of rule options to the current ruleset or last rule added. * * When applying rule options, the last rule (e.g. `min()`) is used unless there is an active ruleset defined (e.g. `$.min().max()`) * in which case the options are applied to all the provided rules. * Once `rule()` is called, the previous rules can no longer be modified and any active ruleset is terminated. * * Rule modifications can only be applied to supported rules. * Most of the `any` methods do not support rule modifications because they are implemented using schema flags (e.g. `required()`) or special * internal implementation (e.g. `valid()`). * In those cases, use the `any.messages()` method to override the error codes for the errors you want to customize. */ rule(options: RuleOptions): this /** * Registers a schema to be used by descendants of the current schema in named link references. */ shared(ref: Schema_2): this /** * Sets the options.convert options to false which prevent type casting for the current key and any child keys. */ strict(IsStrict?: boolean): this /** * Marks a key to be removed from a resulting object or array after validation. Used to sanitize output. * @param [enabled=true] - if true, the value is stripped, otherwise the validated value is retained. Defaults to true. */ strip(enabled?: boolean): this /** * Annotates the key */ tag(...tags: string[]): this /** * Applies any assigned target alterations to a copy of the schema that were applied via `any.alter()`. */ tailor(targets: string | string[]): Schema_2 /** * Annotates the key with an unit name. */ unit(name: string): this /** * Adds the provided values into the allowed whitelist and marks them as the only valid values allowed. */ valid(...values: any[]): this /** * Validates a value using the schema and options. */ validate(value: any, options?: ValidationOptions): ValidationResult /** * Validates a value using the schema and options. */ validateAsync( value: any, options?: TOpts ): Promise< TOpts extends { artifacts: true } | { warnings: true } ? { value: TSchema } & (TOpts extends { artifacts: true } ? { artifacts: Map } : {}) & (TOpts extends { warnings: true } ? { warning: ValidationWarning } : {}) : TSchema > /** * Same as `rule({ warn: true })`. * Note that `warn()` will terminate the current ruleset and cannot be followed by another rule option. * Use `rule()` to apply multiple rule options. */ warn(): this /** * Generates a warning. * When calling `any.validateAsync()`, set the `warning` option to true to enable warnings. * Warnings are reported separately from errors alongside the result value via the warning key (i.e. `{ value, warning }`). * Warning are always included when calling `any.validate()`. */ warning(code: string, context: ValidationContext): this /** * Converts the type into an alternatives type where the conditions are merged into the type definition where: */ when(ref: string | Reference, options: WhenOptions | WhenOptions[]): this /** * Converts the type into an alternatives type where the conditions are merged into the type definition where: */ when(ref: Schema_2, options: WhenSchemaOptions): this } /** * Schema type for array validation. * * @public */ export declare interface ArraySchema extends AnySchema { /** * Verifies that an assertion passes for at least one item in the array, where: * `schema` - the validation rules required to satisfy the assertion. If the `schema` includes references, they are resolved against * the array item being tested, not the value of the `ref` target. */ has(schema: SchemaLike): this; /** * Specifies the exact number of items in the array. */ length(limit: number | Reference): this; /** * Specifies the maximum number of items in the array. */ max(limit: number | Reference): this; /** * Specifies the minimum number of items in the array. */ min(limit: number | Reference): this; /** * Allow single values to be checked against rules as if it were provided as an array. * enabled can be used with a falsy value to go back to the default behavior. */ single(enabled?: any): this; /** * Sorts the array by given order. */ sort(options?: ArraySortOptions): this; /** * Allow this array to be sparse. * enabled can be used with a falsy value to go back to the default behavior. */ sparse(enabled?: any): this; /** * Requires the array values to be unique. * Remember that if you provide a custom comparator function, * different types can be passed as parameter depending on the rules you set on items. * Be aware that a deep equality is performed on elements of the array having a type of object, * a performance penalty is to be expected for this kind of operation. */ unique(comparator?: string | ComparatorFunction, options?: ArrayUniqueOptions): this; /** * Sets a default value if the original value is `undefined`. * * @param value - The default value. Can be: * - A literal array value * - A reference to another schema value * - A function that returns the default value with signature `(parent, helpers) => value` * - `parent` - A clone of the object containing the value being validated * - `helpers` - Validation helper functions for custom validation logic */ default(value?: DefaultableValue): this; /** * List the types allowed for the array values. * If a given type is .required() then there must be a matching item in the array. * If a type is .forbidden() then it cannot appear in the array. * Required items can be added multiple times to signify that multiple items must be found. * Errors will contain the number of items that didn't match. * Any unmatched item having a label will be mentioned explicitly. * * @param type - a joi schema object to validate each array item against. */ items(...types: SchemaLikeWithoutArray[]): this; /** * Lists the types in sequence order for the array values where: * @param type - a joi schema object to validate against each array item in sequence order. type can be multiple values passed as individual arguments. * If a given type is .required() then there must be a matching item with the same index position in the array. * Errors will contain the number of items that didn't match. * Any unmatched item having a label will be mentioned explicitly. */ ordered(...types: SchemaLikeWithoutArray[]): this; } declare interface ArraySchema_2 extends AnySchema_2 { /** * Verifies that an assertion passes for at least one item in the array, where: * `schema` - the validation rules required to satisfy the assertion. If the `schema` includes references, they are resolved against * the array item being tested, not the value of the `ref` target. */ has(schema: SchemaLike_2): this /** * List the types allowed for the array values. * If a given type is .required() then there must be a matching item in the array. * If a type is .forbidden() then it cannot appear in the array. * Required items can be added multiple times to signify that multiple items must be found. * Errors will contain the number of items that didn't match. * Any unmatched item having a label will be mentioned explicitly. * * @param type - a joi schema object to validate each array item against. */ items(a: SchemaLikeWithoutArray_2): ArraySchema_2 items(a: SchemaLikeWithoutArray_2, b: SchemaLikeWithoutArray_2): ArraySchema_2<(A | B)[]> items( a: SchemaLikeWithoutArray_2, b: SchemaLikeWithoutArray_2, c: SchemaLikeWithoutArray_2 ): ArraySchema_2<(A | B | C)[]> items( a: SchemaLikeWithoutArray_2, b: SchemaLikeWithoutArray_2, c: SchemaLikeWithoutArray_2, d: SchemaLikeWithoutArray_2 ): ArraySchema_2<(A | B | C | D)[]> items( a: SchemaLikeWithoutArray_2, b: SchemaLikeWithoutArray_2, c: SchemaLikeWithoutArray_2, d: SchemaLikeWithoutArray_2, e: SchemaLikeWithoutArray_2 ): ArraySchema_2<(A | B | C | D | E)[]> items( a: SchemaLikeWithoutArray_2, b: SchemaLikeWithoutArray_2, c: SchemaLikeWithoutArray_2, d: SchemaLikeWithoutArray_2, e: SchemaLikeWithoutArray_2, f: SchemaLikeWithoutArray_2 ): ArraySchema_2<(A | B | C | D | E | F)[]> items< TItems, TTItems extends SchemaLikeWithoutArray_2[] = SchemaLikeWithoutArray_2[], >( ...types: NoNestedArrays ): ArraySchema_2< { [I in keyof TTItems]: UnwrapSchemaLikeWithoutArray }[number][] > /** * Specifies the exact number of items in the array. */ length(limit: number | Reference): this /** * Specifies the maximum number of items in the array. */ max(limit: number | Reference): this /** * Specifies the minimum number of items in the array. */ min(limit: number | Reference): this /** * Lists the types in sequence order for the array values where: * @param type - a joi schema object to validate against each array item in sequence order. type can be multiple values passed as individual arguments. * If a given type is .required() then there must be a matching item with the same index position in the array. * Errors will contain the number of items that didn't match. * Any unmatched item having a label will be mentioned explicitly. */ ordered(...types: SchemaLikeWithoutArray_2[]): this /** * Allow single values to be checked against rules as if it were provided as an array. * enabled can be used with a falsy value to go back to the default behavior. */ single(enabled?: any): this /** * Sorts the array by given order. */ sort(options?: ArraySortOptions): this /** * Allow this array to be sparse. * enabled can be used with a falsy value to go back to the default behavior. */ sparse(enabled?: any): this /** * Requires the array values to be unique. * Remember that if you provide a custom comparator function, * different types can be passed as parameter depending on the rules you set on items. * Be aware that a deep equality is performed on elements of the array having a type of object, * a performance penalty is to be expected for this kind of operation. */ unique(comparator?: string | ComparatorFunction, options?: ArrayUniqueOptions): this } export declare interface ArraySortOptions { /** * @default 'ascending' */ order?: 'ascending' | 'descending' by?: string | Reference } export declare interface ArrayUniqueOptions extends HierarchySeparatorOptions { /** * if true, undefined values for the dot notation string comparator will not cause the array to fail on uniqueness. * * @default false */ ignoreUndefined?: boolean } export declare interface AsyncValidationOptions extends ValidationOptions { /** * when true, artifacts are returned alongside the value (i.e. `{ value, artifacts }`) * * @default false */ artifacts?: boolean /** * when true, warnings are returned alongside the value (i.e. `{ value, warning }`). * * @default false */ warnings?: boolean } export declare interface Base64Options extends Pick { /** * if true, uses the URI-safe base64 format which replaces `+` with `-` and `\` with `_`. * * @default false */ urlSafe?: boolean } export declare interface BaseValidationOptions { /** * when true, stops validation on the first error, otherwise returns all the errors found. * * @default true */ abortEarly?: boolean /** * when true, allows object to contain unknown keys which are ignored. * * @default false */ allowUnknown?: boolean /** * when true, return artifacts alongside the value. * * @default false */ artifacts?: boolean /** * when true, schema caching is enabled (for schemas with explicit caching rules). * * @default false */ cache?: boolean /** * provides an external data set to be used in references */ context?: ValidationContext /** * when true, attempts to cast values to the required types (e.g. a string to a number). * * @default true */ convert?: boolean /** * sets the string format used when converting dates to strings in error messages and casting. * * @default 'iso' */ dateFormat?: 'date' | 'iso' | 'string' | 'time' | 'utc' /** * when true, valid results and throw errors are decorated with a debug property which includes an array of the validation steps used to generate the returned result. * * @default false */ debug?: boolean /** * error formatting settings. */ errors?: ErrorFormattingOptions /** * if false, the external rules set with `any.external()` are ignored, which is required to ignore any external validations in synchronous mode (or an exception is thrown). * * @default true */ externals?: boolean /** * when true, do not apply default values. * * @default false */ noDefaults?: boolean /** * when true, inputs are shallow cloned to include non-enumerable properties. * * @default false */ nonEnumerables?: boolean /** * sets the default presence requirements. Supported modes: 'optional', 'required', and 'forbidden'. * * @default 'optional' */ presence?: PresenceMode /** * when true, ignores unknown keys with a function value. * * @default false */ skipFunctions?: boolean /** * remove unknown elements from objects and arrays. * - when true, all unknown elements will be removed * - when an object: * - objects - set to true to remove unknown keys from objects * * @default false */ stripUnknown?: boolean | { arrays?: boolean; objects?: boolean } } export declare type BasicType = boolean | number | string | any[] | object | null /** * Schema type for BigInt validation with comprehensive comparison operations. * * This interface extends the base Joi AnySchema to provide BigInt-specific * validation methods including range checks, sign validation, and multiple checks. * * @example * ```typescript * import { validator } from '@nhtio/validation' * * const schema: BigIntSchema = validator.bigint() * .min(0n) * .max(1000n) * .positive() * ``` * * @public */ export declare interface BigIntSchema extends AnySchema { /** * Validates that the BigInt is greater than the specified threshold * @param limit - The threshold value to compare against */ greater(limit: bigint | Reference): this; /** * Validates that the BigInt is less than the specified threshold * @param limit - The threshold value to compare against */ less(limit: bigint | Reference): this; /** * Validates that the BigInt is less than or equal to the specified maximum * @param limit - The maximum allowed value */ max(limit: bigint | Reference): this; /** * Validates that the BigInt is greater than or equal to the specified minimum * @param limit - The minimum allowed value */ min(limit: bigint | Reference): this; /** * Validates that the BigInt is a multiple of the specified factor * @param limit - The factor that the value must be a multiple of */ multiple(limit: bigint | Reference): this; /** * Validates that the BigInt is negative (less than zero) */ negative(): this; /** * Validates that the BigInt is positive (greater than zero) */ positive(): this; } /** * Schema type for binary data validation. * * @public */ export declare interface BinarySchema extends AnySchema { /** * Sets the string encoding format if a string input is converted to a buffer. */ encoding(encoding: string): this; /** * Specifies the minimum length of the buffer. */ min(limit: number | Reference): this; /** * Specifies the maximum length of the buffer. */ max(limit: number | Reference): this; /** * Specifies the exact length of the buffer: */ length(limit: number | Reference): this; /** * Sets a default value if the original value is `undefined`. * * @param value - The default value. Can be: * - A literal binary value (Buffer, Uint8Array, etc.) * - A reference to another schema value * - A function that returns the default value with signature `(parent, helpers) => value` * - `parent` - A clone of the object containing the value being validated * - `helpers` - Validation helper functions for custom validation logic */ default(value?: DefaultableValue): this; } declare interface BinarySchema_2 extends AnySchema_2 { /** * Sets the string encoding format if a string input is converted to a buffer. */ encoding(encoding: string): this /** * Specifies the minimum length of the buffer. */ min(limit: number | Reference): this /** * Specifies the maximum length of the buffer. */ max(limit: number | Reference): this /** * Specifies the exact length of the buffer: */ length(limit: number | Reference): this } /** * Schema type for boolean validation. * * @public */ export declare interface BooleanSchema extends AnySchema { falsy(...values: Array): this; sensitive(enabled?: boolean): this; truthy(...values: Array): this; /** * Sets a default value if the original value is `undefined`. * * @param value - The default value. Can be: * - A literal boolean value * - A reference to another schema value * - A function that returns the default value with signature `(parent, helpers) => value` * - `parent` - A clone of the object containing the value being validated * - `helpers` - Validation helper functions for custom validation logic */ default(value?: DefaultableValue): this; } declare interface BooleanSchema_2 extends AnySchema_2 { /** * Allows for additional values to be considered valid booleans by converting them to false during validation. * String comparisons are by default case insensitive, * see `boolean.sensitive()` to change this behavior. * @param values - strings, numbers or arrays of them */ falsy(...values: Array): this /** * Allows the values provided to truthy and falsy as well as the "true" and "false" default conversion * (when not in `strict()` mode) to be matched in a case insensitive manner. */ sensitive(enabled?: boolean): this /** * Allows for additional values to be considered valid booleans by converting them to true during validation. * String comparisons are by default case insensitive, see `boolean.sensitive()` to change this behavior. * @param values - strings, numbers or arrays of them */ truthy(...values: Array): this } export declare interface Cache { /** * Add an item to the cache. * * Note that key and value can be anything including objects, array, etc. */ set(key: any, value: any): void /** * Retrieve an item from the cache. * * Note that key and value can be anything including objects, array, etc. */ get(key: any): any } export declare interface CacheConfiguration { /** * Provisions a simple LRU cache for caching simple inputs (`undefined`, `null`, strings, numbers, and booleans). */ provision(options?: CacheProvisionOptions): void } export declare interface CacheProvisionOptions { /** * number of items to store in the cache before the least used items are dropped. * * @default 1000 */ max: number } declare type CalendarSystem = Intl.DateTimeFormatOptions extends { calendar?: infer T } ? T : | "buddhist" | "chinese" | "coptic" | "ethioaa" | "ethiopic" | "gregory" | "hebrew" | "indian" | "islamic" | "islamicc" | "iso8601" | "japanese" | "persian" | "roc"; declare type CalendarSystem_2 = Intl.DateTimeFormatOptions extends { calendar?: infer T } ? T : | "buddhist" | "chinese" | "coptic" | "ethioaa" | "ethiopic" | "gregory" | "hebrew" | "indian" | "islamic" | "islamicc" | "iso8601" | "japanese" | "persian" | "roc"; declare type CallbackOrValue = T | ((dt: DateTime, helpers: CustomHelpers) => T); declare type CanBeInvalid = TSSettings extends { throwOnInvalid: true } ? false : true; declare type CanBeInvalid_2 = TSSettings_2 extends { throwOnInvalid: true } ? false : true; declare type Cidr = 'optional' | 'required' | 'forbidden'; export declare type CoerceFunction = (value: any, helpers: CustomHelpers) => CoerceResult export declare interface CoerceObject { method: CoerceFunction from?: string | string[] } export declare interface CoerceResult { errors?: ErrorReport[] value?: any } export declare type ComparatorFunction = (a: any, b: any) => boolean export declare interface CompileOptions { /** * If true and the provided schema is (or contains parts) using an older version of joi, will return a compiled schema that is compatible with the older version. * If false, the schema is always compiled using the current version and if older schema components are found, an error is thrown. */ legacy: boolean } export declare interface Context { [key: string]: any; key?: string; label?: string; value?: any; } declare type ConversionAccuracy = "casual" | "longterm"; declare type ConversionAccuracy_2 = "casual" | "longterm"; declare type CountOptions = _UseLocaleWeekOption; declare type CountOptions_2 = _UseLocaleWeekOption_2; /** * Represents the ISO 3166-1 alpha-2 country codes of all countries recognized by the library. */ export declare type Country = 'AD' | 'AE' | 'AF' | 'AG' | 'AI' | 'AL' | 'AM' | 'AO' | 'AQ' | 'AR' | 'AS' | 'AT' | 'AU' | 'AW' | 'AX' | 'AZ' | 'BA' | 'BB' | 'BD' | 'BE' | 'BF' | 'BG' | 'BH' | 'BI' | 'BJ' | 'BL' | 'BM' | 'BN' | 'BO' | 'BQ' | 'BR' | 'BS' | 'BT' | 'BV' | 'BW' | 'BY' | 'BZ' | 'CA' | 'CC' | 'CD' | 'CF' | 'CG' | 'CH' | 'CI' | 'CK' | 'CL' | 'CM' | 'CN' | 'CO' | 'CR' | 'CU' | 'CV' | 'CW' | 'CX' | 'CY' | 'CZ' | 'DE' | 'DJ' | 'DK' | 'DM' | 'DO' | 'DZ' | 'EC' | 'EE' | 'EG' | 'EH' | 'ER' | 'ES' | 'ET' | 'FI' | 'FJ' | 'FK' | 'FM' | 'FO' | 'FR' | 'GA' | 'GB' | 'GD' | 'GE' | 'GF' | 'GG' | 'GH' | 'GI' | 'GL' | 'GM' | 'GN' | 'GP' | 'GQ' | 'GR' | 'GS' | 'GT' | 'GU' | 'GW' | 'GY' | 'HK' | 'HM' | 'HN' | 'HR' | 'HT' | 'HU' | 'ID' | 'IE' | 'IL' | 'IM' | 'IN' | 'IO' | 'IQ' | 'IR' | 'IS' | 'IT' | 'JE' | 'JM' | 'JO' | 'JP' | 'KE' | 'KG' | 'KH' | 'KI' | 'KM' | 'KN' | 'KP' | 'KR' | 'KW' | 'KY' | 'KZ' | 'LA' | 'LB' | 'LC' | 'LI' | 'LK' | 'LR' | 'LS' | 'LT' | 'LU' | 'LV' | 'LY' | 'MA' | 'MC' | 'MD' | 'ME' | 'MF' | 'MG' | 'MH' | 'MK' | 'ML' | 'MM' | 'MN' | 'MO' | 'MP' | 'MQ' | 'MR' | 'MS' | 'MT' | 'MU' | 'MV' | 'MW' | 'MX' | 'MY' | 'MZ' | 'NA' | 'NC' | 'NE' | 'NF' | 'NG' | 'NI' | 'NL' | 'NO' | 'NP' | 'NR' | 'NU' | 'NZ' | 'OM' | 'PA' | 'PE' | 'PF' | 'PG' | 'PH' | 'PK' | 'PL' | 'PM' | 'PN' | 'PR' | 'PS' | 'PT' | 'PW' | 'PY' | 'QA' | 'RE' | 'RO' | 'RS' | 'RU' | 'RW' | 'SA' | 'SB' | 'SC' | 'SD' | 'SE' | 'SG' | 'SH' | 'SI' | 'SJ' | 'SK' | 'SL' | 'SM' | 'SN' | 'SO' | 'SR' | 'SS' | 'ST' | 'SV' | 'SX' | 'SY' | 'SZ' | 'TC' | 'TD' | 'TF' | 'TG' | 'TH' | 'TJ' | 'TK' | 'TL' | 'TM' | 'TN' | 'TO' | 'TR' | 'TT' | 'TV' | 'TW' | 'TZ' | 'UA' | 'UG' | 'UM' | 'US' | 'UY' | 'UZ' | 'VA' | 'VC' | 'VE' | 'VG' | 'VI' | 'VN' | 'VU' | 'WF' | 'WS' | 'XK' | 'YE' | 'YT' | 'ZA' | 'ZM' | 'ZW'; /** * Represents either the ISO 3166-1 alpha-2 country codes of all countries recognized by the library or the string `'XX'` to represent an unknown country. */ export declare type CountryOrUnknown = Country | 'XX'; /** * Represents the possible timezones of all countries recognized by the library. */ declare type CountryTimezone = 'Europe/Andorra' | 'Asia/Dubai' | 'Asia/Kabul' | 'America/Antigua' | 'America/Anguilla' | 'Europe/Tirane' | 'Asia/Yerevan' | 'Africa/Luanda' | 'Antarctica/Casey' | 'America/Argentina/Buenos_Aires' | 'Pacific/Pago_Pago' | 'Europe/Vienna' | 'Australia/Sydney' | 'America/Aruba' | 'Europe/Mariehamn' | 'Asia/Baku' | 'Europe/Sarajevo' | 'America/Barbados' | 'Asia/Dhaka' | 'Europe/Brussels' | 'Africa/Ouagadougou' | 'Europe/Sofia' | 'Asia/Bahrain' | 'Africa/Bujumbura' | 'Africa/Porto-Novo' | 'America/St_Barthelemy' | 'Atlantic/Bermuda' | 'Asia/Brunei' | 'America/La_Paz' | 'America/Kralendijk' | 'America/Sao_Paulo' | 'America/Nassau' | 'Asia/Thimphu' | 'Africa/Gaborone' | 'Europe/Minsk' | 'America/Belize' | 'America/Toronto' | 'Indian/Cocos' | 'Africa/Kinshasa' | 'Africa/Bangui' | 'Africa/Brazzaville' | 'Europe/Zurich' | 'Africa/Abidjan' | 'Pacific/Rarotonga' | 'America/Santiago' | 'Africa/Douala' | 'Asia/Shanghai' | 'America/Bogota' | 'America/Costa_Rica' | 'America/Havana' | 'Atlantic/Cape_Verde' | 'America/Curacao' | 'Indian/Christmas' | 'Asia/Nicosia' | 'Europe/Prague' | 'Europe/Berlin' | 'Africa/Djibouti' | 'Europe/Copenhagen' | 'America/Dominica' | 'America/Santo_Domingo' | 'Africa/Algiers' | 'America/Guayaquil' | 'Europe/Tallinn' | 'Africa/Cairo' | 'Africa/El_Aaiun' | 'Africa/Asmara' | 'Europe/Madrid' | 'Africa/Addis_Ababa' | 'Europe/Helsinki' | 'Pacific/Fiji' | 'Atlantic/Stanley' | 'Pacific/Pohnpei' | 'Atlantic/Faroe' | 'Europe/Paris' | 'Africa/Libreville' | 'Europe/London' | 'America/Grenada' | 'Asia/Tbilisi' | 'America/Cayenne' | 'Europe/Guernsey' | 'Africa/Accra' | 'Europe/Gibraltar' | 'America/Godthab' | 'Africa/Banjul' | 'Africa/Conakry' | 'America/Guadeloupe' | 'Africa/Malabo' | 'Europe/Athens' | 'Atlantic/South_Georgia' | 'America/Guatemala' | 'Pacific/Guam' | 'Africa/Bissau' | 'America/Guyana' | 'Asia/Hong_Kong' | 'America/Tegucigalpa' | 'Europe/Zagreb' | 'America/Port-au-Prince' | 'Europe/Budapest' | 'Asia/Jakarta' | 'Europe/Dublin' | 'Asia/Jerusalem' | 'Europe/Isle_of_Man' | 'Asia/Kolkata' | 'Indian/Chagos' | 'Asia/Baghdad' | 'Asia/Tehran' | 'Atlantic/Reykjavik' | 'Europe/Rome' | 'Europe/Jersey' | 'America/Jamaica' | 'Asia/Amman' | 'Asia/Tokyo' | 'Africa/Nairobi' | 'Asia/Bishkek' | 'Asia/Phnom_Penh' | 'Pacific/Tarawa' | 'Indian/Comoro' | 'America/St_Kitts' | 'Asia/Pyongyang' | 'Asia/Seoul' | 'Asia/Kuwait' | 'America/Cayman' | 'Asia/Almaty' | 'Asia/Vientiane' | 'Asia/Beirut' | 'America/St_Lucia' | 'Europe/Vaduz' | 'Asia/Colombo' | 'Africa/Monrovia' | 'Africa/Maseru' | 'Europe/Vilnius' | 'Europe/Luxembourg' | 'Europe/Riga' | 'Africa/Tripoli' | 'Africa/Casablanca' | 'Europe/Monaco' | 'Europe/Chisinau' | 'Europe/Podgorica' | 'America/Marigot' | 'Indian/Antananarivo' | 'Pacific/Majuro' | 'Europe/Skopje' | 'Africa/Bamako' | 'Asia/Yangon' | 'Asia/Ulaanbaatar' | 'Asia/Macau' | 'Pacific/Saipan' | 'America/Martinique' | 'Africa/Nouakchott' | 'America/Montserrat' | 'Europe/Malta' | 'Indian/Mauritius' | 'Indian/Maldives' | 'Africa/Blantyre' | 'America/Mexico_City' | 'Asia/Kuala_Lumpur' | 'Africa/Maputo' | 'Africa/Windhoek' | 'Pacific/Noumea' | 'Africa/Niamey' | 'Pacific/Norfolk' | 'Africa/Lagos' | 'America/Managua' | 'Europe/Amsterdam' | 'Europe/Oslo' | 'Asia/Kathmandu' | 'Pacific/Nauru' | 'Pacific/Niue' | 'Pacific/Auckland' | 'Asia/Muscat' | 'America/Panama' | 'America/Lima' | 'Pacific/Tahiti' | 'Pacific/Port_Moresby' | 'Asia/Manila' | 'Asia/Karachi' | 'Europe/Warsaw' | 'America/Miquelon' | 'Pacific/Pitcairn' | 'America/Puerto_Rico' | 'Asia/Gaza' | 'Europe/Lisbon' | 'Pacific/Palau' | 'America/Asuncion' | 'Asia/Qatar' | 'Indian/Reunion' | 'Europe/Bucharest' | 'Europe/Belgrade' | 'Europe/Moscow' | 'Africa/Kigali' | 'Asia/Riyadh' | 'Pacific/Guadalcanal' | 'Indian/Mahe' | 'Africa/Khartoum' | 'Europe/Stockholm' | 'Asia/Singapore' | 'Atlantic/St_Helena' | 'Europe/Ljubljana' | 'Arctic/Longyearbyen' | 'Europe/Bratislava' | 'Africa/Freetown' | 'Europe/San_Marino' | 'Africa/Dakar' | 'Africa/Mogadishu' | 'America/Paramaribo' | 'Africa/Juba' | 'Africa/Sao_Tome' | 'America/El_Salvador' | 'America/Lower_Princes' | 'Asia/Damascus' | 'Africa/Mbabane' | 'America/Grand_Turk' | 'Africa/Ndjamena' | 'Indian/Kerguelen' | 'Africa/Lome' | 'Asia/Bangkok' | 'Asia/Dushanbe' | 'Pacific/Fakaofo' | 'Asia/Dili' | 'Asia/Ashgabat' | 'Africa/Tunis' | 'Pacific/Tongatapu' | 'Europe/Istanbul' | 'America/Port_of_Spain' | 'Pacific/Funafuti' | 'Asia/Taipei' | 'Africa/Dar_es_Salaam' | 'Europe/Kiev' | 'Africa/Kampala' | 'Pacific/Wake' | 'America/New_York' | 'America/Montevideo' | 'Asia/Tashkent' | 'Europe/Vatican' | 'America/St_Vincent' | 'America/Caracas' | 'America/Tortola' | 'America/St_Thomas' | 'Asia/Ho_Chi_Minh' | 'Pacific/Efate' | 'Pacific/Wallis' | 'Pacific/Apia' | 'Asia/Aden' | 'Indian/Mayotte' | 'Africa/Johannesburg' | 'Africa/Lusaka' | 'Africa/Harare'; export declare interface CreateErrorOptions { flags?: boolean messages?: LanguageMessages } export declare interface CustomHelpers { schema: ExtensionBoundSchema state: State prefs: ValidationOptions original: V warn: (code: string, local?: ValidationContext) => void error: (code: string, local?: ValidationContext, localState?: State) => ErrorReport message: (messages: LanguageMessages, local?: ValidationContext) => ErrorReport } export declare type CustomValidator = (value: V, helpers: CustomHelpers) => R | ErrorReport export { DatabaseQueryBuilderContract } export declare interface DataUriOptions { /** * optional parameter defaulting to true which will require `=` padding if true or make padding optional if false * * @default true */ paddingRequired?: boolean } declare type DateInput = DateTime | DateObjectUnits | Date; declare type DateInput_2 = DateTime_2 | DateObjectUnits_2 | Date; /** * Note that ISO weekday and local weekday fields are mutually exclusive */ declare interface DateObjectUnits { // a year, such as 1987 year?: number | undefined; // a month, 1-12 month?: number | undefined; // a day of the month, 1-31, depending on the month day?: number | undefined; // day of the year, 1-365 or 366 ordinal?: number | undefined; // an ISO week year weekYear?: number | undefined; // a week year, according to the locale localWeekYear?: number | undefined; // an ISO week number, between 1 and 52 or 53, depending on the year weekNumber?: number | undefined; // a week number, between 1 and 52 or 53, depending on the year, according to the locale localWeekNumber?: number | undefined; // an ISO weekday, 1-7, where 1 is Monday and 7 is Sunday weekday?: WeekdayNumbers | undefined; // a weekday, 1-7, where 1 is the first day of the week, and 7 is the last, according to the locale localWeekday?: WeekdayNumbers | undefined; // hour of the day, 0-23 hour?: number | undefined; // minute of the hour, 0-59 minute?: number | undefined; // second of the minute, 0-59 second?: number | undefined; // millisecond of the second, 0-999 millisecond?: number | undefined; } /** * Note that ISO weekday and local weekday fields are mutually exclusive */ declare interface DateObjectUnits_2 { // a year, such as 1987 year?: number | undefined; // a month, 1-12 month?: number | undefined; // a day of the month, 1-31, depending on the month day?: number | undefined; // day of the year, 1-365 or 366 ordinal?: number | undefined; // an ISO week year weekYear?: number | undefined; // a week year, according to the locale localWeekYear?: number | undefined; // an ISO week number, between 1 and 52 or 53, depending on the year weekNumber?: number | undefined; // a week number, between 1 and 52 or 53, depending on the year, according to the locale localWeekNumber?: number | undefined; // an ISO weekday, 1-7, where 1 is Monday and 7 is Sunday weekday?: WeekdayNumbers_2 | undefined; // a weekday, 1-7, where 1 is the first day of the week, and 7 is the last, according to the locale localWeekday?: WeekdayNumbers_2 | undefined; // hour of the day, 0-23 hour?: number | undefined; // minute of the hour, 0-59 minute?: number | undefined; // second of the minute, 0-59 second?: number | undefined; // millisecond of the second, 0-999 millisecond?: number | undefined; } /** * Schema type for date validation. * * @public */ export declare interface DateSchema extends AnySchema { /** * Specifies that the value must be greater than date. * Notes: 'now' can be passed in lieu of date so as to always compare relatively to the current date, * allowing to explicitly ensure a date is either in the past or in the future. * It can also be a reference to another field. */ greater(date: 'now' | Date | number | string | Reference): this; /** * Requires the string value to be in valid ISO 8601 date format. */ iso(): this; /** * Specifies that the value must be less than date. * Notes: 'now' can be passed in lieu of date so as to always compare relatively to the current date, * allowing to explicitly ensure a date is either in the past or in the future. * It can also be a reference to another field. */ less(date: 'now' | Date | number | string | Reference): this; /** * Specifies the oldest date allowed. * Notes: 'now' can be passed in lieu of date so as to always compare relatively to the current date, * allowing to explicitly ensure a date is either in the past or in the future. * It can also be a reference to another field. */ min(date: 'now' | Date | number | string | Reference): this; /** * Specifies the latest date allowed. * Notes: 'now' can be passed in lieu of date so as to always compare relatively to the current date, * allowing to explicitly ensure a date is either in the past or in the future. * It can also be a reference to another field. */ max(date: 'now' | Date | number | string | Reference): this; /** * Requires the value to be a timestamp interval from Unix Time. * @param type - the type of timestamp (allowed values are unix or javascript [default]) */ timestamp(type?: 'javascript' | 'unix'): this; /** * Sets a default value if the original value is `undefined`. * * @param value - The default value. Can be: * - A literal date value * - A reference to another schema value * - A function that returns the default value with signature `(parent, helpers) => value` * - `parent` - A clone of the object containing the value being validated * - `helpers` - Validation helper functions for custom validation logic */ default(value?: DefaultableValue): this; } declare interface DateSchema_2 extends AnySchema_2 { /** * Specifies that the value must be greater than date. * Notes: 'now' can be passed in lieu of date so as to always compare relatively to the current date, * allowing to explicitly ensure a date is either in the past or in the future. * It can also be a reference to another field. */ greater(date: 'now' | Date | number | string | Reference): this /** * Requires the string value to be in valid ISO 8601 date format. */ iso(): this /** * Specifies that the value must be less than date. * Notes: 'now' can be passed in lieu of date so as to always compare relatively to the current date, * allowing to explicitly ensure a date is either in the past or in the future. * It can also be a reference to another field. */ less(date: 'now' | Date | number | string | Reference): this /** * Specifies the oldest date allowed. * Notes: 'now' can be passed in lieu of date so as to always compare relatively to the current date, * allowing to explicitly ensure a date is either in the past or in the future. * It can also be a reference to another field. */ min(date: 'now' | Date | number | string | Reference): this /** * Specifies the latest date allowed. * Notes: 'now' can be passed in lieu of date so as to always compare relatively to the current date, * allowing to explicitly ensure a date is either in the past or in the future. * It can also be a reference to another field. */ max(date: 'now' | Date | number | string | Reference): this /** * Requires the value to be a timestamp interval from Unix Time. * @param type - the type of timestamp (allowed values are unix or javascript [default]) */ timestamp(type?: 'javascript' | 'unix'): this } /** * A DateTime is an immutable data structure representing a specific date and time and accompanying methods. * It contains class and instance methods for creating, parsing, interrogating, transforming, and formatting them. * * A DateTime consists of the following parts: * * A timestamp. Each DateTime instance refers to a specific millisecond of the Unix epoch. * * A time zone. Each instance is considered in the context of a specific zone (by default, the local system's zone). * * Configuration properties that affect how output strings are formatted, such as `locale`, `numberingSystem`, and `outputCalendar`. * * Here is a brief overview of the most commonly used functionality it provides: * * * **Creation**: To create a DateTime from its components, use one of its factory class methods: {@link DateTime.local}, {@link DateTime.utc}, and (most flexibly) {@link DateTime.fromObject}. * To create one from a standard string format, use {@link DateTime.fromISO}, {@link DateTime.fromHTTP}, and {@link DateTime.fromRFC2822}. * To create one from a custom string format, use {@link DateTime.fromFormat}. To create one from a native JS date, use {@link DateTime.fromJSDate}. * * **Gregorian calendar and time**: To examine the Gregorian properties of a DateTime individually (i.e. as opposed to collectively through {@link DateTime#toObject}), use the {@link DateTime#year}, * {@link DateTime#month}, {@link DateTime#day}, {@link DateTime#hour}, {@link DateTime#minute}, {@link DateTime#second}, {@link DateTime#millisecond} accessors. * * **Week calendar**: For ISO week calendar attributes, see the {@link DateTime#weekYear}, {@link DateTime#weekNumber}, and {@link DateTime#weekday} accessors. * * **Configuration** See the {@link DateTime#locale} and {@link DateTime#numberingSystem} accessors. * * **Transformation**: To transform the DateTime into other DateTimes, use {@link DateTime#set}, {@link DateTime#reconfigure}, {@link DateTime#setZone}, {@link DateTime#setLocale}, * {@link DateTime.plus}, {@link DateTime#minus}, {@link DateTime#endOf}, {@link DateTime#startOf}, {@link DateTime#toUTC}, and {@link DateTime#toLocal}. * * **Output**: To convert the DateTime to other representations, use the {@link DateTime#toRelative}, {@link DateTime#toRelativeCalendar}, {@link DateTime#toJSON}, {@link DateTime#toISO}, * {@link DateTime#toHTTP}, {@link DateTime#toObject}, {@link DateTime#toRFC2822}, {@link DateTime#toString}, {@link DateTime#toLocaleString}, {@link DateTime#toFormat}, * {@link DateTime#toMillis} and {@link DateTime#toJSDate}. * * There's plenty others documented below. In addition, for more information on subtler topics * like internationalization, time zones, alternative calendars, validity, and so on, see the external documentation. */ declare class DateTime { /** * Create a DateTime for the current instant, in the system's time zone. * * Use Settings to override these default values if needed. * @example * DateTime.now().toISO() //~> now in the ISO format */ static now(): DateTime; /** * Create a local DateTime * * @param year - The calendar year. If omitted (as in, call `local()` with no arguments), the current time will be used * @param month - The month, 1-indexed * @param day - The day of the month, 1-indexed * @param hour - The hour of the day, in 24-hour time * @param minute - The minute of the hour, meaning a number between 0 and 59 * @param second - The second of the minute, meaning a number between 0 and 59 * @param millisecond - The millisecond of the second, meaning a number between 0 and 999 * @param opts * * @example * DateTime.local() //~> now * @example * DateTime.local({ zone: "America/New_York" }) //~> now, in US east coast time * @example * DateTime.local(2017) //~> 2017-01-01T00:00:00 * @example * DateTime.local(2017, 3) //~> 2017-03-01T00:00:00 * @example * DateTime.local(2017, 3, 12, { locale: "fr") //~> 2017-03-12T00:00:00, with a French locale * @example * DateTime.local(2017, 3, 12, 5) //~> 2017-03-12T05:00:00 * @example * DateTime.local(2017, 3, 12, 5, { zone: "utc" }) //~> 2017-03-12T05:00:00, in UTC * @example * DateTime.local(2017, 3, 12, 5, 45) //~> 2017-03-12T05:45:00 * @example * DateTime.local(2017, 3, 12, 5, 45, 10) //~> 2017-03-12T05:45:10 * @example * DateTime.local(2017, 3, 12, 5, 45, 10, 765) //~> 2017-03-12T05:45:10.765 */ static local( year: number, month: number, day: number, hour: number, minute: number, second: number, millisecond: number, opts?: DateTimeJSOptions, ): DateTimeMaybeValid; static local( year: number, month: number, day: number, hour: number, minute: number, second: number, opts?: DateTimeJSOptions, ): DateTimeMaybeValid; static local( year: number, month: number, day: number, hour: number, minute: number, opts?: DateTimeJSOptions, ): DateTimeMaybeValid; static local(year: number, month: number, day: number, hour: number, opts?: DateTimeJSOptions): DateTimeMaybeValid; static local(year: number, month: number, day: number, opts?: DateTimeJSOptions): DateTimeMaybeValid; static local(year: number, month: number, opts?: DateTimeJSOptions): DateTimeMaybeValid; static local(year: number, opts?: DateTimeJSOptions): DateTimeMaybeValid; static local(opts?: DateTimeJSOptions): DateTime; /** * Create a DateTime in UTC * * @param year - The calendar year. If omitted (as in, call `utc()` with no arguments), the current time will be used * @param month - The month, 1-indexed * @param day - The day of the month * @param hour - The hour of the day, in 24-hour time * @param minute - The minute of the hour, meaning a number between 0 and 59 * @param second - The second of the minute, meaning a number between 0 and 59 * @param millisecond - The millisecond of the second, meaning a number between 0 and 999 * @param options - configuration options for the DateTime * @param options.locale - a locale to set on the resulting DateTime instance * @param options.outputCalendar - the output calendar to set on the resulting DateTime instance * @param options.numberingSystem - the numbering system to set on the resulting DateTime instance * * @example * DateTime.utc() //~> now * @example * DateTime.utc(2017) //~> 2017-01-01T00:00:00Z * @example * DateTime.utc(2017, 3) //~> 2017-03-01T00:00:00Z * @example * DateTime.utc(2017, 3, 12) //~> 2017-03-12T00:00:00Z * @example * DateTime.utc(2017, 3, 12, 5) //~> 2017-03-12T05:00:00Z * @example * DateTime.utc(2017, 3, 12, 5, 45) //~> 2017-03-12T05:45:00Z * @example * DateTime.utc(2017, 3, 12, 5, 45, { locale: "fr" } ) //~> 2017-03-12T05:45:00Z with a French locale * @example * DateTime.utc(2017, 3, 12, 5, 45, 10) //~> 2017-03-12T05:45:10Z * @example * DateTime.utc(2017, 3, 12, 5, 45, 10, 765, { locale: "fr") //~> 2017-03-12T05:45:10.765Z with a French locale */ static utc( year: number, month: number, day: number, hour: number, minute: number, second: number, millisecond: number, options?: LocaleOptions, ): DateTimeMaybeValid; static utc( year: number, month: number, day: number, hour: number, minute: number, second: number, options?: LocaleOptions, ): DateTimeMaybeValid; static utc( year: number, month: number, day: number, hour: number, minute: number, options?: LocaleOptions, ): DateTimeMaybeValid; static utc(year: number, month: number, day: number, hour: number, options?: LocaleOptions): DateTimeMaybeValid; static utc(year: number, month: number, day: number, options?: LocaleOptions): DateTimeMaybeValid; static utc(year: number, month: number, options?: LocaleOptions): DateTimeMaybeValid; static utc(year: number, options?: LocaleOptions): DateTimeMaybeValid; static utc(options?: LocaleOptions): DateTime; /** * Create a DateTime from a JavaScript Date object. Uses the default zone. * * @param date - a JavaScript Date object * @param options - configuration options for the DateTime * @param options.zone - the zone to place the DateTime into */ static fromJSDate(date: Date, options?: { zone?: string | Zone }): DateTimeMaybeValid; /** * Create a DateTime from a number of milliseconds since the epoch (meaning since 1 January 1970 00:00:00 UTC). Uses the default zone. * * @param milliseconds - a number of milliseconds since 1970 UTC * @param options - configuration options for the DateTime * @param options.zone - the zone to place the DateTime into. Defaults to 'local'. * @param options.locale - a locale to set on the resulting DateTime instance * @param options.outputCalendar - the output calendar to set on the resulting DateTime instance * @param options.numberingSystem - the numbering system to set on the resulting DateTime instance */ static fromMillis(milliseconds: number, options?: DateTimeJSOptions): DateTimeMaybeValid; /** * Create a DateTime from a number of seconds since the epoch (meaning since 1 January 1970 00:00:00 UTC). Uses the default zone. * * @param seconds - a number of seconds since 1970 UTC * @param options - configuration options for the DateTime * @param options.zone - the zone to place the DateTime into. Defaults to 'local'. * @param options.locale - a locale to set on the resulting DateTime instance * @param options.outputCalendar - the output calendar to set on the resulting DateTime instance * @param options.numberingSystem - the numbering system to set on the resulting DateTime instance */ static fromSeconds(seconds: number, options?: DateTimeJSOptions): DateTimeMaybeValid; /** * Create a DateTime from a JavaScript object with keys like 'year' and 'hour' with reasonable defaults. * * @param obj - the object to create the DateTime from * @param obj.year - a year, such as 1987 * @param obj.month - a month, 1-12 * @param obj.day - a day of the month, 1-31, depending on the month * @param obj.ordinal - day of the year, 1-365 or 366 * @param obj.weekYear - an ISO week year * @param obj.weekNumber - an ISO week number, between 1 and 52 or 53, depending on the year * @param obj.weekday - an ISO weekday, 1-7, where 1 is Monday and 7 is Sunday * @param obj.hour - hour of the day, 0-23 * @param obj.minute - minute of the hour, 0-59 * @param obj.second - second of the minute, 0-59 * @param obj.millisecond - millisecond of the second, 0-999 * @param opts - options for creating this DateTime * @param opts.zone - interpret the numbers in the context of a particular zone. Can take any value taken as the first argument to setZone(). Defaults to 'local'. * @param opts.locale - a locale to set on the resulting DateTime instance. Defaults to 'system's locale'. * @param opts.outputCalendar - the output calendar to set on the resulting DateTime instance * @param opts.numberingSystem - the numbering system to set on the resulting DateTime instance * * @example * DateTime.fromObject({ year: 1982, month: 5, day: 25}).toISODate() //=> '1982-05-25' * @example * DateTime.fromObject({ year: 1982 }).toISODate() //=> '1982-01-01' * @example * DateTime.fromObject({ hour: 10, minute: 26, second: 6 }) //=> today at 10:26:06 * @example * DateTime.fromObject({ hour: 10, minute: 26, second: 6 }, { zone: 'utc' }) * @example * DateTime.fromObject({ hour: 10, minute: 26, second: 6 }, { zone: 'local' }) * @example * DateTime.fromObject({ hour: 10, minute: 26, second: 6 }, { zone: 'America/New_York' }) * @example * DateTime.fromObject({ weekYear: 2016, weekNumber: 2, weekday: 3 }).toISODate() //=> '2016-01-13' * @example * DateTime.fromObject({ localWeekYear: 2022, localWeekNumber: 1, localWeekday: 1 }, { locale: 'en-US' }).toISODate() //=> '2021-12-26' */ static fromObject(obj: DateObjectUnits, opts?: DateTimeJSOptions): DateTimeMaybeValid; /** * Create a DateTime from an ISO 8601 string * * @param text - the ISO string * @param opts - options to affect the creation * @param opts.zone - use this zone if no offset is specified in the input string itself. Will also convert the time to this zone. Defaults to 'local'. * @param opts.setZone - override the zone with a fixed-offset zone specified in the string itself, if it specifies one. Defaults to false. * @param opts.locale - a locale to set on the resulting DateTime instance. Defaults to 'system's locale'. * @param opts.outputCalendar - the output calendar to set on the resulting DateTime instance * @param opts.numberingSystem - the numbering system to set on the resulting DateTime instance * * @example * DateTime.fromISO('2016-05-25T09:08:34.123') * @example * DateTime.fromISO('2016-05-25T09:08:34.123+06:00') * @example * DateTime.fromISO('2016-05-25T09:08:34.123+06:00', {setZone: true}) * @example * DateTime.fromISO('2016-05-25T09:08:34.123', {zone: 'utc'}) * @example * DateTime.fromISO('2016-W05-4') */ static fromISO(text: string, opts?: DateTimeOptions): DateTimeMaybeValid; /** * Create a DateTime from an RFC 2822 string * * @param text - the RFC 2822 string * @param opts - options to affect the creation * @param opts.zone - convert the time to this zone. Since the offset is always specified in the string itself, * this has no effect on the interpretation of string, merely the zone the resulting DateTime is expressed in. Defaults to 'local' * @param opts.setZone - override the zone with a fixed-offset zone specified in the string itself, if it specifies one. Defaults to false. * @param opts.locale - a locale to set on the resulting DateTime instance. Defaults to 'system's locale'. * @param opts.outputCalendar - the output calendar to set on the resulting DateTime instance * @param opts.numberingSystem - the numbering system to set on the resulting DateTime instance * * @example * DateTime.fromRFC2822('25 Nov 2016 13:23:12 GMT') * @example * DateTime.fromRFC2822('Fri, 25 Nov 2016 13:23:12 +0600') * @example * DateTime.fromRFC2822('25 Nov 2016 13:23 Z') */ static fromRFC2822(text: string, opts?: DateTimeOptions): DateTimeMaybeValid; /** * Create a DateTime from an HTTP header date * * @see https://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3.1 * * @param text - the HTTP header date * @param opts - options to affect the creation * @param opts.zone - convert the time to this zone. Since HTTP dates are always in UTC, * this has no effect on the interpretation of string,merely the zone the resulting DateTime is expressed in. Defaults to 'local'. * @param opts.setZone - override the zone with the fixed-offset zone specified in the string. For HTTP dates, this is always UTC, * so this option is equivalent to setting the `zone` option to 'utc', but this option is included for consistency with similar methods. Defaults to false. * @param opts.locale - a locale to set on the resulting DateTime instance. Defaults to 'system's locale'. * @param opts.outputCalendar - the output calendar to set on the resulting DateTime instance * @param opts.numberingSystem - the numbering system to set on the resulting DateTime instance * * @example * DateTime.fromHTTP('Sun, 06 Nov 1994 08:49:37 GMT') * @example * DateTime.fromHTTP('Sunday, 06-Nov-94 08:49:37 GMT') * @example * DateTime.fromHTTP('Sun Nov 6 08:49:37 1994') */ static fromHTTP(text: string, opts?: DateTimeOptions): DateTimeMaybeValid; /** * Create a DateTime from an input string and format string. * * Defaults to en-US if no locale has been specified, regardless of the system's locale. * * For a table of tokens and their interpretations, * see [here](https://moment.github.io/luxon/#/parsing?id=table-of-tokens). * * @param text - the string to parse * @param format - the format the string is expected to be in (see the link below for the formats) * @param opts - options to affect the creation * @param opts.zone - use this zone if no offset is specified in the input string itself. * Will also convert the DateTime to this zone. * Defaults to 'local'. * @param opts.setZone - override the zone with a zone specified in the string itself, if it specifies one. * Defaults to false. * @param opts.locale - a locale string to use when parsing. * Will also set the DateTime to this locale. * Defaults to 'en-US'. * @param opts.numberingSystem - the numbering system to use when parsing. * Will also set the resulting DateTime to this numbering system * @param opts.outputCalendar - the output calendar to set on the resulting DateTime instance */ static fromFormat(text: string, format: Tokens, opts?: DateTimeOptions): DateTimeMaybeValid; /** * @deprecated use fromFormat instead */ static fromString(text: string, format: Tokens, options?: DateTimeOptions): DateTimeMaybeValid; /** * Create a DateTime from a SQL date, time, or datetime * Defaults to en-US if no locale has been specified, regardless of the system's locale * * @param text - the string to parse * @param opts - options to affect the creation * @param opts.zone - use this zone if no offset is specified in the input string itself. Will also convert the DateTime to this zone. Defaults to 'local'. * @param opts.setZone - override the zone with a zone specified in the string itself, if it specifies one. Defaults to false. * @param opts.locale - a locale string to use when parsing. Will also set the DateTime to this locale. Defaults to 'en-US'. * @param opts.numberingSystem - the numbering system to use when parsing. Will also set the resulting DateTime to this numbering system * @param opts.outputCalendar - the output calendar to set on the resulting DateTime instance * * @example * DateTime.fromSQL('2017-05-15') * @example * DateTime.fromSQL('2017-05-15 09:12:34') * @example * DateTime.fromSQL('2017-05-15 09:12:34.342') * @example * DateTime.fromSQL('2017-05-15 09:12:34.342+06:00') * @example * DateTime.fromSQL('2017-05-15 09:12:34.342 America/Los_Angeles') * @example * DateTime.fromSQL('2017-05-15 09:12:34.342 America/Los_Angeles', { setZone: true }) * @example * DateTime.fromSQL('2017-05-15 09:12:34.342', { zone: 'America/Los_Angeles' }) * @example * DateTime.fromSQL('09:12:34.342') */ static fromSQL(text: string, opts?: DateTimeOptions): DateTimeMaybeValid; /** * Create an invalid DateTime. * * @param reason - simple string of why this DateTime is invalid. Should not contain parameters or anything else data-dependent * @param explanation - longer explanation, may include parameters and other useful debugging information. Defaults to null. */ static invalid(reason: string, explanation?: string): DateTime; /** * Check if an object is a DateTime. Works across context boundaries * * @param o */ static isDateTime(o: unknown): o is DateTimeMaybeValid; /** * Produce the format string for a set of options * * @param formatOpts - Intl.DateTimeFormat constructor options and configuration options * @param localeOpts - Opts to override the configuration options on this DateTime * * @example * DateTime.parseFormatForOpts(DateTime.DATETIME_FULL); //=> "MMMM d, yyyyy, h:m a ZZZ" */ static parseFormatForOpts(formatOpts?: DateTimeFormatOptions, localeOpts?: LocaleOptions): string | null; /** * Produce the fully expanded format token for the locale * * Does NOT quote characters, so quoted tokens will not round trip correctly * * @param format - the format string - see {@link Tokens} * @param localeOptions - Options to override the configuration options on this DateTime */ static expandFormat(format: Tokens, localeOptions?: LocaleOptions): string; private constructor(config: unknown); // INFO /** * Get the value of unit. * * @param unit - a unit such as 'minute' or 'day' * * @example * DateTime.local(2017, 7, 4).get('month'); //=> 7 * @example * DateTime.local(2017, 7, 4).get('day'); //=> 4 */ get(unit: keyof DateTime): number; /** * Get those DateTimes which have the same local time as this DateTime, but a different offset from UTC in this DateTime's zone. * During DST changes local time can be ambiguous, for example 2023-10-29T02:30:00 in Europe/Berlin can have offset +01:00 or +02:00. * This method will return both possible DateTimes if this DateTime's local time is ambiguous. */ getPossibleOffsets(): this[]; /** * Returns whether the DateTime is valid. Invalid DateTimes occur when: * * The DateTime was created from invalid calendar information, such as the 13th month or February 30 * * The DateTime was created by an operation on another invalid date */ get isValid(): IfValid; /** * Returns an error code if this DateTime is invalid, or null if the DateTime is valid */ get invalidReason(): IfValid; /** * Returns an explanation of why this DateTime became invalid, or null if the DateTime is valid */ get invalidExplanation(): IfValid; /** * Get the locale of a DateTime, such as 'en-GB'. The locale is used when formatting the DateTime */ get locale(): IfValid; /** * Get the numbering system of a DateTime, such as 'beng'. The numbering system is used when formatting the DateTime */ get numberingSystem(): IfValid; /** * Get the output calendar of a DateTime, such as 'islamic'. The output calendar is used when formatting the DateTime */ get outputCalendar(): IfValid; /** * Get the time zone associated with this DateTime. */ get zone(): Zone; /** * Get the name of the time zone. */ get zoneName(): IfValid; /** * Get the year * * @example DateTime.local(2017, 5, 25).year //=> 2017 */ get year(): IfValid; /** * Get the quarter * * @example DateTime.local(2017, 5, 25).quarter //=> 2 */ get quarter(): IfValid; /** * Get the month (1-12). * * @example DateTime.local(2017, 5, 25).month //=> 5 */ get month(): IfValid; /** * Get the day of the month (1-30ish). * * @example DateTime.local(2017, 5, 25).day //=> 25 */ get day(): IfValid; /** * Get the hour of the day (0-23). * * @example DateTime.local(2017, 5, 25, 9).hour //=> 9 */ get hour(): IfValid; /** * Get the minute of the hour (0-59). * * @example * DateTime.local(2017, 5, 25, 9, 30).minute //=> 30 */ get minute(): IfValid; /** * Get the second of the minute (0-59). * * @example * DateTime.local(2017, 5, 25, 9, 30, 52).second //=> 52 */ get second(): IfValid; /** * Get the millisecond of the second (0-999). * * @example * DateTime.local(2017, 5, 25, 9, 30, 52, 654).millisecond //=> 654 */ get millisecond(): IfValid; /** * Get the week year * @see https://en.wikipedia.org/wiki/ISO_week_date * * @example * DateTime.local(2014, 12, 31).weekYear //=> 2015 */ get weekYear(): IfValid; /** * Get the week number of the week year (1-52ish). * @see https://en.wikipedia.org/wiki/ISO_week_date * * @example * DateTime.local(2017, 5, 25).weekNumber //=> 21 */ get weekNumber(): IfValid; /** * Get the day of the week. * 1 is Monday and 7 is Sunday * @see https://en.wikipedia.org/wiki/ISO_week_date * * @example * DateTime.local(2014, 11, 31).weekday //=> 4 */ get weekday(): IfValid; /** * Returns true if this date is on a weekend, according to the locale, false otherwise */ get isWeekend(): IfValid; /** * Get the day of the week, according to the locale. * 1 is the first day of the week, and 7 is the last day of the week. * If the locale assigns Sunday as the first day of the week, then a date which is a Sunday will return 1. */ get localWeekday(): IfValid; /** * Get the week number of the week year, according to the locale. * Different locales assign week numbers differently. * The week can start on different days of the week (see {@link localWeekday}), * and because a different number of days is required for a week to count as the first week of a year. */ get localWeekNumber(): IfValid; /** * Get the week year, according to the locale. * Different locales assign week numbers (and therefore week years) differently, see {@link localWeekNumber}. */ get localWeekYear(): IfValid; /** * Get the ordinal (meaning the day of the year) * * @example * DateTime.local(2017, 5, 25).ordinal //=> 145 */ get ordinal(): IfValid; /** * Get the human readable short month name, such as 'Oct'. * Defaults to the system's locale if no locale has been specified * * @example * DateTime.local(2017, 10, 30).monthShort //=> Oct */ get monthShort(): IfValid; /** * Get the human readable long month name, such as 'October'. * Defaults to the system's locale if no locale has been specified * * @example * DateTime.local(2017, 10, 30).monthLong //=> October */ get monthLong(): IfValid; /** * Get the human readable short weekday, such as 'Mon'. * Defaults to the system's locale if no locale has been specified * * @example * DateTime.local(2017, 10, 30).weekdayShort //=> Mon */ get weekdayShort(): IfValid; /** * Get the human readable long weekday, such as 'Monday'. * Defaults to the system's locale if no locale has been specified * * @example * DateTime.local(2017, 10, 30).weekdayLong //=> Monday */ get weekdayLong(): IfValid; /** * Get the UTC offset of this DateTime in minutes * * @example * DateTime.now().offset //=> -240 * @example * DateTime.utc().offset //=> 0 */ get offset(): IfValid; /** * Get the short human name for the zone's current offset, for example "EST" or "EDT". * Defaults to the system's locale if no locale has been specified */ get offsetNameShort(): IfValid; /** * Get the long human name for the zone's current offset, for example "Eastern Standard Time" or "Eastern Daylight Time". * Defaults to the system's locale if no locale has been specified */ get offsetNameLong(): IfValid; /** * Get whether this zone's offset ever changes, as in a DST. */ get isOffsetFixed(): IfValid; /** * Get whether the DateTime is in a DST. */ get isInDST(): IfValid; /** * Returns true if this DateTime is in a leap year, false otherwise * * @example * DateTime.local(2016).isInLeapYear //=> true * @example * DateTime.local(2013).isInLeapYear //=> false */ get isInLeapYear(): boolean; /** * Returns the number of days in this DateTime's month * * @example * DateTime.local(2016, 2).daysInMonth //=> 29 * @example * DateTime.local(2016, 3).daysInMonth //=> 31 */ get daysInMonth(): IfValid; /** * Returns the number of days in this DateTime's year * * @example * DateTime.local(2016).daysInYear //=> 366 * @example * DateTime.local(2013).daysInYear //=> 365 */ get daysInYear(): IfValid; /** * Returns the number of weeks in this DateTime's year * @see https://en.wikipedia.org/wiki/ISO_week_date * * @example * DateTime.local(2004).weeksInWeekYear //=> 53 * @example * DateTime.local(2013).weeksInWeekYear //=> 52 */ get weeksInWeekYear(): IfValid; /** * Returns the number of weeks in this DateTime's local week year * * @example * DateTime.local(2020, 6, {locale: 'en-US'}).weeksInLocalWeekYear //=> 52 * @example * DateTime.local(2020, 6, {locale: 'de-DE'}).weeksInLocalWeekYear //=> 53 */ get weeksInLocalWeekYear(): IfValid; /** * Returns the resolved Intl options for this DateTime. * This is useful in understanding the behavior of formatting methods * * @param opts - the same options as toLocaleString */ resolvedLocaleOptions(opts?: LocaleOptions | DateTimeFormatOptions): ResolvedLocaleOptions; // TRANSFORM /** * "Set" the DateTime's zone to UTC. Returns a newly-constructed DateTime. * * Equivalent to {@link DateTime.setZone}('utc') * * @param offset - optionally, an offset from UTC in minutes. Defaults to 0. * @param opts - options to pass to `setZone()`. Defaults to {}. */ toUTC(offset?: number, opts?: ZoneOptions): this; /** * "Set" the DateTime's zone to the host's local zone. Returns a newly-constructed DateTime. * * Equivalent to `setZone('local')` */ toLocal(): this; /** * "Set" the DateTime's zone to specified zone. Returns a newly-constructed DateTime. * * By default, the setter keeps the underlying time the same (as in, the same timestamp), but the new instance will report different local times and consider DSTs when making computations, * as with {@link DateTime.plus}. You may wish to use {@link DateTime.toLocal} and {@link DateTime.toUTC} which provide simple convenience wrappers for commonly used zones. * * @param zone - a zone identifier. As a string, that can be any IANA zone supported by the host environment, or a fixed-offset name of the form 'UTC+3', or the strings 'local' or 'utc'. * You may also supply an instance of a {@link Zone} class. Defaults to 'local'. * @param opts - options * @param opts.keepLocalTime - If true, adjust the underlying time so that the local time stays the same, but in the target zone. You should rarely need this. Defaults to false. */ setZone(zone?: string | Zone, opts?: ZoneOptions): DateTimeMaybeValid; /** * "Set" the locale, numberingSystem, or outputCalendar. Returns a newly-constructed DateTime. * * @param properties - the properties to set * * @example * DateTime.local(2017, 5, 25).reconfigure({ locale: 'en-GB' }) */ reconfigure(properties: LocaleOptions): this; /** * "Set" the locale. Returns a newly-constructed DateTime. * Just a convenient alias for reconfigure({ locale }) * * @example * DateTime.local(2017, 5, 25).setLocale('en-GB') */ setLocale(locale: string): this; /** * "Set" the values of specified units. Returns a newly-constructed DateTime. * You can only set units with this method; for "setting" metadata, see {@link DateTime.reconfigure} and {@link DateTime.setZone}. * * This method also supports setting locale-based week units, i.e. `localWeekday`, `localWeekNumber` and `localWeekYear`. * They cannot be mixed with ISO-week units like `weekday`. * * @example * dt.set({ year: 2017 }) * @example * dt.set({ hour: 8, minute: 30 }) * @example * dt.set({ weekday: 5 }) * @example * dt.set({ year: 2005, ordinal: 234 }) */ set(values: DateObjectUnits): this; /** * Adding hours, minutes, seconds, or milliseconds increases the timestamp by the right number of milliseconds. Adding days, months, or years shifts the calendar, * accounting for DSTs and leap years along the way. Thus, `dt.plus({ hours: 24 })` may result in a different time than `dt.plus({ days: 1 })` if there's a DST shift in between. * * @param duration - The amount to add. Either a Luxon Duration, a number of milliseconds, the object argument to Duration.fromObject() * * @example * DateTime.now().plus(123) //~> in 123 milliseconds * @example * DateTime.now().plus({ minutes: 15 }) //~> in 15 minutes * @example * DateTime.now().plus({ days: 1 }) //~> this time tomorrow * @example * DateTime.now().plus({ days: -1 }) //~> this time yesterday * @example * DateTime.now().plus({ hours: 3, minutes: 13 }) //~> in 3 hr, 13 min * @example * DateTime.now().plus(Duration.fromObject({ hours: 3, minutes: 13 })) //~> in 3 hr, 13 min */ plus(duration: DurationLike): this; /** * See {@link DateTime.plus} * * @param duration - The amount to subtract. Either a Luxon Duration, a number of milliseconds, the object argument to Duration.fromObject() */ minus(duration: DurationLike): this; /** * "Set" this DateTime to the beginning of the given unit. * * @param unit - The unit to go to the beginning of. Can be 'year', 'quarter', 'month', 'week', 'day', 'hour', 'minute', 'second', or 'millisecond'. * @param opts - options * * @example * DateTime.local(2014, 3, 3).startOf('month').toISODate(); //=> '2014-03-01' * @example * DateTime.local(2014, 3, 3).startOf('year').toISODate(); //=> '2014-01-01' * @example * DateTime.local(2014, 3, 3).startOf('week').toISODate(); //=> '2014-03-03', weeks always start on Mondays * @example * DateTime.local(2014, 3, 3, 5, 30).startOf('day').toISOTime(); //=> '00:00.000-05:00' * @example * DateTime.local(2014, 3, 3, 5, 30).startOf('hour').toISOTime(); //=> '05:00:00.000-05:00' */ startOf(unit: DateTimeUnit, opts?: StartOfOptions): this; /** * "Set" this DateTime to the end (meaning the last millisecond) of a unit of time * * @param unit - The unit to go to the end of. Can be 'year', 'quarter', 'month', 'week', 'day', 'hour', 'minute', 'second', or 'millisecond'. * @param opts - options * * @example * DateTime.local(2014, 3, 3).endOf('month').toISO(); //=> '2014-03-31T23:59:59.999-05:00' * @example * DateTime.local(2014, 3, 3).endOf('year').toISO(); //=> '2014-12-31T23:59:59.999-05:00' * @example * DateTime.local(2014, 3, 3).endOf('week').toISO(); // => '2014-03-09T23:59:59.999-05:00', weeks start on Mondays * @example * DateTime.local(2014, 3, 3, 5, 30).endOf('day').toISO(); //=> '2014-03-03T23:59:59.999-05:00' * @example * DateTime.local(2014, 3, 3, 5, 30).endOf('hour').toISO(); //=> '2014-03-03T05:59:59.999-05:00' */ endOf(unit: DateTimeUnit, opts?: EndOfOptions): this; // OUTPUT /** * Returns a string representation of this DateTime formatted according to the specified format string. * **You may not want this.** See {@link DateTime.toLocaleString} for a more flexible formatting tool. For a table of tokens and their interpretations, * see [here](https://moment.github.io/luxon/#/formatting?id=table-of-tokens). * Defaults to en-US if no locale has been specified, regardless of the system's locale. * * @param format - the format string - see {@link Tokens} * @param options - opts to override the configuration options on this DateTime * * @example * DateTime.now().toFormat('yyyy LLL dd') //=> '2017 Apr 22' * @example * DateTime.now().setLocale('fr').toFormat('yyyy LLL dd') //=> '2017 avr. 22' * @example * DateTime.now().toFormat('yyyy LLL dd', { locale: "fr" }) //=> '2017 avr. 22' * @example * DateTime.now().toFormat("HH 'hours and' mm 'minutes'") //=> '20 hours and 55 minutes' */ toFormat(format: Tokens, options?: LocaleOptions): IfValid; /** * Returns a localized string representing this date. Accepts the same options as the Intl.DateTimeFormat constructor and any presets defined by Luxon, * such as `DateTime.DATE_FULL` or `DateTime.TIME_SIMPLE` of the DateTime in the assigned locale. * Defaults to the system's locale if no locale has been specified * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat * * @param formatOpts - Intl.DateTimeFormat constructor options and configuration options * @param opts - opts to override the configuration options on this DateTime * * @example * DateTime.now().toLocaleString(); //=> 4/20/2017 * @example * DateTime.now().setLocale('en-gb').toLocaleString(); //=> '20/04/2017' * @example * DateTime.now().toLocaleString({ locale: 'en-gb' }); //=> '20/04/2017' * @example * DateTime.now().toLocaleString(DateTime.DATE_FULL); //=> 'April 20, 2017' * @example * DateTime.now().toLocaleString(DateTime.TIME_SIMPLE); //=> '11:32 AM' * @example * DateTime.now().toLocaleString(DateTime.DATETIME_SHORT); //=> '4/20/2017, 11:32 AM' * @example * DateTime.now().toLocaleString({ weekday: 'long', month: 'long', day: '2-digit' }); //=> 'Thursday, April 20' * @example * DateTime.now().toLocaleString({ weekday: 'short', month: 'short', day: '2-digit', hour: '2-digit', minute: '2-digit' }); //=> 'Thu, Apr 20, 11:27 AM' * @example * DateTime.now().toLocaleString({ hour: '2-digit', minute: '2-digit', hourCycle: 'h23' }); //=> '11:32' */ toLocaleString( formatOpts?: DateTimeFormatOptions, opts?: LocaleOptions, ): IfValid; /** * Returns an array of format "parts", meaning individual tokens along with metadata. This is allows callers to post-process individual sections of the formatted output. * Defaults to the system's locale if no locale has been specified * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/formatToParts * * @example * DateTime.now().toLocaleParts(); //=> [ * //=> { type: 'day', value: '25' }, * //=> { type: 'literal', value: '/' }, * //=> { type: 'month', value: '05' }, * //=> { type: 'literal', value: '/' }, * //=> { type: 'year', value: '1982' } * //=> ] * @example * DateTime.invalid('').toLocaleParts(); //=> [] */ toLocaleParts(opts?: DateTimeFormatOptions): Intl.DateTimeFormatPart[]; /** * Returns an ISO 8601-compliant string representation of this DateTime * * @example * DateTime.utc(1982, 5, 25).toISO() //=> '1982-05-25T00:00:00.000Z' * @example * DateTime.now().toISO() //=> '2017-04-22T20:47:05.335-04:00' * @example * DateTime.now().toISO({ includeOffset: false }) //=> '2017-04-22T20:47:05.335' * @example * DateTime.now().toISO({ format: 'basic' }) //=> '20170422T204705.335-0400' * @example * DateTime.now().toISO({ precision: 'day' }) //=> '2017-04-22Z' * @example * DateTime.now().toISO({ precision: 'minute' }) //=> '2017-04-22T20:47Z' */ toISO(opts?: ToISOTimeOptions): IfValid; /** * Returns an ISO 8601-compliant string representation of this DateTime's date component * * @example * DateTime.utc(1982, 5, 25).toISODate() //=> '1982-05-25' * @example * DateTime.utc(1982, 5, 25).toISODate({ format: 'basic' }) //=> '19820525' * @example * DateTime.utc(1982, 5, 25).toISODate({ precision: 'month' }) //=> '1982-05' */ toISODate(opts?: ToISODateOptions): IfValid; /** * Returns an ISO 8601-compliant string representation of this DateTime's week date * * @example * DateTime.utc(1982, 5, 25).toISOWeekDate() //=> '1982-W21-2' */ toISOWeekDate(): IfValid; /** * Returns an ISO 8601-compliant string representation of this DateTime's time component * * @example * DateTime.utc().set({ hour: 7, minute: 34 }).toISOTime() //=> '07:34:19.361Z' * @example * DateTime.utc().set({ hour: 7, minute: 34, seconds: 0, milliseconds: 0 }).toISOTime({ suppressSeconds: true }) //=> '07:34Z' * @example * DateTime.utc().set({ hour: 7, minute: 34 }).toISOTime({ format: 'basic' }) //=> '073419.361Z' * @example * DateTime.utc().set({ hour: 7, minute: 34 }).toISOTime({ includePrefix: true }) //=> 'T07:34:19.361Z' * @example * DateTime.utc().set({ hour: 7, minute: 34, second: 56 }).toISOTime({ precision: 'minute' }) //=> '07:34Z' */ toISOTime(opts?: ToISOTimeOptions): IfValid; /** * Returns an RFC 2822-compatible string representation of this DateTime, always in UTC * * @example * DateTime.utc(2014, 7, 13).toRFC2822() //=> 'Sun, 13 Jul 2014 00:00:00 +0000' * @example * DateTime.local(2014, 7, 13).toRFC2822() //=> 'Sun, 13 Jul 2014 00:00:00 -0400' */ toRFC2822(): IfValid; /** * Returns a string representation of this DateTime appropriate for use in HTTP headers. * Specifically, the string conforms to RFC 1123. * @see https://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3.1 * * @example * DateTime.utc(2014, 7, 13).toHTTP() //=> 'Sun, 13 Jul 2014 00:00:00 GMT' * @example * DateTime.utc(2014, 7, 13, 19).toHTTP() //=> 'Sun, 13 Jul 2014 19:00:00 GMT' */ toHTTP(): IfValid; /** * Returns a string representation of this DateTime appropriate for use in SQL Date * * @example * DateTime.utc(2014, 7, 13).toSQLDate() //=> '2014-07-13' */ toSQLDate(): IfValid; /** * Returns a string representation of this DateTime appropriate for use in SQL Time * * @example * DateTime.utc().toSQL() //=> '05:15:16.345' * @example * DateTime.now().toSQL() //=> '05:15:16.345 -04:00' * @example * DateTime.now().toSQL({ includeOffset: false }) //=> '05:15:16.345' * @example * DateTime.now().toSQL({ includeZone: false }) //=> '05:15:16.345 America/New_York' */ toSQLTime(opts?: ToSQLOptions): IfValid; /** * Returns a string representation of this DateTime for use in SQL DateTime * * @example * DateTime.utc(2014, 7, 13).toSQL() //=> '2014-07-13 00:00:00.000 Z' * @example * DateTime.local(2014, 7, 13).toSQL() //=> '2014-07-13 00:00:00.000 -04:00' * @example * DateTime.local(2014, 7, 13).toSQL({ includeOffset: false }) //=> '2014-07-13 00:00:00.000' * @example * DateTime.local(2014, 7, 13).toSQL({ includeZone: true }) //=> '2014-07-13 00:00:00.000 America/New_York' */ toSQL(opts?: ToSQLOptions): IfValid; /** * Returns a string representation of this DateTime appropriate for debugging */ toString(): IfValid; /** * Returns the epoch milliseconds of this DateTime. Alias of {@link DateTime.toMillis} */ valueOf(): IfValid; /** * Returns the epoch milliseconds of this DateTime. */ toMillis(): IfValid; /** * Returns the epoch seconds of this DateTime. */ toSeconds(): IfValid; /** * Returns the epoch seconds (as a whole number) of this DateTime. */ toUnixInteger(): IfValid; /** * Returns an ISO 8601 representation of this DateTime appropriate for use in JSON. */ toJSON(): IfValid; /** * Returns a BSON-serializable equivalent to this DateTime. */ toBSON(): Date; /** * Returns a JavaScript object with this DateTime's year, month, day, and so on. * * @param opts - options for generating the object * @param opts.includeConfig - include configuration attributes in the output. Defaults to false. * * @example * DateTime.now().toObject() //=> { year: 2017, month: 4, day: 22, hour: 20, minute: 49, second: 42, millisecond: 268 } */ toObject(opts?: { /** * Include configuration attributes in the output * @defaultValue false */ includeConfig?: IncludeConfig; }): ToObjectOutput; /** * Returns a JavaScript Date equivalent to this DateTime. */ toJSDate(): Date; // COMPARE /** * Return the difference between two DateTimes as a Duration. * * @param otherDateTime - the DateTime to compare this one to * @param unit - the unit or array of units to include in the duration. * Defaults to ['milliseconds']. * @param opts - options that affect the creation of the Duration * @param opts.conversionAccuracy - the conversion system to use. * Defaults to 'casual'. * * @example * let i1 = DateTime.fromISO('1982-05-25T09:45'), * i2 = DateTime.fromISO('1983-10-14T10:30'); * i2.diff(i1).toObject() //=> { milliseconds: 43807500000 } * i2.diff(i1, 'hours').toObject() //=> { hours: 12168.75 } * i2.diff(i1, ['months', 'days']).toObject() //=> { months: 16, days: 19.03125 } * i2.diff(i1, ['months', 'days', 'hours']).toObject() //=> { months: 16, days: 19, hours: 0.75 } */ diff(otherDateTime: DateTime, unit?: DurationUnits, opts?: DiffOptions): Duration; /** * Return the difference between this DateTime and right now. * See {@link DateTime.diff} * * @param unit - the unit(s) to include in the duration. Defaults to ['milliseconds']. * @param opts - options that affect the creation of the Duration * @param opts.conversionAccuracy - the conversion system to use. Defaults to 'casual'. */ diffNow(unit?: DurationUnits, opts?: DiffOptions): Duration; /** * Return an Interval spanning between this DateTime and another DateTime * * @param otherDateTime - the other end point of the Interval */ until(otherDateTime: DateTime): IfValid, DateTime, IsValid>; /** * Return whether this DateTime is in the same unit of time as another DateTime. * Note that time zones are **ignored** in this comparison, which compares the **local** calendar time. Use {@link DateTime.setZone} to convert one of the dates if needed. * * @param otherDateTime - the other DateTime * @param unit - the unit of time to check sameness on * * @example * DateTime.now().hasSame(otherDT, 'day'); //~> true if otherDT is in the same current calendar day */ hasSame(otherDateTime: DateTime, unit: DateTimeUnit, opts?: HasSameOptions): IfValid; /** * An equality check. * Two DateTimes are equal if and only if they represent the same millisecond, have the same zone and location, and are both valid. * To compare just the millisecond values, use `+dt1 === +dt2`. * * @param other - the other DateTime */ equals(other: DateTime): IfValid; /** * Returns a string representation of this time relative to now, such as "in two days". * Can only internationalize if your platform supports Intl.RelativeTimeFormat. * Rounds towards zero by default. * * @example * DateTime.now().plus({ days: 1 }).toRelative() //=> "in 1 day" * @example * DateTime.now().setLocale("es").toRelative({ days: 1 }) //=> "dentro de 1 día" * @example * DateTime.now().plus({ days: 1 }).toRelative({ locale: "fr" }) //=> "dans 23 heures" * @example * DateTime.now().minus({ days: 2 }).toRelative() //=> "2 days ago" * @example * DateTime.now().minus({ days: 2 }).toRelative({ unit: "hours" }) //=> "48 hours ago" * @example * DateTime.now().minus({ hours: 36 }).toRelative({ round: false }) //=> "1.5 days ago" */ toRelative(options?: ToRelativeOptions): IfValid; /** * Returns a string representation of this date relative to today, such as "yesterday" or "next month". * Only internationalizes on platforms that support Intl.RelativeTimeFormat. * * @example * DateTime.now().plus({ days: 1 }).toRelativeCalendar() //=> "tomorrow" * @example * DateTime.now().setLocale("es").plus({ days: 1 }).toRelative() //=> ""mañana" * @example * DateTime.now().plus({ days: 1 }).toRelativeCalendar({ locale: "fr" }) //=> "demain" * @example * DateTime.now().minus({ days: 2 }).toRelativeCalendar() //=> "2 days ago" */ toRelativeCalendar(options?: ToRelativeCalendarOptions): IfValid; /** * Return the min of several date times * * @param dateTimes - the DateTimes from which to choose the minimum */ static min(...dateTimes: Values): PickedDateTime; /** * Return the max of several date times * * @param dateTimes - the DateTimes from which to choose the maximum */ static max(...dateTimes: Values): PickedDateTime; // MISC /** * Explain how a string would be parsed by {@link fromFormat} * * @param text - the string to parse * @param format - the format the string is expected to be in - see {@link Tokens} * @param options - options taken by {@link fromFormat} */ static fromFormatExplain(text: string, format: Tokens, options?: DateTimeOptions): ExplainedFormat; /** * @deprecated use {@link fromFormatExplain} instead */ static fromStringExplain(text: string, format: Tokens, options?: DateTimeOptions): ExplainedFormat; /** * Build a parser for a given format using the given locale. * * This parser can be passed to {@link fromFormatParser} to a parse a date in this format. * This can be used to optimize cases where many dates need to be parsed in a specific format. * * @param format - the format the string is expected to be in - see {@link Tokens} * @param options - the Locale options */ static buildFormatParser(format: Tokens, options?: LocaleOptions): TokenParser; /** * Create a DateTime from an input string and format parser. * * The format parser must have been created with the same locale as this call. * * @param text the string to parse * @param parser - parser from {@link buildFormatParser} * @param options options taken by {@link fromFormat} */ static fromFormatParser(text: string, parser: TokenParser, options?: DateTimeOptions): DateTimeMaybeValid; // FORMAT PRESETS /** * {@link DateTime.toLocaleString} format like 10/14/1983 */ static get DATE_SHORT(): Intl.DateTimeFormatOptions; /** * {@link DateTime.toLocaleString} format like 'Oct 14, 1983' */ static get DATE_MED(): Intl.DateTimeFormatOptions; /** * {@link DateTime.toLocaleString} format like 'Fri, Oct 14, 1983' */ static get DATE_MED_WITH_WEEKDAY(): Intl.DateTimeFormatOptions; /** * {@link DateTime.toLocaleString} format like 'October 14, 1983' */ static get DATE_FULL(): Intl.DateTimeFormatOptions; /** * {@link DateTime.toLocaleString} format like 'Tuesday, October 14, 1983' */ static get DATE_HUGE(): Intl.DateTimeFormatOptions; /** * {@link DateTime.toLocaleString} format like '09:30 AM'. Only 12-hour if the locale is. */ static get TIME_SIMPLE(): Intl.DateTimeFormatOptions; /** * {@link DateTime.toLocaleString} format like '09:30:23 AM'. Only 12-hour if the locale is. */ static get TIME_WITH_SECONDS(): Intl.DateTimeFormatOptions; /** * {@link DateTime.toLocaleString} format like '09:30:23 AM EDT'. Only 12-hour if the locale is. */ static get TIME_WITH_SHORT_OFFSET(): Intl.DateTimeFormatOptions; /** * {@link DateTime.toLocaleString} format like '09:30:23 AM Eastern Daylight Time'. Only 12-hour if the locale is. */ static get TIME_WITH_LONG_OFFSET(): Intl.DateTimeFormatOptions; /** * {@link DateTime.toLocaleString} format like '09:30', always 24-hour. */ static get TIME_24_SIMPLE(): Intl.DateTimeFormatOptions; /** * {@link DateTime.toLocaleString} format like '09:30:23', always 24-hour. */ static get TIME_24_WITH_SECONDS(): Intl.DateTimeFormatOptions; /** * {@link DateTime.toLocaleString} format like '09:30:23 EDT', always 24-hour. */ static get TIME_24_WITH_SHORT_OFFSET(): Intl.DateTimeFormatOptions; /** * {@link DateTime.toLocaleString} format like '09:30:23 Eastern Daylight Time', always 24-hour. */ static get TIME_24_WITH_LONG_OFFSET(): Intl.DateTimeFormatOptions; /** * {@link DateTime.toLocaleString} format like '10/14/1983, 9:30 AM'. Only 12-hour if the locale is. */ static get DATETIME_SHORT(): Intl.DateTimeFormatOptions; /** * {@link DateTime.toLocaleString} format like '10/14/1983, 9:30:33 AM'. Only 12-hour if the locale is. */ static get DATETIME_SHORT_WITH_SECONDS(): Intl.DateTimeFormatOptions; /** * {@link DateTime.toLocaleString} format like 'Oct 14, 1983, 9:30 AM'. Only 12-hour if the locale is. */ static get DATETIME_MED(): Intl.DateTimeFormatOptions; /** * {@link DateTime.toLocaleString} format like 'Oct 14, 1983, 9:30:33 AM'. Only 12-hour if the locale is. */ static get DATETIME_MED_WITH_SECONDS(): Intl.DateTimeFormatOptions; /** * {@link DateTime.toLocaleString} format like 'Fri, 14 Oct 1983, 9:30 AM'. Only 12-hour if the locale is. */ static get DATETIME_MED_WITH_WEEKDAY(): Intl.DateTimeFormatOptions; /** * {@link DateTime.toLocaleString} format like 'October 14, 1983, 9:30 AM EDT'. Only 12-hour if the locale is. */ static get DATETIME_FULL(): Intl.DateTimeFormatOptions; /** * {@link DateTime.toLocaleString} format like 'October 14, 1983, 9:30:33 AM EDT'. Only 12-hour if the locale is. */ static get DATETIME_FULL_WITH_SECONDS(): Intl.DateTimeFormatOptions; /** * {@link DateTime.toLocaleString} format like 'Friday, October 14, 1983, 9:30 AM Eastern Daylight Time'. Only 12-hour if the locale is. */ static get DATETIME_HUGE(): Intl.DateTimeFormatOptions; /** * {@link DateTime.toLocaleString} format like 'Friday, October 14, 1983, 9:30:33 AM Eastern Daylight Time'. Only 12-hour if the locale is. */ static get DATETIME_HUGE_WITH_SECONDS(): Intl.DateTimeFormatOptions; } /** * A DateTime is an immutable data structure representing a specific date and time and accompanying methods. * It contains class and instance methods for creating, parsing, interrogating, transforming, and formatting them. * * A DateTime consists of the following parts: * * A timestamp. Each DateTime instance refers to a specific millisecond of the Unix epoch. * * A time zone. Each instance is considered in the context of a specific zone (by default, the local system's zone). * * Configuration properties that affect how output strings are formatted, such as `locale`, `numberingSystem`, and `outputCalendar`. * * Here is a brief overview of the most commonly used functionality it provides: * * * **Creation**: To create a DateTime from its components, use one of its factory class methods: {@link DateTime.local}, {@link DateTime.utc}, and (most flexibly) {@link DateTime.fromObject}. * To create one from a standard string format, use {@link DateTime.fromISO}, {@link DateTime.fromHTTP}, and {@link DateTime.fromRFC2822}. * To create one from a custom string format, use {@link DateTime.fromFormat}. To create one from a native JS date, use {@link DateTime.fromJSDate}. * * **Gregorian calendar and time**: To examine the Gregorian properties of a DateTime individually (i.e. as opposed to collectively through {@link DateTime#toObject}), use the {@link DateTime#year}, * {@link DateTime#month}, {@link DateTime#day}, {@link DateTime#hour}, {@link DateTime#minute}, {@link DateTime#second}, {@link DateTime#millisecond} accessors. * * **Week calendar**: For ISO week calendar attributes, see the {@link DateTime#weekYear}, {@link DateTime#weekNumber}, and {@link DateTime#weekday} accessors. * * **Configuration** See the {@link DateTime#locale} and {@link DateTime#numberingSystem} accessors. * * **Transformation**: To transform the DateTime into other DateTimes, use {@link DateTime#set}, {@link DateTime#reconfigure}, {@link DateTime#setZone}, {@link DateTime#setLocale}, * {@link DateTime.plus}, {@link DateTime#minus}, {@link DateTime#endOf}, {@link DateTime#startOf}, {@link DateTime#toUTC}, and {@link DateTime#toLocal}. * * **Output**: To convert the DateTime to other representations, use the {@link DateTime#toRelative}, {@link DateTime#toRelativeCalendar}, {@link DateTime#toJSON}, {@link DateTime#toISO}, * {@link DateTime#toHTTP}, {@link DateTime#toObject}, {@link DateTime#toRFC2822}, {@link DateTime#toString}, {@link DateTime#toLocaleString}, {@link DateTime#toFormat}, * {@link DateTime#toMillis} and {@link DateTime#toJSDate}. * * There's plenty others documented below. In addition, for more information on subtler topics * like internationalization, time zones, alternative calendars, validity, and so on, see the external documentation. */ declare class DateTime_2 { /** * Create a DateTime for the current instant, in the system's time zone. * * Use Settings to override these default values if needed. * @example * DateTime.now().toISO() //~> now in the ISO format */ static now(): DateTime_2; /** * Create a local DateTime * * @param year - The calendar year. If omitted (as in, call `local()` with no arguments), the current time will be used * @param month - The month, 1-indexed * @param day - The day of the month, 1-indexed * @param hour - The hour of the day, in 24-hour time * @param minute - The minute of the hour, meaning a number between 0 and 59 * @param second - The second of the minute, meaning a number between 0 and 59 * @param millisecond - The millisecond of the second, meaning a number between 0 and 999 * @param opts * * @example * DateTime.local() //~> now * @example * DateTime.local({ zone: "America/New_York" }) //~> now, in US east coast time * @example * DateTime.local(2017) //~> 2017-01-01T00:00:00 * @example * DateTime.local(2017, 3) //~> 2017-03-01T00:00:00 * @example * DateTime.local(2017, 3, 12, { locale: "fr") //~> 2017-03-12T00:00:00, with a French locale * @example * DateTime.local(2017, 3, 12, 5) //~> 2017-03-12T05:00:00 * @example * DateTime.local(2017, 3, 12, 5, { zone: "utc" }) //~> 2017-03-12T05:00:00, in UTC * @example * DateTime.local(2017, 3, 12, 5, 45) //~> 2017-03-12T05:45:00 * @example * DateTime.local(2017, 3, 12, 5, 45, 10) //~> 2017-03-12T05:45:10 * @example * DateTime.local(2017, 3, 12, 5, 45, 10, 765) //~> 2017-03-12T05:45:10.765 */ static local( year: number, month: number, day: number, hour: number, minute: number, second: number, millisecond: number, opts?: DateTimeJSOptions_2, ): DateTimeMaybeValid_2; static local( year: number, month: number, day: number, hour: number, minute: number, second: number, opts?: DateTimeJSOptions_2, ): DateTimeMaybeValid_2; static local( year: number, month: number, day: number, hour: number, minute: number, opts?: DateTimeJSOptions_2, ): DateTimeMaybeValid_2; static local(year: number, month: number, day: number, hour: number, opts?: DateTimeJSOptions_2): DateTimeMaybeValid_2; static local(year: number, month: number, day: number, opts?: DateTimeJSOptions_2): DateTimeMaybeValid_2; static local(year: number, month: number, opts?: DateTimeJSOptions_2): DateTimeMaybeValid_2; static local(year: number, opts?: DateTimeJSOptions_2): DateTimeMaybeValid_2; static local(opts?: DateTimeJSOptions_2): DateTime_2; /** * Create a DateTime in UTC * * @param year - The calendar year. If omitted (as in, call `utc()` with no arguments), the current time will be used * @param month - The month, 1-indexed * @param day - The day of the month * @param hour - The hour of the day, in 24-hour time * @param minute - The minute of the hour, meaning a number between 0 and 59 * @param second - The second of the minute, meaning a number between 0 and 59 * @param millisecond - The millisecond of the second, meaning a number between 0 and 999 * @param options - configuration options for the DateTime * @param options.locale - a locale to set on the resulting DateTime instance * @param options.outputCalendar - the output calendar to set on the resulting DateTime instance * @param options.numberingSystem - the numbering system to set on the resulting DateTime instance * * @example * DateTime.utc() //~> now * @example * DateTime.utc(2017) //~> 2017-01-01T00:00:00Z * @example * DateTime.utc(2017, 3) //~> 2017-03-01T00:00:00Z * @example * DateTime.utc(2017, 3, 12) //~> 2017-03-12T00:00:00Z * @example * DateTime.utc(2017, 3, 12, 5) //~> 2017-03-12T05:00:00Z * @example * DateTime.utc(2017, 3, 12, 5, 45) //~> 2017-03-12T05:45:00Z * @example * DateTime.utc(2017, 3, 12, 5, 45, { locale: "fr" } ) //~> 2017-03-12T05:45:00Z with a French locale * @example * DateTime.utc(2017, 3, 12, 5, 45, 10) //~> 2017-03-12T05:45:10Z * @example * DateTime.utc(2017, 3, 12, 5, 45, 10, 765, { locale: "fr") //~> 2017-03-12T05:45:10.765Z with a French locale */ static utc( year: number, month: number, day: number, hour: number, minute: number, second: number, millisecond: number, options?: LocaleOptions_2, ): DateTimeMaybeValid_2; static utc( year: number, month: number, day: number, hour: number, minute: number, second: number, options?: LocaleOptions_2, ): DateTimeMaybeValid_2; static utc( year: number, month: number, day: number, hour: number, minute: number, options?: LocaleOptions_2, ): DateTimeMaybeValid_2; static utc(year: number, month: number, day: number, hour: number, options?: LocaleOptions_2): DateTimeMaybeValid_2; static utc(year: number, month: number, day: number, options?: LocaleOptions_2): DateTimeMaybeValid_2; static utc(year: number, month: number, options?: LocaleOptions_2): DateTimeMaybeValid_2; static utc(year: number, options?: LocaleOptions_2): DateTimeMaybeValid_2; static utc(options?: LocaleOptions_2): DateTime_2; /** * Create a DateTime from a JavaScript Date object. Uses the default zone. * * @param date - a JavaScript Date object * @param options - configuration options for the DateTime * @param options.zone - the zone to place the DateTime into */ static fromJSDate(date: Date, options?: { zone?: string | Zone_2 }): DateTimeMaybeValid_2; /** * Create a DateTime from a number of milliseconds since the epoch (meaning since 1 January 1970 00:00:00 UTC). Uses the default zone. * * @param milliseconds - a number of milliseconds since 1970 UTC * @param options - configuration options for the DateTime * @param options.zone - the zone to place the DateTime into. Defaults to 'local'. * @param options.locale - a locale to set on the resulting DateTime instance * @param options.outputCalendar - the output calendar to set on the resulting DateTime instance * @param options.numberingSystem - the numbering system to set on the resulting DateTime instance */ static fromMillis(milliseconds: number, options?: DateTimeJSOptions_2): DateTimeMaybeValid_2; /** * Create a DateTime from a number of seconds since the epoch (meaning since 1 January 1970 00:00:00 UTC). Uses the default zone. * * @param seconds - a number of seconds since 1970 UTC * @param options - configuration options for the DateTime * @param options.zone - the zone to place the DateTime into. Defaults to 'local'. * @param options.locale - a locale to set on the resulting DateTime instance * @param options.outputCalendar - the output calendar to set on the resulting DateTime instance * @param options.numberingSystem - the numbering system to set on the resulting DateTime instance */ static fromSeconds(seconds: number, options?: DateTimeJSOptions_2): DateTimeMaybeValid_2; /** * Create a DateTime from a JavaScript object with keys like 'year' and 'hour' with reasonable defaults. * * @param obj - the object to create the DateTime from * @param obj.year - a year, such as 1987 * @param obj.month - a month, 1-12 * @param obj.day - a day of the month, 1-31, depending on the month * @param obj.ordinal - day of the year, 1-365 or 366 * @param obj.weekYear - an ISO week year * @param obj.weekNumber - an ISO week number, between 1 and 52 or 53, depending on the year * @param obj.weekday - an ISO weekday, 1-7, where 1 is Monday and 7 is Sunday * @param obj.hour - hour of the day, 0-23 * @param obj.minute - minute of the hour, 0-59 * @param obj.second - second of the minute, 0-59 * @param obj.millisecond - millisecond of the second, 0-999 * @param opts - options for creating this DateTime * @param opts.zone - interpret the numbers in the context of a particular zone. Can take any value taken as the first argument to setZone(). Defaults to 'local'. * @param opts.locale - a locale to set on the resulting DateTime instance. Defaults to 'system's locale'. * @param opts.outputCalendar - the output calendar to set on the resulting DateTime instance * @param opts.numberingSystem - the numbering system to set on the resulting DateTime instance * * @example * DateTime.fromObject({ year: 1982, month: 5, day: 25}).toISODate() //=> '1982-05-25' * @example * DateTime.fromObject({ year: 1982 }).toISODate() //=> '1982-01-01' * @example * DateTime.fromObject({ hour: 10, minute: 26, second: 6 }) //=> today at 10:26:06 * @example * DateTime.fromObject({ hour: 10, minute: 26, second: 6 }, { zone: 'utc' }) * @example * DateTime.fromObject({ hour: 10, minute: 26, second: 6 }, { zone: 'local' }) * @example * DateTime.fromObject({ hour: 10, minute: 26, second: 6 }, { zone: 'America/New_York' }) * @example * DateTime.fromObject({ weekYear: 2016, weekNumber: 2, weekday: 3 }).toISODate() //=> '2016-01-13' * @example * DateTime.fromObject({ localWeekYear: 2022, localWeekNumber: 1, localWeekday: 1 }, { locale: 'en-US' }).toISODate() //=> '2021-12-26' */ static fromObject(obj: DateObjectUnits_2, opts?: DateTimeJSOptions_2): DateTimeMaybeValid_2; /** * Create a DateTime from an ISO 8601 string * * @param text - the ISO string * @param opts - options to affect the creation * @param opts.zone - use this zone if no offset is specified in the input string itself. Will also convert the time to this zone. Defaults to 'local'. * @param opts.setZone - override the zone with a fixed-offset zone specified in the string itself, if it specifies one. Defaults to false. * @param opts.locale - a locale to set on the resulting DateTime instance. Defaults to 'system's locale'. * @param opts.outputCalendar - the output calendar to set on the resulting DateTime instance * @param opts.numberingSystem - the numbering system to set on the resulting DateTime instance * * @example * DateTime.fromISO('2016-05-25T09:08:34.123') * @example * DateTime.fromISO('2016-05-25T09:08:34.123+06:00') * @example * DateTime.fromISO('2016-05-25T09:08:34.123+06:00', {setZone: true}) * @example * DateTime.fromISO('2016-05-25T09:08:34.123', {zone: 'utc'}) * @example * DateTime.fromISO('2016-W05-4') */ static fromISO(text: string, opts?: DateTimeOptions_2): DateTimeMaybeValid_2; /** * Create a DateTime from an RFC 2822 string * * @param text - the RFC 2822 string * @param opts - options to affect the creation * @param opts.zone - convert the time to this zone. Since the offset is always specified in the string itself, * this has no effect on the interpretation of string, merely the zone the resulting DateTime is expressed in. Defaults to 'local' * @param opts.setZone - override the zone with a fixed-offset zone specified in the string itself, if it specifies one. Defaults to false. * @param opts.locale - a locale to set on the resulting DateTime instance. Defaults to 'system's locale'. * @param opts.outputCalendar - the output calendar to set on the resulting DateTime instance * @param opts.numberingSystem - the numbering system to set on the resulting DateTime instance * * @example * DateTime.fromRFC2822('25 Nov 2016 13:23:12 GMT') * @example * DateTime.fromRFC2822('Fri, 25 Nov 2016 13:23:12 +0600') * @example * DateTime.fromRFC2822('25 Nov 2016 13:23 Z') */ static fromRFC2822(text: string, opts?: DateTimeOptions_2): DateTimeMaybeValid_2; /** * Create a DateTime from an HTTP header date * * @see https://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3.1 * * @param text - the HTTP header date * @param opts - options to affect the creation * @param opts.zone - convert the time to this zone. Since HTTP dates are always in UTC, * this has no effect on the interpretation of string,merely the zone the resulting DateTime is expressed in. Defaults to 'local'. * @param opts.setZone - override the zone with the fixed-offset zone specified in the string. For HTTP dates, this is always UTC, * so this option is equivalent to setting the `zone` option to 'utc', but this option is included for consistency with similar methods. Defaults to false. * @param opts.locale - a locale to set on the resulting DateTime instance. Defaults to 'system's locale'. * @param opts.outputCalendar - the output calendar to set on the resulting DateTime instance * @param opts.numberingSystem - the numbering system to set on the resulting DateTime instance * * @example * DateTime.fromHTTP('Sun, 06 Nov 1994 08:49:37 GMT') * @example * DateTime.fromHTTP('Sunday, 06-Nov-94 08:49:37 GMT') * @example * DateTime.fromHTTP('Sun Nov 6 08:49:37 1994') */ static fromHTTP(text: string, opts?: DateTimeOptions_2): DateTimeMaybeValid_2; /** * Create a DateTime from an input string and format string. * * Defaults to en-US if no locale has been specified, regardless of the system's locale. * * For a table of tokens and their interpretations, * see [here](https://moment.github.io/luxon/#/parsing?id=table-of-tokens). * * @param text - the string to parse * @param format - the format the string is expected to be in (see the link below for the formats) * @param opts - options to affect the creation * @param opts.zone - use this zone if no offset is specified in the input string itself. * Will also convert the DateTime to this zone. * Defaults to 'local'. * @param opts.setZone - override the zone with a zone specified in the string itself, if it specifies one. * Defaults to false. * @param opts.locale - a locale string to use when parsing. * Will also set the DateTime to this locale. * Defaults to 'en-US'. * @param opts.numberingSystem - the numbering system to use when parsing. * Will also set the resulting DateTime to this numbering system * @param opts.outputCalendar - the output calendar to set on the resulting DateTime instance */ static fromFormat(text: string, format: Tokens_3, opts?: DateTimeOptions_2): DateTimeMaybeValid_2; /** * @deprecated use fromFormat instead */ static fromString(text: string, format: Tokens_3, options?: DateTimeOptions_2): DateTimeMaybeValid_2; /** * Create a DateTime from a SQL date, time, or datetime * Defaults to en-US if no locale has been specified, regardless of the system's locale * * @param text - the string to parse * @param opts - options to affect the creation * @param opts.zone - use this zone if no offset is specified in the input string itself. Will also convert the DateTime to this zone. Defaults to 'local'. * @param opts.setZone - override the zone with a zone specified in the string itself, if it specifies one. Defaults to false. * @param opts.locale - a locale string to use when parsing. Will also set the DateTime to this locale. Defaults to 'en-US'. * @param opts.numberingSystem - the numbering system to use when parsing. Will also set the resulting DateTime to this numbering system * @param opts.outputCalendar - the output calendar to set on the resulting DateTime instance * * @example * DateTime.fromSQL('2017-05-15') * @example * DateTime.fromSQL('2017-05-15 09:12:34') * @example * DateTime.fromSQL('2017-05-15 09:12:34.342') * @example * DateTime.fromSQL('2017-05-15 09:12:34.342+06:00') * @example * DateTime.fromSQL('2017-05-15 09:12:34.342 America/Los_Angeles') * @example * DateTime.fromSQL('2017-05-15 09:12:34.342 America/Los_Angeles', { setZone: true }) * @example * DateTime.fromSQL('2017-05-15 09:12:34.342', { zone: 'America/Los_Angeles' }) * @example * DateTime.fromSQL('09:12:34.342') */ static fromSQL(text: string, opts?: DateTimeOptions_2): DateTimeMaybeValid_2; /** * Create an invalid DateTime. * * @param reason - simple string of why this DateTime is invalid. Should not contain parameters or anything else data-dependent * @param explanation - longer explanation, may include parameters and other useful debugging information. Defaults to null. */ static invalid(reason: string, explanation?: string): DateTime_2; /** * Check if an object is a DateTime. Works across context boundaries * * @param o */ static isDateTime(o: unknown): o is DateTimeMaybeValid_2; /** * Produce the format string for a set of options * * @param formatOpts - Intl.DateTimeFormat constructor options and configuration options * @param localeOpts - Opts to override the configuration options on this DateTime * * @example * DateTime.parseFormatForOpts(DateTime.DATETIME_FULL); //=> "MMMM d, yyyyy, h:m a ZZZ" */ static parseFormatForOpts(formatOpts?: DateTimeFormatOptions_2, localeOpts?: LocaleOptions_2): string | null; /** * Produce the fully expanded format token for the locale * * Does NOT quote characters, so quoted tokens will not round trip correctly * * @param format - the format string - see {@link Tokens} * @param localeOptions - Options to override the configuration options on this DateTime */ static expandFormat(format: Tokens_3, localeOptions?: LocaleOptions_2): string; private constructor(config: unknown); // INFO /** * Get the value of unit. * * @param unit - a unit such as 'minute' or 'day' * * @example * DateTime.local(2017, 7, 4).get('month'); //=> 7 * @example * DateTime.local(2017, 7, 4).get('day'); //=> 4 */ get(unit: keyof DateTime_2): number; /** * Get those DateTimes which have the same local time as this DateTime, but a different offset from UTC in this DateTime's zone. * During DST changes local time can be ambiguous, for example 2023-10-29T02:30:00 in Europe/Berlin can have offset +01:00 or +02:00. * This method will return both possible DateTimes if this DateTime's local time is ambiguous. */ getPossibleOffsets(): this[]; /** * Returns whether the DateTime is valid. Invalid DateTimes occur when: * * The DateTime was created from invalid calendar information, such as the 13th month or February 30 * * The DateTime was created by an operation on another invalid date */ get isValid(): IfValid_2; /** * Returns an error code if this DateTime is invalid, or null if the DateTime is valid */ get invalidReason(): IfValid_2; /** * Returns an explanation of why this DateTime became invalid, or null if the DateTime is valid */ get invalidExplanation(): IfValid_2; /** * Get the locale of a DateTime, such as 'en-GB'. The locale is used when formatting the DateTime */ get locale(): IfValid_2; /** * Get the numbering system of a DateTime, such as 'beng'. The numbering system is used when formatting the DateTime */ get numberingSystem(): IfValid_2; /** * Get the output calendar of a DateTime, such as 'islamic'. The output calendar is used when formatting the DateTime */ get outputCalendar(): IfValid_2; /** * Get the time zone associated with this DateTime. */ get zone(): Zone_2; /** * Get the name of the time zone. */ get zoneName(): IfValid_2; /** * Get the year * * @example DateTime.local(2017, 5, 25).year //=> 2017 */ get year(): IfValid_2; /** * Get the quarter * * @example DateTime.local(2017, 5, 25).quarter //=> 2 */ get quarter(): IfValid_2; /** * Get the month (1-12). * * @example DateTime.local(2017, 5, 25).month //=> 5 */ get month(): IfValid_2; /** * Get the day of the month (1-30ish). * * @example DateTime.local(2017, 5, 25).day //=> 25 */ get day(): IfValid_2; /** * Get the hour of the day (0-23). * * @example DateTime.local(2017, 5, 25, 9).hour //=> 9 */ get hour(): IfValid_2; /** * Get the minute of the hour (0-59). * * @example * DateTime.local(2017, 5, 25, 9, 30).minute //=> 30 */ get minute(): IfValid_2; /** * Get the second of the minute (0-59). * * @example * DateTime.local(2017, 5, 25, 9, 30, 52).second //=> 52 */ get second(): IfValid_2; /** * Get the millisecond of the second (0-999). * * @example * DateTime.local(2017, 5, 25, 9, 30, 52, 654).millisecond //=> 654 */ get millisecond(): IfValid_2; /** * Get the week year * @see https://en.wikipedia.org/wiki/ISO_week_date * * @example * DateTime.local(2014, 12, 31).weekYear //=> 2015 */ get weekYear(): IfValid_2; /** * Get the week number of the week year (1-52ish). * @see https://en.wikipedia.org/wiki/ISO_week_date * * @example * DateTime.local(2017, 5, 25).weekNumber //=> 21 */ get weekNumber(): IfValid_2; /** * Get the day of the week. * 1 is Monday and 7 is Sunday * @see https://en.wikipedia.org/wiki/ISO_week_date * * @example * DateTime.local(2014, 11, 31).weekday //=> 4 */ get weekday(): IfValid_2; /** * Returns true if this date is on a weekend, according to the locale, false otherwise */ get isWeekend(): IfValid_2; /** * Get the day of the week, according to the locale. * 1 is the first day of the week, and 7 is the last day of the week. * If the locale assigns Sunday as the first day of the week, then a date which is a Sunday will return 1. */ get localWeekday(): IfValid_2; /** * Get the week number of the week year, according to the locale. * Different locales assign week numbers differently. * The week can start on different days of the week (see {@link localWeekday}), * and because a different number of days is required for a week to count as the first week of a year. */ get localWeekNumber(): IfValid_2; /** * Get the week year, according to the locale. * Different locales assign week numbers (and therefore week years) differently, see {@link localWeekNumber}. */ get localWeekYear(): IfValid_2; /** * Get the ordinal (meaning the day of the year) * * @example * DateTime.local(2017, 5, 25).ordinal //=> 145 */ get ordinal(): IfValid_2; /** * Get the human readable short month name, such as 'Oct'. * Defaults to the system's locale if no locale has been specified * * @example * DateTime.local(2017, 10, 30).monthShort //=> Oct */ get monthShort(): IfValid_2; /** * Get the human readable long month name, such as 'October'. * Defaults to the system's locale if no locale has been specified * * @example * DateTime.local(2017, 10, 30).monthLong //=> October */ get monthLong(): IfValid_2; /** * Get the human readable short weekday, such as 'Mon'. * Defaults to the system's locale if no locale has been specified * * @example * DateTime.local(2017, 10, 30).weekdayShort //=> Mon */ get weekdayShort(): IfValid_2; /** * Get the human readable long weekday, such as 'Monday'. * Defaults to the system's locale if no locale has been specified * * @example * DateTime.local(2017, 10, 30).weekdayLong //=> Monday */ get weekdayLong(): IfValid_2; /** * Get the UTC offset of this DateTime in minutes * * @example * DateTime.now().offset //=> -240 * @example * DateTime.utc().offset //=> 0 */ get offset(): IfValid_2; /** * Get the short human name for the zone's current offset, for example "EST" or "EDT". * Defaults to the system's locale if no locale has been specified */ get offsetNameShort(): IfValid_2; /** * Get the long human name for the zone's current offset, for example "Eastern Standard Time" or "Eastern Daylight Time". * Defaults to the system's locale if no locale has been specified */ get offsetNameLong(): IfValid_2; /** * Get whether this zone's offset ever changes, as in a DST. */ get isOffsetFixed(): IfValid_2; /** * Get whether the DateTime is in a DST. */ get isInDST(): IfValid_2; /** * Returns true if this DateTime is in a leap year, false otherwise * * @example * DateTime.local(2016).isInLeapYear //=> true * @example * DateTime.local(2013).isInLeapYear //=> false */ get isInLeapYear(): boolean; /** * Returns the number of days in this DateTime's month * * @example * DateTime.local(2016, 2).daysInMonth //=> 29 * @example * DateTime.local(2016, 3).daysInMonth //=> 31 */ get daysInMonth(): IfValid_2; /** * Returns the number of days in this DateTime's year * * @example * DateTime.local(2016).daysInYear //=> 366 * @example * DateTime.local(2013).daysInYear //=> 365 */ get daysInYear(): IfValid_2; /** * Returns the number of weeks in this DateTime's year * @see https://en.wikipedia.org/wiki/ISO_week_date * * @example * DateTime.local(2004).weeksInWeekYear //=> 53 * @example * DateTime.local(2013).weeksInWeekYear //=> 52 */ get weeksInWeekYear(): IfValid_2; /** * Returns the number of weeks in this DateTime's local week year * * @example * DateTime.local(2020, 6, {locale: 'en-US'}).weeksInLocalWeekYear //=> 52 * @example * DateTime.local(2020, 6, {locale: 'de-DE'}).weeksInLocalWeekYear //=> 53 */ get weeksInLocalWeekYear(): IfValid_2; /** * Returns the resolved Intl options for this DateTime. * This is useful in understanding the behavior of formatting methods * * @param opts - the same options as toLocaleString */ resolvedLocaleOptions(opts?: LocaleOptions_2 | DateTimeFormatOptions_2): ResolvedLocaleOptions_2; // TRANSFORM /** * "Set" the DateTime's zone to UTC. Returns a newly-constructed DateTime. * * Equivalent to {@link DateTime.setZone}('utc') * * @param offset - optionally, an offset from UTC in minutes. Defaults to 0. * @param opts - options to pass to `setZone()`. Defaults to {}. */ toUTC(offset?: number, opts?: ZoneOptions_2): this; /** * "Set" the DateTime's zone to the host's local zone. Returns a newly-constructed DateTime. * * Equivalent to `setZone('local')` */ toLocal(): this; /** * "Set" the DateTime's zone to specified zone. Returns a newly-constructed DateTime. * * By default, the setter keeps the underlying time the same (as in, the same timestamp), but the new instance will report different local times and consider DSTs when making computations, * as with {@link DateTime.plus}. You may wish to use {@link DateTime.toLocal} and {@link DateTime.toUTC} which provide simple convenience wrappers for commonly used zones. * * @param zone - a zone identifier. As a string, that can be any IANA zone supported by the host environment, or a fixed-offset name of the form 'UTC+3', or the strings 'local' or 'utc'. * You may also supply an instance of a {@link Zone} class. Defaults to 'local'. * @param opts - options * @param opts.keepLocalTime - If true, adjust the underlying time so that the local time stays the same, but in the target zone. You should rarely need this. Defaults to false. */ setZone(zone?: string | Zone_2, opts?: ZoneOptions_2): DateTimeMaybeValid_2; /** * "Set" the locale, numberingSystem, or outputCalendar. Returns a newly-constructed DateTime. * * @param properties - the properties to set * * @example * DateTime.local(2017, 5, 25).reconfigure({ locale: 'en-GB' }) */ reconfigure(properties: LocaleOptions_2): this; /** * "Set" the locale. Returns a newly-constructed DateTime. * Just a convenient alias for reconfigure({ locale }) * * @example * DateTime.local(2017, 5, 25).setLocale('en-GB') */ setLocale(locale: string): this; /** * "Set" the values of specified units. Returns a newly-constructed DateTime. * You can only set units with this method; for "setting" metadata, see {@link DateTime.reconfigure} and {@link DateTime.setZone}. * * This method also supports setting locale-based week units, i.e. `localWeekday`, `localWeekNumber` and `localWeekYear`. * They cannot be mixed with ISO-week units like `weekday`. * * @example * dt.set({ year: 2017 }) * @example * dt.set({ hour: 8, minute: 30 }) * @example * dt.set({ weekday: 5 }) * @example * dt.set({ year: 2005, ordinal: 234 }) */ set(values: DateObjectUnits_2): this; /** * Adding hours, minutes, seconds, or milliseconds increases the timestamp by the right number of milliseconds. Adding days, months, or years shifts the calendar, * accounting for DSTs and leap years along the way. Thus, `dt.plus({ hours: 24 })` may result in a different time than `dt.plus({ days: 1 })` if there's a DST shift in between. * * @param duration - The amount to add. Either a Luxon Duration, a number of milliseconds, the object argument to Duration.fromObject() * * @example * DateTime.now().plus(123) //~> in 123 milliseconds * @example * DateTime.now().plus({ minutes: 15 }) //~> in 15 minutes * @example * DateTime.now().plus({ days: 1 }) //~> this time tomorrow * @example * DateTime.now().plus({ days: -1 }) //~> this time yesterday * @example * DateTime.now().plus({ hours: 3, minutes: 13 }) //~> in 3 hr, 13 min * @example * DateTime.now().plus(Duration.fromObject({ hours: 3, minutes: 13 })) //~> in 3 hr, 13 min */ plus(duration: DurationLike_2): this; /** * See {@link DateTime.plus} * * @param duration - The amount to subtract. Either a Luxon Duration, a number of milliseconds, the object argument to Duration.fromObject() */ minus(duration: DurationLike_2): this; /** * "Set" this DateTime to the beginning of the given unit. * * @param unit - The unit to go to the beginning of. Can be 'year', 'quarter', 'month', 'week', 'day', 'hour', 'minute', 'second', or 'millisecond'. * @param opts - options * * @example * DateTime.local(2014, 3, 3).startOf('month').toISODate(); //=> '2014-03-01' * @example * DateTime.local(2014, 3, 3).startOf('year').toISODate(); //=> '2014-01-01' * @example * DateTime.local(2014, 3, 3).startOf('week').toISODate(); //=> '2014-03-03', weeks always start on Mondays * @example * DateTime.local(2014, 3, 3, 5, 30).startOf('day').toISOTime(); //=> '00:00.000-05:00' * @example * DateTime.local(2014, 3, 3, 5, 30).startOf('hour').toISOTime(); //=> '05:00:00.000-05:00' */ startOf(unit: DateTimeUnit_2, opts?: StartOfOptions_2): this; /** * "Set" this DateTime to the end (meaning the last millisecond) of a unit of time * * @param unit - The unit to go to the end of. Can be 'year', 'quarter', 'month', 'week', 'day', 'hour', 'minute', 'second', or 'millisecond'. * @param opts - options * * @example * DateTime.local(2014, 3, 3).endOf('month').toISO(); //=> '2014-03-31T23:59:59.999-05:00' * @example * DateTime.local(2014, 3, 3).endOf('year').toISO(); //=> '2014-12-31T23:59:59.999-05:00' * @example * DateTime.local(2014, 3, 3).endOf('week').toISO(); // => '2014-03-09T23:59:59.999-05:00', weeks start on Mondays * @example * DateTime.local(2014, 3, 3, 5, 30).endOf('day').toISO(); //=> '2014-03-03T23:59:59.999-05:00' * @example * DateTime.local(2014, 3, 3, 5, 30).endOf('hour').toISO(); //=> '2014-03-03T05:59:59.999-05:00' */ endOf(unit: DateTimeUnit_2, opts?: EndOfOptions_2): this; // OUTPUT /** * Returns a string representation of this DateTime formatted according to the specified format string. * **You may not want this.** See {@link DateTime.toLocaleString} for a more flexible formatting tool. For a table of tokens and their interpretations, * see [here](https://moment.github.io/luxon/#/formatting?id=table-of-tokens). * Defaults to en-US if no locale has been specified, regardless of the system's locale. * * @param format - the format string - see {@link Tokens} * @param options - opts to override the configuration options on this DateTime * * @example * DateTime.now().toFormat('yyyy LLL dd') //=> '2017 Apr 22' * @example * DateTime.now().setLocale('fr').toFormat('yyyy LLL dd') //=> '2017 avr. 22' * @example * DateTime.now().toFormat('yyyy LLL dd', { locale: "fr" }) //=> '2017 avr. 22' * @example * DateTime.now().toFormat("HH 'hours and' mm 'minutes'") //=> '20 hours and 55 minutes' */ toFormat(format: Tokens_3, options?: LocaleOptions_2): IfValid_2; /** * Returns a localized string representing this date. Accepts the same options as the Intl.DateTimeFormat constructor and any presets defined by Luxon, * such as `DateTime.DATE_FULL` or `DateTime.TIME_SIMPLE` of the DateTime in the assigned locale. * Defaults to the system's locale if no locale has been specified * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat * * @param formatOpts - Intl.DateTimeFormat constructor options and configuration options * @param opts - opts to override the configuration options on this DateTime * * @example * DateTime.now().toLocaleString(); //=> 4/20/2017 * @example * DateTime.now().setLocale('en-gb').toLocaleString(); //=> '20/04/2017' * @example * DateTime.now().toLocaleString({ locale: 'en-gb' }); //=> '20/04/2017' * @example * DateTime.now().toLocaleString(DateTime.DATE_FULL); //=> 'April 20, 2017' * @example * DateTime.now().toLocaleString(DateTime.TIME_SIMPLE); //=> '11:32 AM' * @example * DateTime.now().toLocaleString(DateTime.DATETIME_SHORT); //=> '4/20/2017, 11:32 AM' * @example * DateTime.now().toLocaleString({ weekday: 'long', month: 'long', day: '2-digit' }); //=> 'Thursday, April 20' * @example * DateTime.now().toLocaleString({ weekday: 'short', month: 'short', day: '2-digit', hour: '2-digit', minute: '2-digit' }); //=> 'Thu, Apr 20, 11:27 AM' * @example * DateTime.now().toLocaleString({ hour: '2-digit', minute: '2-digit', hourCycle: 'h23' }); //=> '11:32' */ toLocaleString( formatOpts?: DateTimeFormatOptions_2, opts?: LocaleOptions_2, ): IfValid_2; /** * Returns an array of format "parts", meaning individual tokens along with metadata. This is allows callers to post-process individual sections of the formatted output. * Defaults to the system's locale if no locale has been specified * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/formatToParts * * @example * DateTime.now().toLocaleParts(); //=> [ * //=> { type: 'day', value: '25' }, * //=> { type: 'literal', value: '/' }, * //=> { type: 'month', value: '05' }, * //=> { type: 'literal', value: '/' }, * //=> { type: 'year', value: '1982' } * //=> ] * @example * DateTime.invalid('').toLocaleParts(); //=> [] */ toLocaleParts(opts?: DateTimeFormatOptions_2): Intl.DateTimeFormatPart[]; /** * Returns an ISO 8601-compliant string representation of this DateTime * * @example * DateTime.utc(1982, 5, 25).toISO() //=> '1982-05-25T00:00:00.000Z' * @example * DateTime.now().toISO() //=> '2017-04-22T20:47:05.335-04:00' * @example * DateTime.now().toISO({ includeOffset: false }) //=> '2017-04-22T20:47:05.335' * @example * DateTime.now().toISO({ format: 'basic' }) //=> '20170422T204705.335-0400' * @example * DateTime.now().toISO({ precision: 'day' }) //=> '2017-04-22Z' * @example * DateTime.now().toISO({ precision: 'minute' }) //=> '2017-04-22T20:47Z' */ toISO(opts?: ToISOTimeOptions_2): IfValid_2; /** * Returns an ISO 8601-compliant string representation of this DateTime's date component * * @example * DateTime.utc(1982, 5, 25).toISODate() //=> '1982-05-25' * @example * DateTime.utc(1982, 5, 25).toISODate({ format: 'basic' }) //=> '19820525' * @example * DateTime.utc(1982, 5, 25).toISODate({ precision: 'month' }) //=> '1982-05' */ toISODate(opts?: ToISODateOptions_2): IfValid_2; /** * Returns an ISO 8601-compliant string representation of this DateTime's week date * * @example * DateTime.utc(1982, 5, 25).toISOWeekDate() //=> '1982-W21-2' */ toISOWeekDate(): IfValid_2; /** * Returns an ISO 8601-compliant string representation of this DateTime's time component * * @example * DateTime.utc().set({ hour: 7, minute: 34 }).toISOTime() //=> '07:34:19.361Z' * @example * DateTime.utc().set({ hour: 7, minute: 34, seconds: 0, milliseconds: 0 }).toISOTime({ suppressSeconds: true }) //=> '07:34Z' * @example * DateTime.utc().set({ hour: 7, minute: 34 }).toISOTime({ format: 'basic' }) //=> '073419.361Z' * @example * DateTime.utc().set({ hour: 7, minute: 34 }).toISOTime({ includePrefix: true }) //=> 'T07:34:19.361Z' * @example * DateTime.utc().set({ hour: 7, minute: 34, second: 56 }).toISOTime({ precision: 'minute' }) //=> '07:34Z' */ toISOTime(opts?: ToISOTimeOptions_2): IfValid_2; /** * Returns an RFC 2822-compatible string representation of this DateTime, always in UTC * * @example * DateTime.utc(2014, 7, 13).toRFC2822() //=> 'Sun, 13 Jul 2014 00:00:00 +0000' * @example * DateTime.local(2014, 7, 13).toRFC2822() //=> 'Sun, 13 Jul 2014 00:00:00 -0400' */ toRFC2822(): IfValid_2; /** * Returns a string representation of this DateTime appropriate for use in HTTP headers. * Specifically, the string conforms to RFC 1123. * @see https://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3.1 * * @example * DateTime.utc(2014, 7, 13).toHTTP() //=> 'Sun, 13 Jul 2014 00:00:00 GMT' * @example * DateTime.utc(2014, 7, 13, 19).toHTTP() //=> 'Sun, 13 Jul 2014 19:00:00 GMT' */ toHTTP(): IfValid_2; /** * Returns a string representation of this DateTime appropriate for use in SQL Date * * @example * DateTime.utc(2014, 7, 13).toSQLDate() //=> '2014-07-13' */ toSQLDate(): IfValid_2; /** * Returns a string representation of this DateTime appropriate for use in SQL Time * * @example * DateTime.utc().toSQL() //=> '05:15:16.345' * @example * DateTime.now().toSQL() //=> '05:15:16.345 -04:00' * @example * DateTime.now().toSQL({ includeOffset: false }) //=> '05:15:16.345' * @example * DateTime.now().toSQL({ includeZone: false }) //=> '05:15:16.345 America/New_York' */ toSQLTime(opts?: ToSQLOptions_2): IfValid_2; /** * Returns a string representation of this DateTime for use in SQL DateTime * * @example * DateTime.utc(2014, 7, 13).toSQL() //=> '2014-07-13 00:00:00.000 Z' * @example * DateTime.local(2014, 7, 13).toSQL() //=> '2014-07-13 00:00:00.000 -04:00' * @example * DateTime.local(2014, 7, 13).toSQL({ includeOffset: false }) //=> '2014-07-13 00:00:00.000' * @example * DateTime.local(2014, 7, 13).toSQL({ includeZone: true }) //=> '2014-07-13 00:00:00.000 America/New_York' */ toSQL(opts?: ToSQLOptions_2): IfValid_2; /** * Returns a string representation of this DateTime appropriate for debugging */ toString(): IfValid_2; /** * Returns the epoch milliseconds of this DateTime. Alias of {@link DateTime.toMillis} */ valueOf(): IfValid_2; /** * Returns the epoch milliseconds of this DateTime. */ toMillis(): IfValid_2; /** * Returns the epoch seconds of this DateTime. */ toSeconds(): IfValid_2; /** * Returns the epoch seconds (as a whole number) of this DateTime. */ toUnixInteger(): IfValid_2; /** * Returns an ISO 8601 representation of this DateTime appropriate for use in JSON. */ toJSON(): IfValid_2; /** * Returns a BSON-serializable equivalent to this DateTime. */ toBSON(): Date; /** * Returns a JavaScript object with this DateTime's year, month, day, and so on. * * @param opts - options for generating the object * @param opts.includeConfig - include configuration attributes in the output. Defaults to false. * * @example * DateTime.now().toObject() //=> { year: 2017, month: 4, day: 22, hour: 20, minute: 49, second: 42, millisecond: 268 } */ toObject(opts?: { /** * Include configuration attributes in the output * @defaultValue false */ includeConfig?: IncludeConfig; }): ToObjectOutput_2; /** * Returns a JavaScript Date equivalent to this DateTime. */ toJSDate(): Date; // COMPARE /** * Return the difference between two DateTimes as a Duration. * * @param otherDateTime - the DateTime to compare this one to * @param unit - the unit or array of units to include in the duration. * Defaults to ['milliseconds']. * @param opts - options that affect the creation of the Duration * @param opts.conversionAccuracy - the conversion system to use. * Defaults to 'casual'. * * @example * let i1 = DateTime.fromISO('1982-05-25T09:45'), * i2 = DateTime.fromISO('1983-10-14T10:30'); * i2.diff(i1).toObject() //=> { milliseconds: 43807500000 } * i2.diff(i1, 'hours').toObject() //=> { hours: 12168.75 } * i2.diff(i1, ['months', 'days']).toObject() //=> { months: 16, days: 19.03125 } * i2.diff(i1, ['months', 'days', 'hours']).toObject() //=> { months: 16, days: 19, hours: 0.75 } */ diff(otherDateTime: DateTime_2, unit?: DurationUnits_2, opts?: DiffOptions_2): Duration_2; /** * Return the difference between this DateTime and right now. * See {@link DateTime.diff} * * @param unit - the unit(s) to include in the duration. Defaults to ['milliseconds']. * @param opts - options that affect the creation of the Duration * @param opts.conversionAccuracy - the conversion system to use. Defaults to 'casual'. */ diffNow(unit?: DurationUnits_2, opts?: DiffOptions_2): Duration_2; /** * Return an Interval spanning between this DateTime and another DateTime * * @param otherDateTime - the other end point of the Interval */ until(otherDateTime: DateTime_2): IfValid_2, DateTime_2, IsValid>; /** * Return whether this DateTime is in the same unit of time as another DateTime. * Note that time zones are **ignored** in this comparison, which compares the **local** calendar time. Use {@link DateTime.setZone} to convert one of the dates if needed. * * @param otherDateTime - the other DateTime * @param unit - the unit of time to check sameness on * * @example * DateTime.now().hasSame(otherDT, 'day'); //~> true if otherDT is in the same current calendar day */ hasSame(otherDateTime: DateTime_2, unit: DateTimeUnit_2, opts?: HasSameOptions_2): IfValid_2; /** * An equality check. * Two DateTimes are equal if and only if they represent the same millisecond, have the same zone and location, and are both valid. * To compare just the millisecond values, use `+dt1 === +dt2`. * * @param other - the other DateTime */ equals(other: DateTime_2): IfValid_2; /** * Returns a string representation of this time relative to now, such as "in two days". * Can only internationalize if your platform supports Intl.RelativeTimeFormat. * Rounds towards zero by default. * * @example * DateTime.now().plus({ days: 1 }).toRelative() //=> "in 1 day" * @example * DateTime.now().setLocale("es").toRelative({ days: 1 }) //=> "dentro de 1 día" * @example * DateTime.now().plus({ days: 1 }).toRelative({ locale: "fr" }) //=> "dans 23 heures" * @example * DateTime.now().minus({ days: 2 }).toRelative() //=> "2 days ago" * @example * DateTime.now().minus({ days: 2 }).toRelative({ unit: "hours" }) //=> "48 hours ago" * @example * DateTime.now().minus({ hours: 36 }).toRelative({ round: false }) //=> "1.5 days ago" */ toRelative(options?: ToRelativeOptions_2): IfValid_2; /** * Returns a string representation of this date relative to today, such as "yesterday" or "next month". * Only internationalizes on platforms that support Intl.RelativeTimeFormat. * * @example * DateTime.now().plus({ days: 1 }).toRelativeCalendar() //=> "tomorrow" * @example * DateTime.now().setLocale("es").plus({ days: 1 }).toRelative() //=> ""mañana" * @example * DateTime.now().plus({ days: 1 }).toRelativeCalendar({ locale: "fr" }) //=> "demain" * @example * DateTime.now().minus({ days: 2 }).toRelativeCalendar() //=> "2 days ago" */ toRelativeCalendar(options?: ToRelativeCalendarOptions_2): IfValid_2; /** * Return the min of several date times * * @param dateTimes - the DateTimes from which to choose the minimum */ static min(...dateTimes: Values): PickedDateTime_2; /** * Return the max of several date times * * @param dateTimes - the DateTimes from which to choose the maximum */ static max(...dateTimes: Values): PickedDateTime_2; // MISC /** * Explain how a string would be parsed by {@link fromFormat} * * @param text - the string to parse * @param format - the format the string is expected to be in - see {@link Tokens} * @param options - options taken by {@link fromFormat} */ static fromFormatExplain(text: string, format: Tokens_3, options?: DateTimeOptions_2): ExplainedFormat_2; /** * @deprecated use {@link fromFormatExplain} instead */ static fromStringExplain(text: string, format: Tokens_3, options?: DateTimeOptions_2): ExplainedFormat_2; /** * Build a parser for a given format using the given locale. * * This parser can be passed to {@link fromFormatParser} to a parse a date in this format. * This can be used to optimize cases where many dates need to be parsed in a specific format. * * @param format - the format the string is expected to be in - see {@link Tokens} * @param options - the Locale options */ static buildFormatParser(format: Tokens_3, options?: LocaleOptions_2): TokenParser_2; /** * Create a DateTime from an input string and format parser. * * The format parser must have been created with the same locale as this call. * * @param text the string to parse * @param parser - parser from {@link buildFormatParser} * @param options options taken by {@link fromFormat} */ static fromFormatParser(text: string, parser: TokenParser_2, options?: DateTimeOptions_2): DateTimeMaybeValid_2; // FORMAT PRESETS /** * {@link DateTime.toLocaleString} format like 10/14/1983 */ static get DATE_SHORT(): Intl.DateTimeFormatOptions; /** * {@link DateTime.toLocaleString} format like 'Oct 14, 1983' */ static get DATE_MED(): Intl.DateTimeFormatOptions; /** * {@link DateTime.toLocaleString} format like 'Fri, Oct 14, 1983' */ static get DATE_MED_WITH_WEEKDAY(): Intl.DateTimeFormatOptions; /** * {@link DateTime.toLocaleString} format like 'October 14, 1983' */ static get DATE_FULL(): Intl.DateTimeFormatOptions; /** * {@link DateTime.toLocaleString} format like 'Tuesday, October 14, 1983' */ static get DATE_HUGE(): Intl.DateTimeFormatOptions; /** * {@link DateTime.toLocaleString} format like '09:30 AM'. Only 12-hour if the locale is. */ static get TIME_SIMPLE(): Intl.DateTimeFormatOptions; /** * {@link DateTime.toLocaleString} format like '09:30:23 AM'. Only 12-hour if the locale is. */ static get TIME_WITH_SECONDS(): Intl.DateTimeFormatOptions; /** * {@link DateTime.toLocaleString} format like '09:30:23 AM EDT'. Only 12-hour if the locale is. */ static get TIME_WITH_SHORT_OFFSET(): Intl.DateTimeFormatOptions; /** * {@link DateTime.toLocaleString} format like '09:30:23 AM Eastern Daylight Time'. Only 12-hour if the locale is. */ static get TIME_WITH_LONG_OFFSET(): Intl.DateTimeFormatOptions; /** * {@link DateTime.toLocaleString} format like '09:30', always 24-hour. */ static get TIME_24_SIMPLE(): Intl.DateTimeFormatOptions; /** * {@link DateTime.toLocaleString} format like '09:30:23', always 24-hour. */ static get TIME_24_WITH_SECONDS(): Intl.DateTimeFormatOptions; /** * {@link DateTime.toLocaleString} format like '09:30:23 EDT', always 24-hour. */ static get TIME_24_WITH_SHORT_OFFSET(): Intl.DateTimeFormatOptions; /** * {@link DateTime.toLocaleString} format like '09:30:23 Eastern Daylight Time', always 24-hour. */ static get TIME_24_WITH_LONG_OFFSET(): Intl.DateTimeFormatOptions; /** * {@link DateTime.toLocaleString} format like '10/14/1983, 9:30 AM'. Only 12-hour if the locale is. */ static get DATETIME_SHORT(): Intl.DateTimeFormatOptions; /** * {@link DateTime.toLocaleString} format like '10/14/1983, 9:30:33 AM'. Only 12-hour if the locale is. */ static get DATETIME_SHORT_WITH_SECONDS(): Intl.DateTimeFormatOptions; /** * {@link DateTime.toLocaleString} format like 'Oct 14, 1983, 9:30 AM'. Only 12-hour if the locale is. */ static get DATETIME_MED(): Intl.DateTimeFormatOptions; /** * {@link DateTime.toLocaleString} format like 'Oct 14, 1983, 9:30:33 AM'. Only 12-hour if the locale is. */ static get DATETIME_MED_WITH_SECONDS(): Intl.DateTimeFormatOptions; /** * {@link DateTime.toLocaleString} format like 'Fri, 14 Oct 1983, 9:30 AM'. Only 12-hour if the locale is. */ static get DATETIME_MED_WITH_WEEKDAY(): Intl.DateTimeFormatOptions; /** * {@link DateTime.toLocaleString} format like 'October 14, 1983, 9:30 AM EDT'. Only 12-hour if the locale is. */ static get DATETIME_FULL(): Intl.DateTimeFormatOptions; /** * {@link DateTime.toLocaleString} format like 'October 14, 1983, 9:30:33 AM EDT'. Only 12-hour if the locale is. */ static get DATETIME_FULL_WITH_SECONDS(): Intl.DateTimeFormatOptions; /** * {@link DateTime.toLocaleString} format like 'Friday, October 14, 1983, 9:30 AM Eastern Daylight Time'. Only 12-hour if the locale is. */ static get DATETIME_HUGE(): Intl.DateTimeFormatOptions; /** * {@link DateTime.toLocaleString} format like 'Friday, October 14, 1983, 9:30:33 AM Eastern Daylight Time'. Only 12-hour if the locale is. */ static get DATETIME_HUGE_WITH_SECONDS(): Intl.DateTimeFormatOptions; } declare type DateTimeFormatOptions = Intl.DateTimeFormatOptions; declare type DateTimeFormatOptions_2 = Intl.DateTimeFormatOptions; declare type DateTimeJSOptions = Omit; declare type DateTimeJSOptions_2 = Omit; declare type DateTimeMaybeValid = CanBeInvalid extends true ? (DateTime | DateTime) : DateTime; declare type DateTimeMaybeValid_2 = CanBeInvalid_2 extends true ? (DateTime_2 | DateTime_2) : DateTime_2; declare interface DateTimeOptions extends LocaleOptions { /** * Use this zone if no offset is specified in the input string itself. Will also convert the time to this zone. * @default local */ zone?: string | Zone | undefined; /** * Override the zone with a fixed-offset zone specified in the string itself, if it specifies one. * @default false */ setZone?: boolean | undefined; } declare interface DateTimeOptions_2 extends LocaleOptions_2 { /** * Use this zone if no offset is specified in the input string itself. Will also convert the time to this zone. * @default local */ zone?: string | Zone_2 | undefined; /** * Override the zone with a fixed-offset zone specified in the string itself, if it specifies one. * @default false */ setZone?: boolean | undefined; } /** * Schema for datetime validation with comprehensive formatting and comparison methods. * * Extends the base AnySchema to provide datetime-specific validation rules including * comparisons (before/after), weekend/weekday checks, timezone conversions, and * various output formatting options. * * Supports keyword values for intuitive date comparisons like `'today'`, `'yesterday'`, * `'start of month'`, `'next week'`, etc. See {@link Parseable} for full list. * * @template TSchema - The output type after validation and potential transformation * * @example Basic validation with ISO string * ```typescript * const schema: DatetimeSchema = joi.datetime() * .after('2023-01-01') * .toUTC() * .toISO() * * const result = schema.validate('2023-06-15T10:30:00Z') * // Returns ISO string in UTC timezone * ``` * * @example Using keyword values * ```typescript * const schema = joi.datetime() * .after('yesterday') * .before('tomorrow') * .weekday() * * schema.validate('today') // Valid if today is a weekday * ``` * * @example Operator-aware keywords * ```typescript * // 'today' with beforeOrEqual includes the entire day (00:00 - 23:59:59.999) * joi.datetime().beforeOrEqual('today').validate('2023-12-03T23:59:59Z') // Valid * * // 'today' with after starts from beginning of day (00:00:00) * joi.datetime().after('today').validate('2023-12-03T00:00:01Z') // Valid * ``` */ export declare interface DatetimeSchema extends AnySchema { /** * Validates that the datetime is exactly equal to the specified limit. * Uses strict equality comparison (===) between DateTime objects. * * @param limit - The datetime value to compare against * @returns The schema instance for method chaining * * @example * ```typescript * const schema = joi.datetime().exactly('2023-01-01T00:00:00Z') * schema.validate('2023-01-01T00:00:00Z') // Valid * schema.validate('2023-01-01T00:00:01Z') // Invalid * ``` */ exactly(limit: Parseable | Reference): this; /** * Validates that the datetime is equal to the specified limit. * Uses loose equality comparison (==) between DateTime objects. * * @param limit - The datetime value to compare against * @returns The schema instance for method chaining * * @example * ```typescript * const schema = joi.datetime().equals('2023-01-01T00:00:00Z') * schema.validate('2023-01-01T00:00:00.000Z') // Valid (same moment) * ``` */ equals(limit: Parseable | Reference): this; /** * Validates that the datetime is after the specified limit. * * @param limit - The datetime value that the input must be after (supports keywords) * @returns The schema instance for method chaining * * @example With ISO string * ```typescript * const schema = joi.datetime().after('2023-01-01T00:00:00Z') * schema.validate('2023-01-02T00:00:00Z') // Valid * schema.validate('2022-12-31T23:59:59Z') // Invalid * ``` * * @example With keywords * ```typescript * const schema = joi.datetime().after('today') * schema.validate(DateTime.now().plus({ days: 1 })) // Valid * schema.validate(DateTime.now().minus({ days: 1 })) // Invalid * ``` */ after(limit: Parseable | Reference): this; /** * Validates that the datetime is greater than the specified limit. * Alias for `after()`. * * @param limit - The datetime value that the input must be greater than * @returns The schema instance for method chaining */ greater(limit: Parseable | Reference): this; /** * Validates that the datetime is before the specified limit. * * @param limit - The datetime value that the input must be before (supports keywords) * @returns The schema instance for method chaining * * @example With ISO string * ```typescript * const schema = joi.datetime().before('2023-12-31T23:59:59Z') * schema.validate('2023-06-15T12:00:00Z') // Valid * schema.validate('2024-01-01T00:00:00Z') // Invalid * ``` * * @example With keywords * ```typescript * const schema = joi.datetime().before('end of month') * schema.validate(DateTime.now().endOf('month').minus({ hours: 1 })) // Valid * ``` */ before(limit: Parseable | Reference): this; /** * Validates that the datetime is less than the specified limit. * Alias for `before()`. * * @param limit - The datetime value that the input must be less than * @returns The schema instance for method chaining */ less(limit: Parseable | Reference): this; /** * Validates that the datetime is after or equal to the specified limit. * * @param limit - The datetime value that the input must be after or equal to * @returns The schema instance for method chaining * * @example * ```typescript * const schema = joi.datetime().afterOrEqual('2023-01-01T00:00:00Z') * schema.validate('2023-01-01T00:00:00Z') // Valid (equal) * schema.validate('2023-01-02T00:00:00Z') // Valid (after) * schema.validate('2022-12-31T23:59:59Z') // Invalid * ``` */ afterOrEqual(limit: Parseable | Reference): this; /** * Validates that the datetime is greater than or equal to the specified limit. * Alias for `afterOrEqual()`. * * @param limit - The minimum datetime value * @returns The schema instance for method chaining */ min(limit: Parseable | Reference): this; /** * Validates that the datetime is before or equal to the specified limit. * * When using period keywords (e.g., 'today', 'last month'), this method intelligently * uses the end of the period, making "on or before today" include the entire day. * * @param limit - The datetime value that the input must be before or equal to (supports keywords) * @returns The schema instance for method chaining * * @example With ISO string * ```typescript * const schema = joi.datetime().beforeOrEqual('2023-12-31T23:59:59Z') * schema.validate('2023-12-31T23:59:59Z') // Valid (equal) * schema.validate('2023-06-15T12:00:00Z') // Valid (before) * schema.validate('2024-01-01T00:00:00Z') // Invalid * ``` * * @example With keywords (operator-aware) * ```typescript * // 'today' resolves to end of day (23:59:59.999) for intuitive behavior * const schema = joi.datetime().beforeOrEqual('today') * schema.validate(DateTime.now()) // Valid (anytime today) * schema.validate(DateTime.now().plus({ days: 1 })) // Invalid (tomorrow) * ``` */ beforeOrEqual(limit: Parseable | Reference): this; /** * Validates that the datetime is less than or equal to the specified limit. * Alias for `beforeOrEqual()`. * * @param limit - The maximum datetime value * @returns The schema instance for method chaining */ max(limit: Parseable | Reference): this; /** * Validates that the datetime falls on a weekend day. * Based on the configured weekend days in Luxon settings (default: Saturday and Sunday). * * @returns The schema instance for method chaining * * @example * ```typescript * const schema = joi.datetime().weekend() * schema.validate('2023-07-01T12:00:00Z') // Valid if Saturday * schema.validate('2023-07-03T12:00:00Z') // Invalid if Monday * ``` */ weekend(): this; /** * Validates that the datetime falls on a weekday (non-weekend day). * Based on the configured weekend days in Luxon settings. * * @returns The schema instance for method chaining * * @example * ```typescript * const schema = joi.datetime().weekday() * schema.validate('2023-07-03T12:00:00Z') // Valid if Monday * schema.validate('2023-07-01T12:00:00Z') // Invalid if Saturday * ``` */ weekday(): this; /** * Converts the datetime to UTC timezone during validation. * The output will be a DateTime object in UTC. * * @returns The schema instance for method chaining * * @example * ```typescript * const schema = joi.datetime().toUTC() * const result = schema.validate('2023-07-15T10:30:00-05:00') * // Returns DateTime in UTC: 2023-07-15T15:30:00Z * ``` */ toUTC(): this; /** * Converts the datetime to local timezone during validation. * The output will be a DateTime object in the system's local timezone. * * @returns The schema instance for method chaining * * @example * ```typescript * const schema = joi.datetime().toLocal() * const result = schema.validate('2023-07-15T15:30:00Z') * // Returns DateTime in local timezone * ``` */ toLocal(): this; /** * Sets the timezone for the datetime during validation. * * @param zone - The timezone to set (IANA timezone name or Luxon Zone object) * @returns The schema instance for method chaining * * @example * ```typescript * const schema = joi.datetime().setZone('America/New_York') * const result = schema.validate('2023-07-15T15:30:00Z') * // Returns DateTime in Eastern timezone * ``` */ setZone(zone: string | Zone, opts?: ZoneOptions): this; /** * Formats the datetime using a custom format string during validation. * * @param format - The format string (Luxon format tokens) or callback function * @returns The schema instance for method chaining * * @example Static format * ```typescript * const schema = joi.datetime().toFormat('yyyy-MM-dd HH:mm:ss') * const result = schema.validate('2023-07-15T15:30:00Z') * // Returns: "2023-07-15 15:30:00" * ``` * * @example Callback function (serializable) * ```typescript * const schema = joi.datetime().toFormat((dt, helpers) => * dt.year > 2000 ? 'yyyy-MM-dd' : 'MM/dd/yy' * ) * ``` */ toFormat(format: CallbackOrValue): this; /** * Formats the datetime using locale-specific formatting during validation. * * @param formatOpts - Locale formatting options or callback function * @returns The schema instance for method chaining * * @example Static options * ```typescript * const schema = joi.datetime().toLocalizedString({ month: 'long', day: 'numeric' }) * const result = schema.validate('2023-07-15T15:30:00Z') * // Returns: "July 15" (or localized equivalent) * ``` * * @example Callback function (serializable) * ```typescript * const schema = joi.datetime().toLocalizedString((dt, helpers) => ({ * month: dt.month > 6 ? 'long' : 'short', * day: 'numeric' * })) * ``` */ toLocalizedString(formatOpts: CallbackOrValue): this; /** * Converts the datetime to ISO 8601 string format during validation. * * @param opts - Options for ISO string formatting or callback function * @returns The schema instance for method chaining * * @example Static options * ```typescript * const schema = joi.datetime().toISO({ suppressMilliseconds: true }) * const result = schema.validate('July 15, 2023 3:30 PM') * // Returns: "2023-07-15T15:30:00Z" * ``` * * @example Callback function (serializable) * ```typescript * const schema = joi.datetime().toISO((dt, helpers) => ({ * suppressMilliseconds: true, * extendedZone: dt.year > 1970, * precision: 'seconds' * })) * ``` */ toISO(opts?: CallbackOrValue): this; /** * Converts the datetime to ISO date format (YYYY-MM-DD) during validation. * * @param opts - Options for ISO date formatting or callback function * @returns The schema instance for method chaining * * @example Static options * ```typescript * const schema = joi.datetime().toISODate() * const result = schema.validate('July 15, 2023 3:30 PM') * // Returns: "2023-07-15" * ``` * * @example Callback function (serializable) * ```typescript * const schema = joi.datetime().toISODate((dt, helpers) => ({ * format: dt.year > 2000 ? 'extended' : 'basic' * })) * ``` */ toISODate(opts?: CallbackOrValue): this; /** * Converts the datetime to ISO week date format during validation. * * @returns The schema instance for method chaining * * @example * ```typescript * const schema = joi.datetime().toISOWeekDate() * const result = schema.validate('2023-07-15T15:30:00Z') * // Returns: "2023-W28-6" * ``` */ toISOWeekDate(): this; /** * Converts the datetime to ISO time format during validation. * * @param opts - Options for ISO time formatting or callback function * @returns The schema instance for method chaining * * @example Static options * ```typescript * const schema = joi.datetime().toISOTime({ suppressMilliseconds: true }) * const result = schema.validate('2023-07-15T15:30:00Z') * // Returns: "15:30:00Z" * ``` * * @example Callback function (serializable) * ```typescript * const schema = joi.datetime().toISOTime((dt, helpers) => ({ * suppressMilliseconds: dt.millisecond === 0 * })) * ``` */ toISOTime(opts?: CallbackOrValue): this; /** * Converts the datetime to RFC 2822 format during validation. * * @returns The schema instance for method chaining * * @example * ```typescript * const schema = joi.datetime().toRFC2822() * const result = schema.validate('2023-07-15T15:30:00Z') * // Returns: "Sat, 15 Jul 2023 15:30:00 +0000" * ``` */ toRFC2822(): this; /** * Converts the datetime to HTTP date format during validation. * * @returns The schema instance for method chaining * * @example * ```typescript * const schema = joi.datetime().toHTTP() * const result = schema.validate('2023-07-15T15:30:00Z') * // Returns: "Sat, 15 Jul 2023 15:30:00 GMT" * ``` */ toHTTP(): this; /** * Converts the datetime to SQL date format (YYYY-MM-DD) during validation. * * @returns The schema instance for method chaining * * @example * ```typescript * const schema = joi.datetime().toSQLDate() * const result = schema.validate('2023-07-15T15:30:00Z') * // Returns: "2023-07-15" * ``` */ toSQLDate(): this; /** * Converts the datetime to SQL time format (HH:mm:ss.SSS) during validation. * * @param opts - Options for SQL time formatting or callback function * @returns The schema instance for method chaining * * @example Static options * ```typescript * const schema = joi.datetime().toSQLTime({ includeZone: true }) * const result = schema.validate('2023-07-15T15:30:45.123Z') * // Returns: "15:30:45.123 Z" * ``` * * @example Callback function (serializable) * ```typescript * const schema = joi.datetime().toSQLTime((dt, helpers) => ({ * includeZone: dt.zone.name !== 'UTC' * })) * ``` */ toSQLTime(opts?: CallbackOrValue): this; /** * Converts the datetime to SQL datetime format during validation. * * @param opts - Options for SQL formatting or callback function * @returns The schema instance for method chaining * * @example Static options * ```typescript * const schema = joi.datetime().toSQL({ includeZone: false }) * const result = schema.validate('2023-07-15T15:30:45.123Z') * // Returns: "2023-07-15 15:30:45.123" * ``` * * @example Callback function (serializable) * ```typescript * const schema = joi.datetime().toSQL((dt, helpers) => ({ * includeZone: dt.zone.name !== 'UTC' * })) * ``` */ toSQL(opts?: CallbackOrValue): this; /** * Converts the datetime to milliseconds since Unix epoch during validation. * * @returns The schema instance for method chaining * * @example * ```typescript * const schema = joi.datetime().toMillis() * const result = schema.validate('2023-07-15T15:30:00Z') * // Returns: 1689433800000 * ``` */ toMillis(): this; /** * Converts the datetime to seconds since Unix epoch during validation. * * @returns The schema instance for method chaining * * @example * ```typescript * const schema = joi.datetime().toSeconds() * const result = schema.validate('2023-07-15T15:30:00Z') * // Returns: 1689433800.0 * ``` */ toSeconds(): this; /** * Converts the datetime to Unix timestamp (seconds as integer) during validation. * * @returns The schema instance for method chaining * * @example * ```typescript * const schema = joi.datetime().toUnixInteger() * const result = schema.validate('2023-07-15T15:30:00Z') * // Returns: 1689433800 * ``` */ toUnixInteger(): this; /** * Converts the datetime to JSON string format during validation. * * @returns The schema instance for method chaining * * @example * ```typescript * const schema = joi.datetime().toJSON() * const result = schema.validate('2023-07-15T15:30:00Z') * // Returns: "2023-07-15T15:30:00.000Z" * ``` */ toJSON(): this; /** * Converts the datetime to BSON format during validation. * * @returns The schema instance for method chaining * * @example * ```typescript * const schema = joi.datetime().toBSON() * const result = schema.validate('2023-07-15T15:30:00Z') * // Returns: Date object for BSON serialization * ``` */ toBSON(): this; /** * Converts the datetime to a plain object representation during validation. * * @param opts - Options for object conversion or callback function * @returns The schema instance for method chaining * * @example Static options * ```typescript * const schema = joi.datetime().toObject({ includeConfig: true }) * const result = schema.validate('2023-07-15T15:30:00Z') * // Returns: { year: 2023, month: 7, day: 15, hour: 15, minute: 30, second: 0, millisecond: 0 } * ``` * * @example Callback function (serializable) * ```typescript * const schema = joi.datetime().toObject((dt, helpers) => ({ * includeConfig: dt.year > 2000 * })) * ``` */ toObject(opts?: CallbackOrValue<{ includeConfig?: boolean; }>): this; /** * Converts the datetime to a JavaScript Date object during validation. * * @returns The schema instance for method chaining * * @example * ```typescript * const schema = joi.datetime().toJSDate() * const result = schema.validate('2023-07-15T15:30:00Z') * // Returns: Date object * ``` */ toJSDate(): this; /** * Converts the datetime to a relative time string during validation. * * @param opts - Options for relative time formatting or callback function * @returns The schema instance for method chaining * * @example Static options * ```typescript * const schema = joi.datetime().toRelative({ base: DateTime.now() }) * const result = schema.validate('2023-07-15T15:30:00Z') * // Returns: "2 hours ago" (relative to current time) * ``` * * @example Callback function (serializable) * ```typescript * const schema = joi.datetime().toRelative((dt, helpers) => ({ * base: dt.year > 2020 ? DateTime.now() : DateTime.fromISO('2020-01-01') * })) * ``` */ toRelative(opts?: CallbackOrValue): this; /** * Sets the locale for the datetime during validation. * * @param locale - The locale code (e.g., 'en-US', 'fr-FR') * @returns The schema instance for method chaining * * @example * ```typescript * const schema = joi.datetime().setLocale('fr-FR').toLocaleString() * const result = schema.validate('2023-07-15T15:30:00Z') * // Returns localized string in French * ``` */ setLocale(locale: string): this; } declare type DateTimeUnit = "year" | "quarter" | "month" | "week" | "day" | "hour" | "minute" | "second" | "millisecond"; declare type DateTimeUnit_2 = "year" | "quarter" | "month" | "week" | "day" | "hour" | "minute" | "second" | "millisecond"; declare type DayNumbers = | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31; declare type DayNumbers_2 = | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31; /** * Options for database-backed validation helpers such as `uniqueInDb` and `existsInDb`. */ export declare interface DbValidationOptions { /** * Perform case-insensitive comparisons when querying the database. * Defaults to `false`. */ caseInsensitive?: boolean; /** * Optional function that receives the Knex query builder (or equivalent) so * the caller can append additional WHERE clauses (or joins). Can be async. * Example: `async (query, value, column, helpers) => query.where('tenant_id', tenantId)` */ filter?: (queryBuilder: QueryBuilder, value: any, column: string, helpers: Omit) => void | Promise; } /** * Decodes a base64-encoded schema string back into a usable validation schema. * * This function reverses the encoding process, decompressing and parsing the * encoded schema while performing version compatibility checks. It ensures * that schemas encoded with newer versions of the library are rejected to * prevent runtime errors from incompatible schema formats. * * The function handles: * - Base64 decoding and zlib decompression * - Version compatibility validation using semantic versioning * - Backward compatibility with legacy encoding formats * - Input validation and error handling * - Schema reconstruction using Joi's build method * * @param base64 - The base64-encoded schema string * @param options - Decoding options * @returns A reconstructed validation schema ready for validation * @throws {TypeError} When the encoded string is not a valid schema * @throws {TypeError} When the schema version is invalid or incompatible * * @example Basic Usage * ```typescript * import { decode } from './utils' * * const encodedSchema = "eJyrVkosLcmIz8nPS1WyUvJIzcnJT..." * const schema = decode(encodedSchema) * * // Use the decoded schema for validation * const result = schema.validate({ name: "John", age: 30 }) * ``` * * @example Error Handling * ```typescript * try { * const schema = decode(untrustedEncodedString) * // Use schema safely * } catch (error) { * if (error instanceof TypeError) { * console.error('Invalid or incompatible schema:', error.message) * } * } * ``` * * @example Version Compatibility * ```typescript * // Schema encoded with v2.1.0, current version is v2.0.0 * const futureSchema = "..." // Contains version 2.1.0 * decode(futureSchema) // Throws: Schema version 2.1.0 is not compatible * * // Schema encoded with v1.9.0, current version is v2.0.0 * const oldSchema = "..." // Contains version 1.9.0 * const schema = decode(oldSchema) // Works - backward compatible * ``` * * @security * **IMPORTANT: Only decode schemas from trusted sources.** * * Decoded schemas may contain serialized functions that are evaluated using the * Function constructor. Never decode schemas from: * - User input or user-controlled data * - Untrusted third-party APIs * - Any source you do not control * * If the schema source is not under your direct control, validate its integrity * using cryptographic signatures or checksums before decoding. * * @see {@link encode} For encoding schemas into transportable strings */ export declare const decode: (base64: string, options?: EncoderOptions) => Schema; export declare type DefaultableValue = Reference | BasicType | DateTime | bigint | Phone | ((parent: any, helpers: CustomHelpers) => Reference | BasicType | DateTime | Phone | bigint); declare type DefaultValidity = CanBeInvalid extends true ? boolean : true; declare type DefaultValidity_2 = CanBeInvalid_2 extends true ? boolean : true; export declare interface DependencyOptions extends HierarchySeparatorOptions { /** * overrides the default check for a present value. * * @default (resolved) => resolved !== undefined */ isPresent?: (resolved: any) => boolean } export declare interface Description { type?: Types | string label?: string description?: string flags?: object notes?: string[] tags?: string[] metas?: any[] example?: any[] valids?: any[] invalids?: any[] unit?: string options?: ValidationOptions [key: string]: any } declare interface DiffOptions { /** * @default 'casual' */ conversionAccuracy?: ConversionAccuracy | undefined; } declare interface DiffOptions_2 { /** * @default 'casual' */ conversionAccuracy?: ConversionAccuracy_2 | undefined; } export declare interface DomainOptions { /** * if `true`, domains ending with a `.` character are permitted * * @default false */ allowFullyQualified?: boolean /** * If `true`, Unicode characters are permitted * * @default true */ allowUnicode?: boolean /** * If `true`, underscores (`_`) are allowed in the domain name * * @default false */ allowUnderscore?: boolean /** * Options for TLD (top level domain) validation. By default, the TLD must be a valid name listed on the [IANA registry](http://data.iana.org/TLD/tlds-alpha-by-domain.txt) * * @default { allow: true } */ tlds?: TopLevelDomainOptions | false /** * Number of segments required for the domain. * * @default 2 */ minDomainSegments?: number /** * The maximum number of domain segments (e.g. `x.y.z` has 3 segments) allowed. Defaults to no limit. * * @default Infinity */ maxDomainSegments?: number } declare interface DomainOptions_2 { /** * Determines whether Unicode characters are allowed. * * @default true */ readonly allowUnicode?: boolean; /** * Determines whether underscore (_) characters are allowed. * * @default false */ readonly allowUnderscore?: boolean; /** * The maximum number of domain segments (e.g. `x.y.z` has 3 segments) allowed. * * @default Infinity */ readonly maxDomainSegments?: number; /** * The minimum number of domain segments (e.g. `x.y.z` has 3 segments) required. * * @default 2 */ readonly minDomainSegments?: number; /** * Top-level-domain options * * @default true */ readonly tlds?: TldsAllow | TldsDeny; /** * Allows passing fully qualified domain (ends with a period) * * @default false */ readonly allowFullyQualified?: boolean; } /** * A Duration object represents a period of time, like "2 months" or "1 day, 1 hour". * Conceptually, it is just a map of units to their quantities, accompanied by some additional configuration and methods for creating, parsing, interrogating, transforming, and formatting them. * They can be used on their own or in conjunction with other Luxon types; for example, you can use {@link DateTime.plus} to add a Duration object to a DateTime, producing another DateTime. * * Here is a brief overview of commonly used methods and getters in Duration: * * * **Creation** To create a Duration, use {@link Duration.fromMillis}, {@link Duration.fromObject}, or {@link Duration.fromISO}. * * **Unit values** See the {@link Duration#years}, {@link Duration.months}, {@link Duration#weeks}, {@link Duration#days}, {@link Duration#hours}, {@link Duration#minutes}, * * {@link Duration#seconds}, {@link Duration#milliseconds} accessors. * * **Configuration** See {@link Duration#locale} and {@link Duration#numberingSystem} accessors. * * **Transformation** To create new Durations out of old ones use {@link Duration#plus}, {@link Duration#minus}, {@link Duration#normalize}, {@link Duration#set}, {@link Duration#reconfigure}, * * {@link Duration#shiftTo}, and {@link Duration#negate}. * * **Output** To convert the Duration into other representations, see {@link Duration#as}, {@link Duration#toISO}, {@link Duration#toFormat}, and {@link Duration#toJSON} * * There's are more methods documented below. In addition, for more information on subtler topics like internationalization and validity, see the external documentation. */ declare class Duration { /** * Create Duration from a number of milliseconds. * * @param count - of milliseconds * @param opts - options for parsing * @param opts.locale - the locale to use * @param opts.numberingSystem - the numbering system to use * @param opts.conversionAccuracy - the conversion system to use */ static fromMillis(count: number, opts?: DurationOptions): Duration; /** * Create a Duration from a JavaScript object with keys like 'years' and 'hours'. * If this object is empty then a zero milliseconds duration is returned. * * @param obj - the object to create the Duration from * @param obj.years * @param obj.quarters * @param obj.months * @param obj.weeks * @param obj.days * @param obj.hours * @param obj.minutes * @param obj.seconds * @param obj.milliseconds * @param opts - options for creating this Duration. Defaults to {}. * @param opts.locale - the locale to use. Defaults to 'en-US'. * @param opts.numberingSystem - the numbering system to use * @param opts.conversionAccuracy - the conversion system to use. Defaults to 'casual'. */ static fromObject(obj: DurationLikeObject, opts?: DurationOptions): Duration; /** * Create a Duration from DurationLike. * * @param durationLike * Either a Luxon Duration, a number of milliseconds, or the object argument to Duration.fromObject() */ static fromDurationLike(durationLike: DurationLike): Duration; /** * Create a Duration from an ISO 8601 duration string. * @see https://en.wikipedia.org/wiki/ISO_8601#Durations * * @param text - text to parse * @param opts - options for parsing * @param opts.locale - the locale to use. Defaults to 'en-US'. * @param opts.numberingSystem - the numbering system to use * @param opts.conversionAccuracy - the conversion system to use. Defaults to 'casual'. * * @example * Duration.fromISO('P3Y6M1W4DT12H30M5S').toObject() //=> { years: 3, months: 6, weeks: 1, days: 4, hours: 12, minutes: 30, seconds: 5 } * @example * Duration.fromISO('PT23H').toObject() //=> { hours: 23 } * @example * Duration.fromISO('P5Y3M').toObject() //=> { years: 5, months: 3 } */ static fromISO(text: string, opts?: DurationOptions): DurationMaybeValid; /** * Create a Duration from an ISO 8601 time string. * @see https://en.wikipedia.org/wiki/ISO_8601#Times * * @param text - text to parse * @param opts - options for parsing * @param opts.locale - the locale to use. Defaults to 'en-US'. * @param opts.numberingSystem - the numbering system to use * @param opts.conversionAccuracy - the conversion system to use. Defaults to 'casual'. * * @example * Duration.fromISOTime('11:22:33.444').toObject() //=> { hours: 11, minutes: 22, seconds: 33, milliseconds: 444 } * @example * Duration.fromISOTime('11:00').toObject() //=> { hours: 11, minutes: 0, seconds: 0 } * @example * Duration.fromISOTime('T11:00').toObject() //=> { hours: 11, minutes: 0, seconds: 0 } * @example * Duration.fromISOTime('1100').toObject() //=> { hours: 11, minutes: 0, seconds: 0 } * @example * Duration.fromISOTime('T1100').toObject() //=> { hours: 11, minutes: 0, seconds: 0 } */ static fromISOTime(text: string, opts?: DurationOptions): DurationMaybeValid; /** * Create an invalid Duration. * * @param reason - simple string of why this datetime is invalid. Should not contain parameters or anything else data-dependent * @param explanation - longer explanation, may include parameters and other useful debugging information. Defaults to null. */ static invalid(reason: string, explanation?: string): Duration; /** * Check if an object is a Duration. Works across context boundaries * * @param o */ static isDuration(o: unknown): o is DurationMaybeValid; private constructor(config: unknown); /** * Get the locale of a Duration, such as 'en-GB' */ get locale(): IfValid; /** * Get the numbering system of a Duration, such as 'beng'. The numbering system is used when formatting the Duration */ get numberingSystem(): IfValid; /** * Returns a string representation of this Duration formatted according to the specified format string. You may use these tokens: * * `S` for milliseconds * * `s` for seconds * * `m` for minutes * * `h` for hours * * `d` for days * * `M` for months * * `y` for years * Notes: * * Add padding by repeating the token, e.g. "yy" pads the years to two digits, "hhhh" pads the hours out to four digits * * The duration will be converted to the set of units in the format string using {@link Duration.shiftTo} and the Duration's conversion accuracy setting. * * @example * Duration.fromObject({ years: 1, days: 6, seconds: 2 }).toFormat("y d s") //=> "1 6 2" * @example * Duration.fromObject({ years: 1, days: 6, seconds: 2 }).toFormat("yy dd sss") //=> "01 06 002" * @example * Duration.fromObject({ years: 1, days: 6, seconds: 2 }).toFormat("M S") //=> "12 518402000" * @example * Duration.fromObject({ days: 6, seconds: 2 }).toFormat("d s", { signMode: "all" }) //=> "+6 +2" * @example * Duration.fromObject({ days: -6, seconds: -2 }).toFormat("d s", { signMode: "all" }) //=> "-6 -2" * @example * Duration.fromObject({ days: -6, seconds: -2 }).toFormat("d s", { signMode: "negativeLargestOnly" }) //=> "-6 2" */ toFormat(fmt: string, opts?: DurationFormatOptions): IfValid; /** * Returns a string representation of a Duration with all units included * To modify its behavior use the `listStyle` and any Intl.NumberFormat option, though `unitDisplay` is especially relevant. See {@link Intl.NumberFormat}. * * @example * ```js * var dur = Duration.fromObject({ months: 1, weeks: 0, hours: 5, minutes: 6 }) * dur.toHuman() //=> '1 month, 0 weeks, 5 hours, 6 minutes' * dur.toHuman({ listStyle: "long" }) //=> '1 month, 0 weeks, 5 hours, and 6 minutes' * dur.toHuman({ unitDisplay: "short" }) //=> '1 mth, 0 wks, 5 hr, 6 min' * dur.toHuman({ showZeros: false }) //=> '1 month, 5 hours, 6 minutes' * ``` */ toHuman(opts?: ToHumanDurationOptions): string; /** * Returns a JavaScript object with this Duration's values. * * @example * Duration.fromObject({ years: 1, days: 6, seconds: 2 }).toObject() //=> { years: 1, days: 6, seconds: 2 } */ toObject(): DurationObjectUnits; /** * Returns an ISO 8601-compliant string representation of this Duration. * @see https://en.wikipedia.org/wiki/ISO_8601#Durations * * @example * Duration.fromObject({ years: 3, seconds: 45 }).toISO() //=> 'P3YT45S' * @example * Duration.fromObject({ months: 4, seconds: 45 }).toISO() //=> 'P4MT45S' * @example * Duration.fromObject({ months: 5 }).toISO() //=> 'P5M' * @example * Duration.fromObject({ minutes: 5 }).toISO() //=> 'PT5M' * @example * Duration.fromObject({ milliseconds: 6 }).toISO() //=> 'PT0.006S' */ toISO(): IfValid; /** * Returns an ISO 8601-compliant string representation of this Duration, formatted as a time of day. * @see https://en.wikipedia.org/wiki/ISO_8601#Times * * @param opts - options * @param opts.suppressMilliseconds - exclude milliseconds from the format if they are 0. Defaults to false. * @param opts.suppressSeconds - exclude seconds from the format if they're 0. Defaults to false. * @param opts.includePrefix - include the `T` prefix. Defaults to false. * @param opts.format - choose between the basic and extended format. Defaults to 'extended'. * * @example * Duration.fromObject({ hours: 11 }).toISOTime() //=> '11:00:00.000' * @example * Duration.fromObject({ hours: 11 }).toISOTime({ suppressMilliseconds: true }) //=> '11:00:00' * @example * Duration.fromObject({ hours: 11 }).toISOTime({ suppressSeconds: true }) //=> '11:00' * @example * Duration.fromObject({ hours: 11 }).toISOTime({ includePrefix: true }) //=> 'T11:00:00.000' * @example * Duration.fromObject({ hours: 11 }).toISOTime({ format: 'basic' }) //=> '110000.000' */ toISOTime(opts?: ToISOTimeDurationOptions): IfValid; /** * Returns an ISO 8601 representation of this Duration appropriate for use in JSON. */ toJSON(): IfValid; /** * Returns an ISO 8601 representation of this Duration appropriate for use in debugging. */ toString(): IfValid; /** * Returns a millisecond value of this Duration. */ toMillis(): IfValid; /** * Returns a millisecond value of this Duration. Alias of {@link toMillis} */ valueOf(): IfValid; /** * Make this Duration longer by the specified amount. Return a newly-constructed Duration. * * @param duration - The amount to add. Either a Luxon Duration, a number of milliseconds, the object argument to Duration.fromObject() */ plus(duration: DurationLike): this; /** * Make this Duration shorter by the specified amount. Return a newly-constructed Duration. * * @param duration - The amount to subtract. Either a Luxon Duration, a number of milliseconds, the object argument to Duration.fromObject() */ minus(duration: DurationLike): this; /** * Scale this Duration by the specified amount. Return a newly-constructed Duration. * * @example * Duration.fromObject({ hours: 1, minutes: 30 }).mapUnit(x => x * 2) //=> { hours: 2, minutes: 60 } * @example * Duration.fromObject({ hours: 1, minutes: 30 }).mapUnit((x, u) => u === "hour" ? x * 2 : x) //=> { hours: 2, minutes: 30 } */ mapUnits(fn: (x: number, u?: DurationUnit) => number): this; /** * Get the value of unit. * * @param unit - a unit such as 'minute' or 'day' * * @example * Duration.fromObject({years: 2, days: 3}).get('years') //=> 2 * @example * Duration.fromObject({years: 2, days: 3}).get('months') //=> 0 * @example * Duration.fromObject({years: 2, days: 3}).get('days') //=> 3 */ get(unit: DurationUnit): IfValid; /** * "Set" the values of specified units. Return a newly-constructed Duration. * * @param values - a mapping of units to numbers * * @example * dur.set({ years: 2017 }) * @example * dur.set({ hours: 8, minutes: 30 }) */ set(values: DurationLikeObject): this; /** * "Set" the locale and/or numberingSystem. Returns a newly-constructed Duration. * * @example * dur.reconfigure({ locale: 'en-GB' }) */ reconfigure(opts?: DurationOptions): this; /** * Return the length of the duration in the specified unit. * * @param unit - a unit such as 'minutes' or 'days' * * @example * Duration.fromObject({years: 1}).as('days') //=> 365 * @example * Duration.fromObject({years: 1}).as('months') //=> 12 * @example * Duration.fromObject({hours: 60}).as('days') //=> 2.5 */ as(unit: DurationUnit): IfValid; /** * Reduce this Duration to its canonical representation in its current units. * * @example * Duration.fromObject({ years: 2, days: 5000 }).normalize().toObject() //=> { years: 15, days: 255 } * @example * Duration.fromObject({ hours: 12, minutes: -45 }).normalize().toObject() //=> { hours: 11, minutes: 15 } */ normalize(): this; /** * Rescale units to its largest representation. * * @example * Duration.fromObject({ milliseconds: 90000 }).rescale().toObject() //=> { minutes: 1, seconds: 30 } */ rescale(): this; /** * Convert this Duration into its representation in a different set of units. * * @example * Duration.fromObject({ hours: 1, seconds: 30 }).shiftTo('minutes', 'milliseconds').toObject() //=> { minutes: 60, milliseconds: 30000 } */ shiftTo(...units: DurationUnit[]): this; /** * Shift this Duration to all available units. * Same as shiftTo("years", "months", "weeks", "days", "hours", "minutes", "seconds", "milliseconds") */ shiftToAll(): this; /** * Return the negative of this Duration. * * @example * Duration.fromObject({ hours: 1, seconds: 30 }).negate().toObject() //=> { hours: -1, seconds: -30 } */ negate(): this; /** * Removes all units with values equal to 0 from this Duration. * * @example * Duration.fromObject({ years: 2, days: 0, hours: 0, minutes: 0 }).removeZeros().toObject() //=> { years: 2 } */ removeZeros(): this; /** * Get the years. */ get years(): IfValid; /** * Get the quarters. */ get quarters(): IfValid; /** * Get the months. */ get months(): IfValid; /** * Get the weeks */ get weeks(): IfValid; /** * Get the days. */ get days(): IfValid; /** * Get the hours. */ get hours(): IfValid; /** * Get the minutes. */ get minutes(): IfValid; /** * Get the seconds. */ get seconds(): IfValid; /** * Get the milliseconds. */ get milliseconds(): IfValid; /** * Returns whether the Duration is invalid. * Diff operations on invalid DateTimes or Intervals return invalid Durations. */ get isValid(): IfValid; /** * Returns an error code if this Duration became invalid, or null if the Duration is valid */ get invalidReason(): IfValid; /** * Returns an explanation of why this Duration became invalid, or null if the Duration is valid */ get invalidExplanation(): IfValid; /** * Equality check * Two Durations are equal iff they have the same units and the same values for each unit. */ equals(other: Duration): IfValid; } /** * A Duration object represents a period of time, like "2 months" or "1 day, 1 hour". * Conceptually, it is just a map of units to their quantities, accompanied by some additional configuration and methods for creating, parsing, interrogating, transforming, and formatting them. * They can be used on their own or in conjunction with other Luxon types; for example, you can use {@link DateTime.plus} to add a Duration object to a DateTime, producing another DateTime. * * Here is a brief overview of commonly used methods and getters in Duration: * * * **Creation** To create a Duration, use {@link Duration.fromMillis}, {@link Duration.fromObject}, or {@link Duration.fromISO}. * * **Unit values** See the {@link Duration#years}, {@link Duration.months}, {@link Duration#weeks}, {@link Duration#days}, {@link Duration#hours}, {@link Duration#minutes}, * * {@link Duration#seconds}, {@link Duration#milliseconds} accessors. * * **Configuration** See {@link Duration#locale} and {@link Duration#numberingSystem} accessors. * * **Transformation** To create new Durations out of old ones use {@link Duration#plus}, {@link Duration#minus}, {@link Duration#normalize}, {@link Duration#set}, {@link Duration#reconfigure}, * * {@link Duration#shiftTo}, and {@link Duration#negate}. * * **Output** To convert the Duration into other representations, see {@link Duration#as}, {@link Duration#toISO}, {@link Duration#toFormat}, and {@link Duration#toJSON} * * There's are more methods documented below. In addition, for more information on subtler topics like internationalization and validity, see the external documentation. */ declare class Duration_2 { /** * Create Duration from a number of milliseconds. * * @param count - of milliseconds * @param opts - options for parsing * @param opts.locale - the locale to use * @param opts.numberingSystem - the numbering system to use * @param opts.conversionAccuracy - the conversion system to use */ static fromMillis(count: number, opts?: DurationOptions_2): Duration_2; /** * Create a Duration from a JavaScript object with keys like 'years' and 'hours'. * If this object is empty then a zero milliseconds duration is returned. * * @param obj - the object to create the Duration from * @param obj.years * @param obj.quarters * @param obj.months * @param obj.weeks * @param obj.days * @param obj.hours * @param obj.minutes * @param obj.seconds * @param obj.milliseconds * @param opts - options for creating this Duration. Defaults to {}. * @param opts.locale - the locale to use. Defaults to 'en-US'. * @param opts.numberingSystem - the numbering system to use * @param opts.conversionAccuracy - the conversion system to use. Defaults to 'casual'. */ static fromObject(obj: DurationLikeObject_2, opts?: DurationOptions_2): Duration_2; /** * Create a Duration from DurationLike. * * @param durationLike * Either a Luxon Duration, a number of milliseconds, or the object argument to Duration.fromObject() */ static fromDurationLike(durationLike: DurationLike_2): Duration_2; /** * Create a Duration from an ISO 8601 duration string. * @see https://en.wikipedia.org/wiki/ISO_8601#Durations * * @param text - text to parse * @param opts - options for parsing * @param opts.locale - the locale to use. Defaults to 'en-US'. * @param opts.numberingSystem - the numbering system to use * @param opts.conversionAccuracy - the conversion system to use. Defaults to 'casual'. * * @example * Duration.fromISO('P3Y6M1W4DT12H30M5S').toObject() //=> { years: 3, months: 6, weeks: 1, days: 4, hours: 12, minutes: 30, seconds: 5 } * @example * Duration.fromISO('PT23H').toObject() //=> { hours: 23 } * @example * Duration.fromISO('P5Y3M').toObject() //=> { years: 5, months: 3 } */ static fromISO(text: string, opts?: DurationOptions_2): DurationMaybeValid_2; /** * Create a Duration from an ISO 8601 time string. * @see https://en.wikipedia.org/wiki/ISO_8601#Times * * @param text - text to parse * @param opts - options for parsing * @param opts.locale - the locale to use. Defaults to 'en-US'. * @param opts.numberingSystem - the numbering system to use * @param opts.conversionAccuracy - the conversion system to use. Defaults to 'casual'. * * @example * Duration.fromISOTime('11:22:33.444').toObject() //=> { hours: 11, minutes: 22, seconds: 33, milliseconds: 444 } * @example * Duration.fromISOTime('11:00').toObject() //=> { hours: 11, minutes: 0, seconds: 0 } * @example * Duration.fromISOTime('T11:00').toObject() //=> { hours: 11, minutes: 0, seconds: 0 } * @example * Duration.fromISOTime('1100').toObject() //=> { hours: 11, minutes: 0, seconds: 0 } * @example * Duration.fromISOTime('T1100').toObject() //=> { hours: 11, minutes: 0, seconds: 0 } */ static fromISOTime(text: string, opts?: DurationOptions_2): DurationMaybeValid_2; /** * Create an invalid Duration. * * @param reason - simple string of why this datetime is invalid. Should not contain parameters or anything else data-dependent * @param explanation - longer explanation, may include parameters and other useful debugging information. Defaults to null. */ static invalid(reason: string, explanation?: string): Duration_2; /** * Check if an object is a Duration. Works across context boundaries * * @param o */ static isDuration(o: unknown): o is DurationMaybeValid_2; private constructor(config: unknown); /** * Get the locale of a Duration, such as 'en-GB' */ get locale(): IfValid_2; /** * Get the numbering system of a Duration, such as 'beng'. The numbering system is used when formatting the Duration */ get numberingSystem(): IfValid_2; /** * Returns a string representation of this Duration formatted according to the specified format string. You may use these tokens: * * `S` for milliseconds * * `s` for seconds * * `m` for minutes * * `h` for hours * * `d` for days * * `M` for months * * `y` for years * Notes: * * Add padding by repeating the token, e.g. "yy" pads the years to two digits, "hhhh" pads the hours out to four digits * * The duration will be converted to the set of units in the format string using {@link Duration.shiftTo} and the Duration's conversion accuracy setting. * * @example * Duration.fromObject({ years: 1, days: 6, seconds: 2 }).toFormat("y d s") //=> "1 6 2" * @example * Duration.fromObject({ years: 1, days: 6, seconds: 2 }).toFormat("yy dd sss") //=> "01 06 002" * @example * Duration.fromObject({ years: 1, days: 6, seconds: 2 }).toFormat("M S") //=> "12 518402000" * @example * Duration.fromObject({ days: 6, seconds: 2 }).toFormat("d s", { signMode: "all" }) //=> "+6 +2" * @example * Duration.fromObject({ days: -6, seconds: -2 }).toFormat("d s", { signMode: "all" }) //=> "-6 -2" * @example * Duration.fromObject({ days: -6, seconds: -2 }).toFormat("d s", { signMode: "negativeLargestOnly" }) //=> "-6 2" */ toFormat(fmt: string, opts?: DurationFormatOptions_2): IfValid_2; /** * Returns a string representation of a Duration with all units included * To modify its behavior use the `listStyle` and any Intl.NumberFormat option, though `unitDisplay` is especially relevant. See {@link Intl.NumberFormat}. * * @example * ```js * var dur = Duration.fromObject({ months: 1, weeks: 0, hours: 5, minutes: 6 }) * dur.toHuman() //=> '1 month, 0 weeks, 5 hours, 6 minutes' * dur.toHuman({ listStyle: "long" }) //=> '1 month, 0 weeks, 5 hours, and 6 minutes' * dur.toHuman({ unitDisplay: "short" }) //=> '1 mth, 0 wks, 5 hr, 6 min' * dur.toHuman({ showZeros: false }) //=> '1 month, 5 hours, 6 minutes' * ``` */ toHuman(opts?: ToHumanDurationOptions_2): string; /** * Returns a JavaScript object with this Duration's values. * * @example * Duration.fromObject({ years: 1, days: 6, seconds: 2 }).toObject() //=> { years: 1, days: 6, seconds: 2 } */ toObject(): DurationObjectUnits_2; /** * Returns an ISO 8601-compliant string representation of this Duration. * @see https://en.wikipedia.org/wiki/ISO_8601#Durations * * @example * Duration.fromObject({ years: 3, seconds: 45 }).toISO() //=> 'P3YT45S' * @example * Duration.fromObject({ months: 4, seconds: 45 }).toISO() //=> 'P4MT45S' * @example * Duration.fromObject({ months: 5 }).toISO() //=> 'P5M' * @example * Duration.fromObject({ minutes: 5 }).toISO() //=> 'PT5M' * @example * Duration.fromObject({ milliseconds: 6 }).toISO() //=> 'PT0.006S' */ toISO(): IfValid_2; /** * Returns an ISO 8601-compliant string representation of this Duration, formatted as a time of day. * @see https://en.wikipedia.org/wiki/ISO_8601#Times * * @param opts - options * @param opts.suppressMilliseconds - exclude milliseconds from the format if they are 0. Defaults to false. * @param opts.suppressSeconds - exclude seconds from the format if they're 0. Defaults to false. * @param opts.includePrefix - include the `T` prefix. Defaults to false. * @param opts.format - choose between the basic and extended format. Defaults to 'extended'. * * @example * Duration.fromObject({ hours: 11 }).toISOTime() //=> '11:00:00.000' * @example * Duration.fromObject({ hours: 11 }).toISOTime({ suppressMilliseconds: true }) //=> '11:00:00' * @example * Duration.fromObject({ hours: 11 }).toISOTime({ suppressSeconds: true }) //=> '11:00' * @example * Duration.fromObject({ hours: 11 }).toISOTime({ includePrefix: true }) //=> 'T11:00:00.000' * @example * Duration.fromObject({ hours: 11 }).toISOTime({ format: 'basic' }) //=> '110000.000' */ toISOTime(opts?: ToISOTimeDurationOptions_2): IfValid_2; /** * Returns an ISO 8601 representation of this Duration appropriate for use in JSON. */ toJSON(): IfValid_2; /** * Returns an ISO 8601 representation of this Duration appropriate for use in debugging. */ toString(): IfValid_2; /** * Returns a millisecond value of this Duration. */ toMillis(): IfValid_2; /** * Returns a millisecond value of this Duration. Alias of {@link toMillis} */ valueOf(): IfValid_2; /** * Make this Duration longer by the specified amount. Return a newly-constructed Duration. * * @param duration - The amount to add. Either a Luxon Duration, a number of milliseconds, the object argument to Duration.fromObject() */ plus(duration: DurationLike_2): this; /** * Make this Duration shorter by the specified amount. Return a newly-constructed Duration. * * @param duration - The amount to subtract. Either a Luxon Duration, a number of milliseconds, the object argument to Duration.fromObject() */ minus(duration: DurationLike_2): this; /** * Scale this Duration by the specified amount. Return a newly-constructed Duration. * * @example * Duration.fromObject({ hours: 1, minutes: 30 }).mapUnit(x => x * 2) //=> { hours: 2, minutes: 60 } * @example * Duration.fromObject({ hours: 1, minutes: 30 }).mapUnit((x, u) => u === "hour" ? x * 2 : x) //=> { hours: 2, minutes: 30 } */ mapUnits(fn: (x: number, u?: DurationUnit_2) => number): this; /** * Get the value of unit. * * @param unit - a unit such as 'minute' or 'day' * * @example * Duration.fromObject({years: 2, days: 3}).get('years') //=> 2 * @example * Duration.fromObject({years: 2, days: 3}).get('months') //=> 0 * @example * Duration.fromObject({years: 2, days: 3}).get('days') //=> 3 */ get(unit: DurationUnit_2): IfValid_2; /** * "Set" the values of specified units. Return a newly-constructed Duration. * * @param values - a mapping of units to numbers * * @example * dur.set({ years: 2017 }) * @example * dur.set({ hours: 8, minutes: 30 }) */ set(values: DurationLikeObject_2): this; /** * "Set" the locale and/or numberingSystem. Returns a newly-constructed Duration. * * @example * dur.reconfigure({ locale: 'en-GB' }) */ reconfigure(opts?: DurationOptions_2): this; /** * Return the length of the duration in the specified unit. * * @param unit - a unit such as 'minutes' or 'days' * * @example * Duration.fromObject({years: 1}).as('days') //=> 365 * @example * Duration.fromObject({years: 1}).as('months') //=> 12 * @example * Duration.fromObject({hours: 60}).as('days') //=> 2.5 */ as(unit: DurationUnit_2): IfValid_2; /** * Reduce this Duration to its canonical representation in its current units. * * @example * Duration.fromObject({ years: 2, days: 5000 }).normalize().toObject() //=> { years: 15, days: 255 } * @example * Duration.fromObject({ hours: 12, minutes: -45 }).normalize().toObject() //=> { hours: 11, minutes: 15 } */ normalize(): this; /** * Rescale units to its largest representation. * * @example * Duration.fromObject({ milliseconds: 90000 }).rescale().toObject() //=> { minutes: 1, seconds: 30 } */ rescale(): this; /** * Convert this Duration into its representation in a different set of units. * * @example * Duration.fromObject({ hours: 1, seconds: 30 }).shiftTo('minutes', 'milliseconds').toObject() //=> { minutes: 60, milliseconds: 30000 } */ shiftTo(...units: DurationUnit_2[]): this; /** * Shift this Duration to all available units. * Same as shiftTo("years", "months", "weeks", "days", "hours", "minutes", "seconds", "milliseconds") */ shiftToAll(): this; /** * Return the negative of this Duration. * * @example * Duration.fromObject({ hours: 1, seconds: 30 }).negate().toObject() //=> { hours: -1, seconds: -30 } */ negate(): this; /** * Removes all units with values equal to 0 from this Duration. * * @example * Duration.fromObject({ years: 2, days: 0, hours: 0, minutes: 0 }).removeZeros().toObject() //=> { years: 2 } */ removeZeros(): this; /** * Get the years. */ get years(): IfValid_2; /** * Get the quarters. */ get quarters(): IfValid_2; /** * Get the months. */ get months(): IfValid_2; /** * Get the weeks */ get weeks(): IfValid_2; /** * Get the days. */ get days(): IfValid_2; /** * Get the hours. */ get hours(): IfValid_2; /** * Get the minutes. */ get minutes(): IfValid_2; /** * Get the seconds. */ get seconds(): IfValid_2; /** * Get the milliseconds. */ get milliseconds(): IfValid_2; /** * Returns whether the Duration is invalid. * Diff operations on invalid DateTimes or Intervals return invalid Durations. */ get isValid(): IfValid_2; /** * Returns an error code if this Duration became invalid, or null if the Duration is valid */ get invalidReason(): IfValid_2; /** * Returns an explanation of why this Duration became invalid, or null if the Duration is valid */ get invalidExplanation(): IfValid_2; /** * Equality check * Two Durations are equal iff they have the same units and the same values for each unit. */ equals(other: Duration_2): IfValid_2; } declare interface DurationFormatOptions { /** * Whether or not to floor numerical values. * @default true */ floor?: boolean | undefined; /** * How to handle signs * @default 'negative' */ signMode?: "negative" | "all" | "negativeLargestOnly" | undefined; } declare interface DurationFormatOptions_2 { /** * Whether or not to floor numerical values. * @default true */ floor?: boolean | undefined; /** * How to handle signs * @default 'negative' */ signMode?: "negative" | "all" | "negativeLargestOnly" | undefined; } /** * Either a Luxon Duration, a number of milliseconds, the object argument to Duration.fromObject() */ declare type DurationLike = Duration | DurationLikeObject | number; /** * Either a Luxon Duration, a number of milliseconds, the object argument to Duration.fromObject() */ declare type DurationLike_2 = Duration_2 | DurationLikeObject_2 | number; declare interface DurationLikeObject extends DurationObjectUnits { year?: number | undefined; quarter?: number | undefined; month?: number | undefined; week?: number | undefined; day?: number | undefined; hour?: number | undefined; minute?: number | undefined; second?: number | undefined; millisecond?: number | undefined; } declare interface DurationLikeObject_2 extends DurationObjectUnits_2 { year?: number | undefined; quarter?: number | undefined; month?: number | undefined; week?: number | undefined; day?: number | undefined; hour?: number | undefined; minute?: number | undefined; second?: number | undefined; millisecond?: number | undefined; } declare type DurationMaybeValid = CanBeInvalid extends true ? (Duration | Duration) : Duration; declare type DurationMaybeValid_2 = CanBeInvalid_2 extends true ? (Duration_2 | Duration_2) : Duration_2; declare interface DurationObjectUnits { years?: number | undefined; quarters?: number | undefined; months?: number | undefined; weeks?: number | undefined; days?: number | undefined; hours?: number | undefined; minutes?: number | undefined; seconds?: number | undefined; milliseconds?: number | undefined; } declare interface DurationObjectUnits_2 { years?: number | undefined; quarters?: number | undefined; months?: number | undefined; weeks?: number | undefined; days?: number | undefined; hours?: number | undefined; minutes?: number | undefined; seconds?: number | undefined; milliseconds?: number | undefined; } declare interface DurationOptions { locale?: string | undefined; numberingSystem?: NumberingSystem | undefined; conversionAccuracy?: ConversionAccuracy | undefined; } declare interface DurationOptions_2 { locale?: string | undefined; numberingSystem?: NumberingSystem_2 | undefined; conversionAccuracy?: ConversionAccuracy_2 | undefined; } declare type DurationUnit = keyof DurationLikeObject; declare type DurationUnit_2 = keyof DurationLikeObject_2; declare type DurationUnits = DurationUnit | DurationUnit[]; declare type DurationUnits_2 = DurationUnit_2 | DurationUnit_2[]; export declare interface EmailOptions { /** * if `true`, domains ending with a `.` character are permitted * * @default false */ allowFullyQualified?: boolean /** * If `true`, Unicode characters are permitted * * @default true */ allowUnicode?: boolean /** * If `true`, underscores (`_`) are allowed in the domain name * * @default false */ allowUnderscore?: boolean /** * if `true`, ignore invalid email length errors. * * @default false */ ignoreLength?: boolean /** * if true, allows multiple email addresses in a single string, separated by , or the separator characters. * * @default false */ multiple?: boolean /** * when multiple is true, overrides the default , separator. String can be a single character or multiple separator characters. * * @default ',' */ separator?: string | string[] /** * Options for TLD (top level domain) validation. By default, the TLD must be a valid name listed on the [IANA registry](http://data.iana.org/TLD/tlds-alpha-by-domain.txt) * * @default { allow: true } */ tlds?: TopLevelDomainOptions | false /** * Number of segments required for the domain. Be careful since some domains, such as `io`, directly allow email. * * @default 2 */ minDomainSegments?: number /** * The maximum number of domain segments (e.g. `x.y.z` has 3 segments) allowed. Defaults to no limit. * * @default Infinity */ maxDomainSegments?: number } declare interface EmailOptions_2 extends DomainOptions_2 { /** * Determines whether to ignore the standards maximum email length limit. * * @default false */ readonly ignoreLength?: boolean; } /** * Encodes a validation schema into a compressed, base64-encoded string for transport between environments. * * This function serializes a validation schema description along with version information, * compresses it using zlib, and encodes it as a base64 string. This enables efficient * transfer of validation schemas between frontend and backend environments while * maintaining version compatibility. * * The encoded string includes: * - Current library version for compatibility checking * - Complete schema description from `schema.describe()` * - Zlib compression for minimal payload size * - Base64 encoding for web-safe transport * * @param schema - The validation schema to encode * @returns A compressed, base64-encoded string representing the schema * * @example Basic Usage * ```typescript * import Joi from 'joi' * import { encode } from './utils' * * const schema = Joi.object({ * name: Joi.string().required(), * age: Joi.number().min(0) * }) * * const encoded = encode(schema) * // Returns: "eJyrVkosLcmIz8nPS1WyUvJIzcnJT..." * ``` * * @example Cross-Environment Transfer * ```typescript * // Backend * const validationSchema = Joi.object({ * email: Joi.string().email().required() * }) * const encodedSchema = encode(validationSchema) * * // Send to frontend via API * response.json({ schema: encodedSchema }) * * // Frontend can then decode and use the same validation * ``` * * @see {@link decode} For decoding schemas from encoded strings */ export declare const encode: (schema: Schema, options?: EncoderOptions) => string; /** * Options for encoding and decoding validation schemas. * * These options control what gets serialized when encoding schemas and how * they're reconstructed during decoding. The defaults prioritize security * and are designed for the most common use case: sharing validation rules * between frontend and backend environments. */ declare type EncoderOptions = { /** * Include database connections and database validation rules in the encoded schema. * * When `false` (default): * - Database connections (`.knex()`, `.db()`) are stripped from the encoded schema * - Database validation rules (`.uniqueInDb()`, `.existsInDb()`) are converted to no-ops * - Filter functions in database rules are replaced with empty functions * - This prevents credential leakage and reduces payload size * * When `true`: * - Database connection configurations are serialized (if they're plain objects) * - Database validation rules and their filter functions are preserved * - **Security warning**: Only use this in trusted backend-to-backend communication * - Encoded schemas will require re-attaching database connections after decoding * * **Why this defaults to `false`:** * 1. **Security**: Prevents accidental exposure of database credentials in client-side code * 2. **Use case alignment**: Frontend validation typically doesn't need database rules * 3. **Credential safety**: Database connections often contain sensitive connection strings * 4. **Function security**: Custom filter functions may contain business logic or credentials * * @default false * * @example Frontend/Backend Schema Sharing (default) * ```typescript * // Backend * const schema = joi.object({ * email: joi.string().email().uniqueInDb('users', 'email') * }).knex(db) * * const encoded = encode(schema) // withDatabase defaults to false * // Database rules are stripped, safe to send to frontend * * // Frontend receives and decodes * const frontendSchema = decode(encoded) * // Only gets email format validation, no database checks * ``` * * @example Backend-to-Backend Schema Transfer * ```typescript * // Service A * const schema = joi.object({ * username: joi.string().uniqueInDb('users', 'username', { * filter: async (query) => query.where('tenant_id', tenantId) * }) * }).knex({ client: 'pg', connection: { host: 'localhost', ... } }) * * const encoded = encode(schema, { withDatabase: true }) * // Sends to trusted Service B * * // Service B * const decoded = decode(encoded, { withDatabase: true }) * const rehydrated = decoded.knex(serviceB_db_connection) * // Now has full database validation capabilities * ``` */ withDatabase?: boolean; }; declare type EndOfOptions = _UseLocaleWeekOption; declare type EndOfOptions_2 = _UseLocaleWeekOption_2; export declare interface Err { toString(): string } declare const errorCodes: { EMPTY_STRING: string; FORBIDDEN_UNICODE: string; MULTIPLE_AT_CHAR: string; MISSING_AT_CHAR: string; EMPTY_LOCAL: string; ADDRESS_TOO_LONG: string; LOCAL_TOO_LONG: string; EMPTY_LOCAL_SEGMENT: string; INVALID_LOCAL_CHARS: string; DOMAIN_NON_EMPTY_STRING: string; DOMAIN_TOO_LONG: string; DOMAIN_INVALID_UNICODE_CHARS: string; DOMAIN_INVALID_CHARS: string; DOMAIN_INVALID_TLDS_CHARS: string; DOMAIN_SEGMENTS_COUNT: string; DOMAIN_SEGMENTS_COUNT_MAX: string; DOMAIN_FORBIDDEN_TLDS: string; DOMAIN_EMPTY_SEGMENT: string; DOMAIN_LONG_SEGMENT: string; }; export declare interface ErrorFormattingOptions { /** * when true, error message templates will escape special characters to HTML entities, for security purposes. * * @default false */ escapeHtml?: boolean /** * defines the value used to set the label context variable. */ label?: 'path' | 'key' | false /** * The preferred language code for error messages. * The value is matched against keys at the root of the messages object, and then the error code as a child key of that. * Can be a reference to the value, global context, or local context which is the root value passed to the validation function. * * Note that references to the value are usually not what you want as they move around the value structure relative to where the error happens. * Instead, either use the global context, or the absolute value (e.g. `Joi.ref('/variable')`) */ language?: keyof LanguageMessages /** * when false, skips rendering error templates. Useful when error messages are generated elsewhere to save processing time. * * @default true */ render?: boolean /** * when true, the main error will possess a stack trace, otherwise it will be disabled. * Defaults to false for performances reasons. Has no effect on platforms other than V8/node.js as it uses the Stack trace API. * * @default false */ stack?: boolean /** * overrides the way values are wrapped (e.g. `[]` around arrays, `""` around labels). * Each key can be set to a string with one (same character before and after the value) or two characters (first character * before and second character after), or `false` to disable wrapping. */ wrap?: { /** * the characters used around `{#label}` references. Defaults to `'"'`. * * @default '"' */ label?: string | false /** * the characters used around array values. Defaults to `'[]'` * * @default '[]' */ array?: string | false /** * the characters used around array string values. Defaults to no wrapping. * * @default false */ string?: string | false } } export declare interface ErrorReport extends Error { code: string flags: Record path: string[] prefs: ErrorValidationOptions messages: LanguageMessages state: State value: any local: any } export declare interface ErrorValidationOptions extends BaseValidationOptions { messages?: Record } declare interface ExplainedFormat { input: string; tokens: Array<{ literal: boolean; val: string }>; regex?: RegExp | undefined; rawMatches?: RegExpMatchArray | null | undefined; matches?: { [k: string]: any } | undefined; result?: { [k: string]: any } | null | undefined; zone?: Zone | null | undefined; invalidReason?: string | undefined; } declare interface ExplainedFormat_2 { input: string; tokens: Array<{ literal: boolean; val: string }>; regex?: RegExp | undefined; rawMatches?: RegExpMatchArray | null | undefined; matches?: { [k: string]: any } | undefined; result?: { [k: string]: any } | null | undefined; zone?: Zone_2 | null | undefined; invalidReason?: string | undefined; } declare interface Expression { /** The CIDR mode. */ cidr: Cidr; /** The raw regular expression string. */ raw: string; /** The regular expression. */ regex: RegExp; /** The array of versions allowed. */ versions: Version[]; } declare interface Expression_2 { /** The raw regular expression string. */ raw: string; /** The regular expression. */ regex: RegExp; /** The specified URI scheme */ scheme: string | null; } export declare interface Extension { type: string | RegExp args?(...args: SchemaLike_2[]): Schema_2 base?: Schema_2 coerce?: CoerceFunction | CoerceObject flags?: Record manifest?: { build?(obj: ExtensionBoundSchema, desc: Record): any } messages?: LanguageMessages | string modifiers?: Record any> overrides?: Record Schema_2> prepare?(value: any, helpers: CustomHelpers): any rebuild?(schema: ExtensionBoundSchema): void rules?: Record> terms?: Record validate?(value: any, helpers: CustomHelpers): any /** * undocumented options */ cast?: Record properties?: Record } export declare type ExtensionBoundSchema = Schema_2 & SchemaInternals export declare type ExtensionFactory = (joi: Root) => Extension export declare interface ExtensionFlag { setter?: string default?: any } export declare interface ExtensionRule { /** * alternative name for this rule. */ alias?: string /** * whether rule supports multiple invocations. */ multi?: boolean /** * Dual rule: converts or validates. */ convert?: boolean /** * list of arguments accepted by `method`. */ args?: Array /** * rule body. */ method?: RuleMethod | false /** * validation function. */ validate?(value: any, helpers: any, args: Record, options: any): any /** * undocumented flags. */ priority?: boolean manifest?: boolean } export declare interface ExtensionTerm { init: any[] | null register?: any manifest?: Record } export declare interface ExtensionTermManifest { mapped: { from: string to: string } } export declare interface ExternalHelpers { schema: ExtensionBoundSchema linked: ExtensionBoundSchema | null state: State prefs: ValidationOptions original: V warn: (code: string, local?: ValidationContext) => void error: (code: string, local?: ValidationContext) => ErrorReport message: (messages: LanguageMessages, local?: ValidationContext) => ErrorReport } export declare type ExternalValidationFunction = ( value: V, helpers: ExternalHelpers ) => R | undefined export declare namespace formula { export { Parser, Options_3 as Options } } /** * Schema type for function validation. * * @public */ export declare interface FunctionSchema extends ObjectSchema { /** * Specifies the arity of the function where: * @param n - the arity expected. */ arity(n: number): this; /** * Requires the function to be a class. */ class(): this; /** * Specifies the minimal arity of the function where: * @param n - the minimal arity expected. */ minArity(n: number): this; /** * Specifies the minimal arity of the function where: * @param n - the minimal arity expected. */ maxArity(n: number): this; } declare interface FunctionSchema_2 extends ObjectSchema_2 { /** * Specifies the arity of the function where: * @param n - the arity expected. */ arity(n: number): this /** * Requires the function to be a class. */ class(): this /** * Specifies the minimal arity of the function where: * @param n - the minimal arity expected. */ minArity(n: number): this /** * Specifies the minimal arity of the function where: * @param n - the minimal arity expected. */ maxArity(n: number): this } export declare interface GetRuleOptions { args?: Record method?: string name: string operator?: string } declare namespace guards { export { isInstanceOf, isPlainObject, isDateObjectUnits, isArray, isLuxonDateTime } } export { guards } export declare interface GuidOptions { version?: GuidVersions[] | GuidVersions separator?: boolean | '-' | ':' /** * Defines the allowed or required GUID wrapper characters where: * - `undefined` - (default) the GUID can be optionally wrapped with `{}`, `[]`, or `()`. The opening and closing characters must be a matching pair. * - `true` - the GUID must be wrapped with `{}`, `[]`, or `()`. The opening and closing characters must be a matching pair. * - `false` - wrapper characters are not allowed. * - `'['`, `'{'`, or `'('` - a specific wrapper is required (e.g., if `wrapper` is `'['`, the GUID must be enclosed in square brackets). */ wrapper?: true | false | '[' | '{' | '(' | undefined } export declare type GuidVersions = | 'uuidv1' | 'uuidv2' | 'uuidv3' | 'uuidv4' | 'uuidv5' | 'uuidv6' | 'uuidv7' | 'uuidv8' declare type HasSameOptions = _UseLocaleWeekOption; declare type HasSameOptions_2 = _UseLocaleWeekOption_2; export declare interface HexOptions { /** * hex decoded representation must be byte aligned. * @default false */ byteAligned?: boolean /** * controls whether the prefix `0x` or `0X` is allowed (or required) on hex strings. * When `true`, the prefix must be provided. * When `false`, the prefix is forbidden. * When `optional`, the prefix is allowed but not required. * * @default false */ prefix?: boolean | 'optional' } export declare interface HierarchySeparatorOptions { /** * overrides the default `.` hierarchy separator. Set to false to treat the key as a literal value. * * @default '.' */ separator?: string | false } declare type HourNumbers = | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23; declare type HourNumbers_2 = | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23; /** * Callback function type for internationalization translation. * * This function is responsible for translating validation message keys into * localized strings. It receives a message term (like 'string.min') and should * return the translated message in the appropriate language. * * @param term - The message key to translate (e.g., 'string.base', 'number.min') * @returns The translated message string, or the original term if translation fails * * @example * ```typescript * const translateToSpanish: I18nCallback = (term: string) => { * const translations = { * 'string.base': 'debe ser una cadena de texto', * 'number.min': 'debe ser mayor o igual a {{#limit}}' * } * return translations[term] || term * } * ``` */ export declare interface I18nCallback { (term: string): string; } declare type IfValid = ThisIsValid extends true ? ValidType : ThisIsValid extends false ? InvalidType : CanBeInvalid extends true ? ValidType | InvalidType : ValidType; declare type IfValid_2 = ThisIsValid extends true ? ValidType : ThisIsValid extends false ? InvalidType : CanBeInvalid_2 extends true ? ValidType | InvalidType : ValidType; /** * An Interval object represents a half-open interval of time, where each endpoint is a {@link DateTime}. * Conceptually, it is a container for those two endpoints, accompanied by methods for * creating, parsing, interrogating, comparing, transforming, and formatting them. * * Here is a brief overview of the most commonly used methods and getters in Interval: * * * **Creation** To create an Interval, use {@link Interval.fromDateTimes}, {@link Interval.after}, {@link Interval.before}, or {@link Interval.fromISO}. * * **Accessors** Use {@link Interval#start} and {@link Interval#end} to get the start and end. * * **Interrogation** To analyze the Interval, use {@link Interval#count}, {@link Interval#length}, {@link Interval#hasSame}, * * {@link Interval#contains}, {@link Interval#isAfter}, or {@link Interval#isBefore}. * * **Transformation** To create other Intervals out of this one, use {@link Interval#set}, {@link Interval#splitAt}, {@link Interval#splitBy}, {@link Interval#divideEqually}, * * {@link Interval.merge}, {@link Interval.xor}, {@link Interval#union}, {@link Interval#intersection}, or {@link Interval#difference}. * * **Comparison** To compare this Interval to another one, use {@link Interval#equals}, {@link Interval#overlaps}, {@link Interval#abutsStart}, {@link Interval#abutsEnd}, {@link Interval#engulfs} * * **Output** To convert the Interval into other representations, see {@link Interval#toString}, {@link Interval#toLocaleString}, {@link Interval#toISO}, {@link Interval#toISODate}, * * {@link Interval#toISOTime}, {@link Interval#toFormat}, and {@link Interval#toDuration}. */ declare class Interval { /** * Create an invalid Interval. * * @param reason - simple string of why this Interval is invalid. Should not contain parameters or anything else data-dependent * @param explanation - longer explanation, may include parameters and other useful debugging information. */ static invalid(reason: string, explanation?: string): Interval; /** * Create an Interval from a start DateTime and an end DateTime. Inclusive of the start but not the end. * * @param start * @param end */ static fromDateTimes(start: DateInput, end: DateInput): IntervalMaybeValid; /** * Create an Interval from a start DateTime and a Duration to extend to. * * @param start * @param duration - the length of the Interval. */ static after(start: DateInput, duration: DurationLike): IntervalMaybeValid; /** * Create an Interval from an end DateTime and a Duration to extend backwards to. * * @param end * @param duration - the length of the Interval. */ static before(end: DateInput, duration: DurationLike): IntervalMaybeValid; /** * Create an Interval from an ISO 8601 string. * Accepts `/`, `/`, and `/` formats. * @see https://en.wikipedia.org/wiki/ISO_8601#Time_intervals * * @param text - the ISO string to parse * @param opts - options to pass {@link DateTime.fromISO} and optionally {@link Duration.fromISO} */ static fromISO(text: string, opts?: DateTimeOptions): IntervalMaybeValid; /** * Check if an object is an Interval. Works across context boundaries * * @param o */ static isInterval(o: unknown): o is IntervalMaybeValid; private constructor(config: unknown); /** * Returns the start of the Interval */ get start(): IfValid, null, IsValid>; /** * Returns the end of the Interval. This is the first instant which is not part of the interval. * (Interval is half-open). */ get end(): IfValid, null, IsValid>; /** * Returns the last DateTime included in the interval (since end is not part of the interval) */ get lastDateTime(): IfValid, null, IsValid>; /** * Returns whether this Interval's end is at least its start, meaning that the Interval isn't 'backwards'. */ get isValid(): IfValid; /** * Returns an error code if this Interval is invalid, or null if the Interval is valid */ get invalidReason(): IfValid; /** * Returns an explanation of why this Interval became invalid, or null if the Interval is valid */ get invalidExplanation(): IfValid; /** * Returns the length of the Interval in the specified unit. * * @param unit - the unit (such as 'hours' or 'days') to return the length in. */ length(unit?: DurationUnit): IfValid; /** * Returns the count of minutes, hours, days, months, or years included in the Interval, even in part. * Unlike {@link Interval#length} this counts sections of the calendar, not periods of time, e.g. specifying 'day' * asks 'what dates are included in this interval?', not 'how many days long is this interval?' * * @param unit - the unit of time to count. Defaults to 'milliseconds'. */ count(unit?: DurationUnit, opts?: CountOptions): IfValid; /** * Returns whether this Interval's start and end are both in the same unit of time * * @param unit - the unit of time to check sameness on */ hasSame(unit: DurationUnit): IfValid; /** * Return whether this Interval has the same start and end DateTimes. */ isEmpty(): boolean; /** * Return whether this Interval's start is after the specified DateTime. * * @param dateTime */ isAfter(dateTime: DateTime): IfValid; /** * Return whether this Interval's end is before the specified DateTime. * * @param dateTime */ isBefore(dateTime: DateTime): IfValid; /** * Return whether this Interval contains the specified DateTime. * * @param dateTime */ contains(dateTime: DateTime): IfValid; /** * "Sets" the start and/or end dates. Returns a newly-constructed Interval. * * @param values - the values to set * @param values.start - the starting DateTime * @param values.end - the ending DateTime */ set(values?: IntervalObject): IntervalMaybeValid; /** * Split this Interval at each of the specified DateTimes * * @param dateTimes - the unit of time to count. */ splitAt(...dateTimes: DateTime[]): IfValid; /** * Split this Interval into smaller Intervals, each of the specified length. * Left over time is grouped into a smaller interval * * @param duration - The length of each resulting interval. */ splitBy(duration: DurationLike): IfValid; /** * Split this Interval into the specified number of smaller intervals. * * @param numberOfParts - The number of Intervals to divide the Interval into. */ divideEqually(numberOfParts: number): IfValid; /** * Return whether this Interval overlaps with the specified Interval */ overlaps(other: Interval): boolean; /** * Return whether this Interval's end is adjacent to the specified Interval's start. */ abutsStart(other: Interval): IfValid; /** * Return whether this Interval's start is adjacent to the specified Interval's end. */ abutsEnd(other: Interval): IfValid; /** * Return whether this Interval engulfs the start and end of the specified Interval. */ engulfs(other: Interval): IfValid; /** * Return whether this Interval has the same start and end as the specified Interval. */ equals(other: Interval): IfValid; /** * Return an Interval representing the intersection of this Interval and the specified Interval. * Specifically, the resulting Interval has the maximum start time and the minimum end time of the two Intervals. * Returns null if the intersection is empty, meaning the intervals do not intersect. */ intersection(other: Interval): Interval | null; /** * Return an Interval representing the union of this Interval and the specified Interval. * Specifically, the resulting Interval has the minimum start time and the maximum end time of the two Intervals. */ union(other: Interval): IntervalMaybeValid; /** * Merge an array of Intervals into an equivalent minimal set of Intervals. * Combines overlapping and adjacent Intervals. */ static merge(intervals: Interval[]): IntervalMaybeValid[]; /** * Return an array of Intervals representing the spans of time that only appear in one of the specified Intervals. */ static xor(intervals: Interval[]): IntervalMaybeValid[]; /** * Return Intervals representing the spans of time in this Interval that not overlap with any of the specified Intervals. */ difference(...intervals: Interval[]): IntervalMaybeValid[]; /** * Returns a string representation of this Interval appropriate for debugging. */ toString(): IfValid; /** * Returns a localized string representing this Interval. Accepts the same options as the * Intl.DateTimeFormat constructor and any presets defined by Luxon, such as * {@link DateTime.DATE_FULL} or {@link DateTime.TIME_SIMPLE}. The exact behavior of this method * is browser-specific, but in general it will return an appropriate representation of the * Interval in the assigned locale. Defaults to the system's locale if no locale has been * specified. * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat * @param formatOpts - Either a DateTime preset or Intl.DateTimeFormat constructor options. Defaults to DateTime.DATE_SHORT * @param opts - Options to override the configuration of the start DateTime. * * @example * Interval.fromISO('2022-11-07T09:00Z/2022-11-08T09:00Z').toLocaleString(); //=> 11/7/2022 – 11/8/2022 * @example * Interval.fromISO('2022-11-07T09:00Z/2022-11-08T09:00Z').toLocaleString(DateTime.DATE_FULL); //=> November 7 – 8, 2022 * @example * Interval.fromISO('2022-11-07T09:00Z/2022-11-08T09:00Z').toLocaleString(DateTime.DATE_FULL, { locale: 'fr-FR' }); //=> 7–8 novembre 2022 * @example * Interval.fromISO('2022-11-07T17:00Z/2022-11-07T19:00Z').toLocaleString(DateTime.TIME_SIMPLE); //=> 6:00 – 8:00 PM * @example * Interval.fromISO("2022-11-07T17:00Z/2022-11-07T19:00Z").toLocaleString({ * weekday: "short", * month: "short", * day: "2-digit", * hour: "2-digit", * minute: "2-digit", * }); //=> Mon, Nov 07, 6:00 – 8:00 p */ toLocaleString( formatOpts?: Intl.DateTimeFormatOptions, opts?: LocaleOptions, ): IfValid; /** * Returns an ISO 8601-compliant string representation of this Interval. * @see https://en.wikipedia.org/wiki/ISO_8601#Time_intervals * * @param opts - The same options as {@link DateTime#toISO} */ toISO(opts?: ToISOTimeOptions): IfValid; /** * Returns an ISO 8601-compliant string representation of the dates in this Interval. * The time components are ignored. * @see https://en.wikipedia.org/wiki/ISO_8601#Time_intervals */ toISODate(): IfValid; /** * Returns an ISO 8601-compliant string representation of the times in this Interval. * The date components are ignored. * @see https://en.wikipedia.org/wiki/ISO_8601#Time_intervals * * @param opts - The same options as {@link DateTime.toISO} */ toISOTime(opts?: ToISOTimeOptions): IfValid; /** * Returns a string representation of this Interval formatted according to the specified format string. * * @param dateFormat - the format string. This string formats the start and end time. See {@link DateTime.toFormat} for details. * @param opts - options * @param opts.separator - a separator to place between the start and end representations. Defaults to ' - '. */ toFormat( dateFormat: string, opts?: { separator?: string | undefined; }, ): IfValid; /** * Return a Duration representing the time spanned by this interval. * * @param unit - the unit or units (such as 'hours' or 'days') to include in the duration. Defaults to ['milliseconds']. * @param opts - options that affect the creation of the Duration * @param opts.conversionAccuracy - the conversion system to use. Defaults to 'casual'. * * @example * Interval.fromDateTimes(dt1, dt2).toDuration().toObject() //=> { milliseconds: 88489257 } * @example * Interval.fromDateTimes(dt1, dt2).toDuration('days').toObject() //=> { days: 1.0241812152777778 } * @example * Interval.fromDateTimes(dt1, dt2).toDuration(['hours', 'minutes']).toObject() //=> { hours: 24, minutes: 34.82095 } * @example * Interval.fromDateTimes(dt1, dt2).toDuration(['hours', 'minutes', 'seconds']).toObject() //=> { hours: 24, minutes: 34, seconds: 49.257 } * @example * Interval.fromDateTimes(dt1, dt2).toDuration('seconds').toObject() //=> { seconds: 88489.257 } */ toDuration(unit?: DurationUnit | DurationUnit[], opts?: DiffOptions): DurationMaybeValid; /** * Run mapFn on the interval start and end, returning a new Interval from the resulting DateTimes * * @example * Interval.fromDateTimes(dt1, dt2).mapEndpoints(endpoint => endpoint.toUTC()) * @example * Interval.fromDateTimes(dt1, dt2).mapEndpoints(endpoint => endpoint.plus({ hours: 2 })) */ mapEndpoints(mapFn: (d: DateTime) => DateTime): IntervalMaybeValid; } /** * An Interval object represents a half-open interval of time, where each endpoint is a {@link DateTime}. * Conceptually, it is a container for those two endpoints, accompanied by methods for * creating, parsing, interrogating, comparing, transforming, and formatting them. * * Here is a brief overview of the most commonly used methods and getters in Interval: * * * **Creation** To create an Interval, use {@link Interval.fromDateTimes}, {@link Interval.after}, {@link Interval.before}, or {@link Interval.fromISO}. * * **Accessors** Use {@link Interval#start} and {@link Interval#end} to get the start and end. * * **Interrogation** To analyze the Interval, use {@link Interval#count}, {@link Interval#length}, {@link Interval#hasSame}, * * {@link Interval#contains}, {@link Interval#isAfter}, or {@link Interval#isBefore}. * * **Transformation** To create other Intervals out of this one, use {@link Interval#set}, {@link Interval#splitAt}, {@link Interval#splitBy}, {@link Interval#divideEqually}, * * {@link Interval.merge}, {@link Interval.xor}, {@link Interval#union}, {@link Interval#intersection}, or {@link Interval#difference}. * * **Comparison** To compare this Interval to another one, use {@link Interval#equals}, {@link Interval#overlaps}, {@link Interval#abutsStart}, {@link Interval#abutsEnd}, {@link Interval#engulfs} * * **Output** To convert the Interval into other representations, see {@link Interval#toString}, {@link Interval#toLocaleString}, {@link Interval#toISO}, {@link Interval#toISODate}, * * {@link Interval#toISOTime}, {@link Interval#toFormat}, and {@link Interval#toDuration}. */ declare class Interval_2 { /** * Create an invalid Interval. * * @param reason - simple string of why this Interval is invalid. Should not contain parameters or anything else data-dependent * @param explanation - longer explanation, may include parameters and other useful debugging information. */ static invalid(reason: string, explanation?: string): Interval_2; /** * Create an Interval from a start DateTime and an end DateTime. Inclusive of the start but not the end. * * @param start * @param end */ static fromDateTimes(start: DateInput_2, end: DateInput_2): IntervalMaybeValid_2; /** * Create an Interval from a start DateTime and a Duration to extend to. * * @param start * @param duration - the length of the Interval. */ static after(start: DateInput_2, duration: DurationLike_2): IntervalMaybeValid_2; /** * Create an Interval from an end DateTime and a Duration to extend backwards to. * * @param end * @param duration - the length of the Interval. */ static before(end: DateInput_2, duration: DurationLike_2): IntervalMaybeValid_2; /** * Create an Interval from an ISO 8601 string. * Accepts `/`, `/`, and `/` formats. * @see https://en.wikipedia.org/wiki/ISO_8601#Time_intervals * * @param text - the ISO string to parse * @param opts - options to pass {@link DateTime.fromISO} and optionally {@link Duration.fromISO} */ static fromISO(text: string, opts?: DateTimeOptions_2): IntervalMaybeValid_2; /** * Check if an object is an Interval. Works across context boundaries * * @param o */ static isInterval(o: unknown): o is IntervalMaybeValid_2; private constructor(config: unknown); /** * Returns the start of the Interval */ get start(): IfValid_2, null, IsValid>; /** * Returns the end of the Interval. This is the first instant which is not part of the interval. * (Interval is half-open). */ get end(): IfValid_2, null, IsValid>; /** * Returns the last DateTime included in the interval (since end is not part of the interval) */ get lastDateTime(): IfValid_2, null, IsValid>; /** * Returns whether this Interval's end is at least its start, meaning that the Interval isn't 'backwards'. */ get isValid(): IfValid_2; /** * Returns an error code if this Interval is invalid, or null if the Interval is valid */ get invalidReason(): IfValid_2; /** * Returns an explanation of why this Interval became invalid, or null if the Interval is valid */ get invalidExplanation(): IfValid_2; /** * Returns the length of the Interval in the specified unit. * * @param unit - the unit (such as 'hours' or 'days') to return the length in. */ length(unit?: DurationUnit_2): IfValid_2; /** * Returns the count of minutes, hours, days, months, or years included in the Interval, even in part. * Unlike {@link Interval#length} this counts sections of the calendar, not periods of time, e.g. specifying 'day' * asks 'what dates are included in this interval?', not 'how many days long is this interval?' * * @param unit - the unit of time to count. Defaults to 'milliseconds'. */ count(unit?: DurationUnit_2, opts?: CountOptions_2): IfValid_2; /** * Returns whether this Interval's start and end are both in the same unit of time * * @param unit - the unit of time to check sameness on */ hasSame(unit: DurationUnit_2): IfValid_2; /** * Return whether this Interval has the same start and end DateTimes. */ isEmpty(): boolean; /** * Return whether this Interval's start is after the specified DateTime. * * @param dateTime */ isAfter(dateTime: DateTime_2): IfValid_2; /** * Return whether this Interval's end is before the specified DateTime. * * @param dateTime */ isBefore(dateTime: DateTime_2): IfValid_2; /** * Return whether this Interval contains the specified DateTime. * * @param dateTime */ contains(dateTime: DateTime_2): IfValid_2; /** * "Sets" the start and/or end dates. Returns a newly-constructed Interval. * * @param values - the values to set * @param values.start - the starting DateTime * @param values.end - the ending DateTime */ set(values?: IntervalObject_2): IntervalMaybeValid_2; /** * Split this Interval at each of the specified DateTimes * * @param dateTimes - the unit of time to count. */ splitAt(...dateTimes: DateTime_2[]): IfValid_2; /** * Split this Interval into smaller Intervals, each of the specified length. * Left over time is grouped into a smaller interval * * @param duration - The length of each resulting interval. */ splitBy(duration: DurationLike_2): IfValid_2; /** * Split this Interval into the specified number of smaller intervals. * * @param numberOfParts - The number of Intervals to divide the Interval into. */ divideEqually(numberOfParts: number): IfValid_2; /** * Return whether this Interval overlaps with the specified Interval */ overlaps(other: Interval_2): boolean; /** * Return whether this Interval's end is adjacent to the specified Interval's start. */ abutsStart(other: Interval_2): IfValid_2; /** * Return whether this Interval's start is adjacent to the specified Interval's end. */ abutsEnd(other: Interval_2): IfValid_2; /** * Return whether this Interval engulfs the start and end of the specified Interval. */ engulfs(other: Interval_2): IfValid_2; /** * Return whether this Interval has the same start and end as the specified Interval. */ equals(other: Interval_2): IfValid_2; /** * Return an Interval representing the intersection of this Interval and the specified Interval. * Specifically, the resulting Interval has the maximum start time and the minimum end time of the two Intervals. * Returns null if the intersection is empty, meaning the intervals do not intersect. */ intersection(other: Interval_2): Interval_2 | null; /** * Return an Interval representing the union of this Interval and the specified Interval. * Specifically, the resulting Interval has the minimum start time and the maximum end time of the two Intervals. */ union(other: Interval_2): IntervalMaybeValid_2; /** * Merge an array of Intervals into an equivalent minimal set of Intervals. * Combines overlapping and adjacent Intervals. */ static merge(intervals: Interval_2[]): IntervalMaybeValid_2[]; /** * Return an array of Intervals representing the spans of time that only appear in one of the specified Intervals. */ static xor(intervals: Interval_2[]): IntervalMaybeValid_2[]; /** * Return Intervals representing the spans of time in this Interval that not overlap with any of the specified Intervals. */ difference(...intervals: Interval_2[]): IntervalMaybeValid_2[]; /** * Returns a string representation of this Interval appropriate for debugging. */ toString(): IfValid_2; /** * Returns a localized string representing this Interval. Accepts the same options as the * Intl.DateTimeFormat constructor and any presets defined by Luxon, such as * {@link DateTime.DATE_FULL} or {@link DateTime.TIME_SIMPLE}. The exact behavior of this method * is browser-specific, but in general it will return an appropriate representation of the * Interval in the assigned locale. Defaults to the system's locale if no locale has been * specified. * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat * @param formatOpts - Either a DateTime preset or Intl.DateTimeFormat constructor options. Defaults to DateTime.DATE_SHORT * @param opts - Options to override the configuration of the start DateTime. * * @example * Interval.fromISO('2022-11-07T09:00Z/2022-11-08T09:00Z').toLocaleString(); //=> 11/7/2022 – 11/8/2022 * @example * Interval.fromISO('2022-11-07T09:00Z/2022-11-08T09:00Z').toLocaleString(DateTime.DATE_FULL); //=> November 7 – 8, 2022 * @example * Interval.fromISO('2022-11-07T09:00Z/2022-11-08T09:00Z').toLocaleString(DateTime.DATE_FULL, { locale: 'fr-FR' }); //=> 7–8 novembre 2022 * @example * Interval.fromISO('2022-11-07T17:00Z/2022-11-07T19:00Z').toLocaleString(DateTime.TIME_SIMPLE); //=> 6:00 – 8:00 PM * @example * Interval.fromISO("2022-11-07T17:00Z/2022-11-07T19:00Z").toLocaleString({ * weekday: "short", * month: "short", * day: "2-digit", * hour: "2-digit", * minute: "2-digit", * }); //=> Mon, Nov 07, 6:00 – 8:00 p */ toLocaleString( formatOpts?: Intl.DateTimeFormatOptions, opts?: LocaleOptions_2, ): IfValid_2; /** * Returns an ISO 8601-compliant string representation of this Interval. * @see https://en.wikipedia.org/wiki/ISO_8601#Time_intervals * * @param opts - The same options as {@link DateTime#toISO} */ toISO(opts?: ToISOTimeOptions_2): IfValid_2; /** * Returns an ISO 8601-compliant string representation of the dates in this Interval. * The time components are ignored. * @see https://en.wikipedia.org/wiki/ISO_8601#Time_intervals */ toISODate(): IfValid_2; /** * Returns an ISO 8601-compliant string representation of the times in this Interval. * The date components are ignored. * @see https://en.wikipedia.org/wiki/ISO_8601#Time_intervals * * @param opts - The same options as {@link DateTime.toISO} */ toISOTime(opts?: ToISOTimeOptions_2): IfValid_2; /** * Returns a string representation of this Interval formatted according to the specified format string. * * @param dateFormat - the format string. This string formats the start and end time. See {@link DateTime.toFormat} for details. * @param opts - options * @param opts.separator - a separator to place between the start and end representations. Defaults to ' - '. */ toFormat( dateFormat: string, opts?: { separator?: string | undefined; }, ): IfValid_2; /** * Return a Duration representing the time spanned by this interval. * * @param unit - the unit or units (such as 'hours' or 'days') to include in the duration. Defaults to ['milliseconds']. * @param opts - options that affect the creation of the Duration * @param opts.conversionAccuracy - the conversion system to use. Defaults to 'casual'. * * @example * Interval.fromDateTimes(dt1, dt2).toDuration().toObject() //=> { milliseconds: 88489257 } * @example * Interval.fromDateTimes(dt1, dt2).toDuration('days').toObject() //=> { days: 1.0241812152777778 } * @example * Interval.fromDateTimes(dt1, dt2).toDuration(['hours', 'minutes']).toObject() //=> { hours: 24, minutes: 34.82095 } * @example * Interval.fromDateTimes(dt1, dt2).toDuration(['hours', 'minutes', 'seconds']).toObject() //=> { hours: 24, minutes: 34, seconds: 49.257 } * @example * Interval.fromDateTimes(dt1, dt2).toDuration('seconds').toObject() //=> { seconds: 88489.257 } */ toDuration(unit?: DurationUnit_2 | DurationUnit_2[], opts?: DiffOptions_2): DurationMaybeValid_2; /** * Run mapFn on the interval start and end, returning a new Interval from the resulting DateTimes * * @example * Interval.fromDateTimes(dt1, dt2).mapEndpoints(endpoint => endpoint.toUTC()) * @example * Interval.fromDateTimes(dt1, dt2).mapEndpoints(endpoint => endpoint.plus({ hours: 2 })) */ mapEndpoints(mapFn: (d: DateTime_2) => DateTime_2): IntervalMaybeValid_2; } declare type IntervalMaybeValid = CanBeInvalid extends true ? (Interval | Interval) : Interval; declare type IntervalMaybeValid_2 = CanBeInvalid_2 extends true ? (Interval_2 | Interval_2) : Interval_2; declare interface IntervalObject { start?: DateTime | undefined; end?: DateTime | undefined; } declare interface IntervalObject_2 { start?: DateTime_2 | undefined; end?: DateTime_2 | undefined; } declare type Invalid = false; declare type Invalid_2 = false; export declare interface IpOptions { /** * One or more IP address versions to validate against. Valid values: ipv4, ipv6, ipvfuture */ version?: string | string[] /** * Used to determine if a CIDR is allowed or not. Valid values: optional, required, forbidden */ cidr?: PresenceMode } /** * Generates a regular expression used to validate IP addresses. * * @param options - optional settings. * * @returns an object with the regular expression and meta data. */ declare function ipRegex(options?: Options): Expression; /** * Type guard to check if a value is an array * @param value - The value to check * @returns True if the value is an array, false otherwise */ declare const isArray: (value: unknown) => value is unknown[]; /** * Type guard to check if a value is a valid Luxon DateObjectUnits object. * * This function validates that the input is a plain object containing only valid * Luxon date/time unit properties with numeric values. It ensures type safety * when working with objects that should represent date/time units for Luxon operations. * * @param value - The value to check for DateObjectUnits compatibility * @returns True if the value is a valid DateObjectUnits object, false otherwise * * @example * ```typescript * // Valid DateObjectUnits objects * const validUnits1 = { year: 2023, month: 12, day: 25 }; * const validUnits2 = { hour: 14, minute: 30, second: 45 }; * const validUnits3 = { weekYear: 2023, weekNumber: 52 }; * * console.log(isDateObjectUnits(validUnits1)); // true * console.log(isDateObjectUnits(validUnits2)); // true * console.log(isDateObjectUnits(validUnits3)); // true * * // Invalid cases * console.log(isDateObjectUnits({})); // false (empty object) * console.log(isDateObjectUnits({ year: "2023" })); // false (string value) * console.log(isDateObjectUnits({ invalid: 123 })); // false (invalid property) * console.log(isDateObjectUnits(null)); // false * console.log(isDateObjectUnits([])); // false * ``` * * @remarks * The function validates against all supported Luxon DateObjectUnits properties: * - Time units: year, month, day, ordinal * - Week-based units: weekYear, localWeekYear, weekNumber, localWeekNumber, weekday, localWeekday * - Time of day units: hour, minute, second, millisecond * * All property values must be numbers or undefined. The object must contain at least one property. */ declare const isDateObjectUnits: (value: unknown) => value is DateObjectUnits; /** * Analyzes a string to verify it is a valid domain name. * * @param domain - the domain name to validate. * @param options - optional settings. * * @return - true when valid, otherwise false. */ declare function isDomainValid(domain: string, options?: DomainOptions_2): boolean; /** * Analyzes a string to verify it is a valid email address. * * @param email - the email address to validate. * @param options - optional settings. * * @return - true when valid, otherwise false. */ declare function isEmailValid(email: string, options?: EmailOptions_2): boolean; /** * Checks if a value is an instance of a specific class. * @param value - The value to check * @param type - The name of the class to check against * @returns true if the value is an instance of the specified class, false otherwise */ declare const isInstanceOf: (value: unknown, type: string, ctor?: new (...args: any[]) => T) => value is T; /** * Type guard to check if a value is a Luxon DateTime instance * @param value - The value to check * @returns True if the value is a Luxon DateTime, false otherwise */ declare const isLuxonDateTime: (value: unknown) => value is DateTime_2; export declare type IsNonPrimitiveSubsetUnion = true extends IsUnion ? (true extends IsPrimitiveSubset ? false : true) : false /** * Type guard to check if a value is a plain object (not null, not array) * @param value - The value to check * @returns True if the value is a plain object, false otherwise */ declare const isPlainObject: (value: unknown) => value is { [key: string]: unknown; }; export declare type IsPrimitiveSubset = [T] extends [string] ? true : [T] extends [number] ? true : [T] extends [bigint] ? true : [T] extends [boolean] ? true : [T] extends [symbol] ? true : [T] extends [null] ? true : [T] extends [undefined] ? true : false export declare interface IsSchemaOptions { /** * If true, will identify schemas from older versions of joi, otherwise will throw an error. * * @default false */ legacy: boolean } export declare type IsUnion = T extends unknown ? ([U] extends [T] ? false : true) : false export declare type KnexConfig = Knex.Config; export declare interface KnexConnectionConfigurations { client: NonNullable; connection: NonNullable; [key: string | number | symbol]: any; } export declare type KnexInstance = ReturnType; export declare type KnexQueryBuilder = Knex.QueryBuilder; export declare type KnexSchemaConnection = KnexConnectionConfigurations | any; export declare type KnexTransaction = Knex.Transaction; export declare type LanguageMessages = Record> export declare interface LanguageMessageTemplate { source: string rendered: string } /** * Schema type for link validation. * * @public */ export declare interface LinkSchema extends AnySchema { /** * Same as `any.concat()` but the schema is merged after the link is resolved which allows merging with schemas of the same type as the resolved link. * Will throw an exception during validation if the merged types are not compatible. */ concat(schema: Schema | Schema): this; /** * Initializes the schema after constructions for cases where the schema has to be constructed first and then initialized. * If `ref` was not passed to the constructor, `link.ref()` must be called prior to usage. */ ref(ref: string): this; } declare interface LinkSchema_2 extends AnySchema_2 { /** * Same as `any.concat()` but the schema is merged after the link is resolved which allows merging with schemas of the same type as the resolved link. * Will throw an exception during validation if the merged types are not compatible. */ concat(schema: Schema_2): this /** * Initializes the schema after constructions for cases where the schema has to be constructed first and then initialized. * If `ref` was not passed to the constructor, `link.ref()` must be called prior to usage. */ ref(ref: string): this } declare interface LocaleOptions { /** * @default system's locale */ locale?: string | undefined; outputCalendar?: CalendarSystem | undefined; numberingSystem?: NumberingSystem | undefined; weekSettings?: WeekSettings | undefined; } declare interface LocaleOptions_2 { /** * @default system's locale */ locale?: string | undefined; outputCalendar?: CalendarSystem_2 | undefined; numberingSystem?: NumberingSystem_2 | undefined; weekSettings?: WeekSettings_2 | undefined; } /** Returns the filename and line number of the caller in the call stack @param depth - The distance from the location function in the call stack. Defaults to 1 (caller). @return an object with the filename and line number. */ export declare function location(depth?: number): location.Location; export declare namespace location { export interface Location { /** The fully qualified filename. */ readonly filename: string; /** The file line number. */ readonly line: number; } } declare type ManyDateTimes = Array>; declare type ManyDateTimes_2 = Array>; declare type MinuteNumbers = SecondNumbers; declare type MinuteNumbers_2 = SecondNumbers_2; export declare interface ModifyOptions { each?: boolean once?: boolean ref?: boolean schema?: boolean } declare type MonthNumbers = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12; declare type MonthNumbers_2 = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12; export declare interface MutateRegisterOptions { family?: any key?: any } export declare type NoNestedArrays = Extract extends never ? T : never export declare type NullableType = undefined | null | T declare type NumberingSystem = Intl.DateTimeFormatOptions extends { numberingSystem?: infer T } ? T : | "arab" | "arabext" | "bali" | "beng" | "deva" | "fullwide" | "gujr" | "guru" | "hanidec" | "khmr" | "knda" | "laoo" | "latn" | "limb" | "mlym" | "mong" | "mymr" | "orya" | "tamldec" | "telu" | "thai" | "tibt"; declare type NumberingSystem_2 = Intl.DateTimeFormatOptions extends { numberingSystem?: infer T } ? T : | "arab" | "arabext" | "bali" | "beng" | "deva" | "fullwide" | "gujr" | "guru" | "hanidec" | "khmr" | "knda" | "laoo" | "latn" | "limb" | "mlym" | "mong" | "mymr" | "orya" | "tamldec" | "telu" | "thai" | "tibt"; /** * Schema type for number validation. * * @public */ export declare interface NumberSchema extends AnySchema { /** * Specifies that the value must be greater than limit. * It can also be a reference to another field. */ greater(limit: number | Reference): this; /** * Requires the number to be an integer (no floating point). */ integer(): this; /** * Specifies that the value must be less than limit. * It can also be a reference to another field. */ less(limit: number | Reference): this; /** * Specifies the maximum value. * It can also be a reference to another field. */ max(limit: number | Reference): this; /** * Specifies the minimum value. * It can also be a reference to another field. */ min(limit: number | Reference): this; /** * Specifies that the value must be a multiple of base. */ multiple(base: number | Reference): this; /** * Requires the number to be negative. */ negative(): this; /** * Requires the number to be a TCP port, so between 0 and 65535. */ port(): this; /** * Requires the number to be positive. */ positive(): this; /** * Specifies the maximum number of decimal places where: * @param limit - the maximum number of decimal places allowed. */ precision(limit: number): this; /** * Requires the number to be negative or positive. */ sign(sign: 'positive' | 'negative'): this; /** * Allows the number to be outside of JavaScript's safety range (Number.MIN_SAFE_INTEGER & Number.MAX_SAFE_INTEGER). */ unsafe(enabled?: any): this; /** * Sets a default value if the original value is `undefined`. * * @param value - The default value. Can be: * - A literal number value * - A reference to another schema value * - A function that returns the default value with signature `(parent, helpers) => value` * - `parent` - A clone of the object containing the value being validated * - `helpers` - Validation helper functions for custom validation logic */ default(value?: DefaultableValue): this; } declare interface NumberSchema_2 extends AnySchema_2 { /** * Specifies that the value must be greater than limit. * It can also be a reference to another field. */ greater(limit: number | Reference): this /** * Requires the number to be an integer (no floating point). */ integer(): this /** * Specifies that the value must be less than limit. * It can also be a reference to another field. */ less(limit: number | Reference): this /** * Specifies the maximum value. * It can also be a reference to another field. */ max(limit: number | Reference): this /** * Specifies the minimum value. * It can also be a reference to another field. */ min(limit: number | Reference): this /** * Specifies that the value must be a multiple of base. */ multiple(base: number | Reference): this /** * Requires the number to be negative. */ negative(): this /** * Requires the number to be a TCP port, so between 0 and 65535. */ port(): this /** * Requires the number to be positive. */ positive(): this /** * Specifies the maximum number of decimal places where: * @param limit - the maximum number of decimal places allowed. */ precision(limit: number): this /** * Requires the number to be negative or positive. */ sign(sign: 'positive' | 'negative'): this /** * Allows the number to be outside of JavaScript's safety range (Number.MIN_SAFE_INTEGER & Number.MAX_SAFE_INTEGER). */ unsafe(enabled?: any): this } export declare interface ObjectPatternOptions { fallthrough?: boolean matches: SchemaLike_2 | Reference } export declare type ObjectPropertiesSchema = true extends IsNonPrimitiveSubsetUnion> ? AlternativesSchema : T extends NullableType ? StringSchema : T extends NullableType ? NumberSchema : T extends NullableType ? BigIntSchema : T extends NullableType ? BooleanSchema : T extends NullableType ? DateSchema : T extends NullableType ? BinarySchema : T extends NullableType> ? ArraySchema : T extends DateTime ? DatetimeSchema : T extends NullableType ? StrictSchemaMap | ObjectSchema : never; declare type ObjectPropertiesSchema_2 = true extends IsNonPrimitiveSubsetUnion> ? AlternativesSchema_2 : T extends NullableType ? StringSchema_2 : T extends NullableType ? NumberSchema_2 : T extends NullableType ? NumberSchema_2 : T extends NullableType ? BooleanSchema_2 : T extends NullableType ? DateSchema_2 : T extends NullableType ? BinarySchema_2 : T extends NullableType> ? ArraySchema_2 : T extends NullableType ? StrictSchemaMap_2 | ObjectSchema_2 : never /** * Schema type for object validation. * * @public */ export declare interface ObjectSchema extends AnySchema { /** * Defines an all-or-nothing relationship between keys where if one of the peers is present, all of them are required as well. * * Optional settings must be the last argument. */ and(...peers: Array): this; /** * Appends the allowed object keys. If schema is null, undefined, or {}, no changes will be applied. */ append(schema?: SchemaMap): this; append(schema?: SchemaMap): ObjectSchema; /** * Verifies an assertion where. */ assert(ref: string | Reference, schema: SchemaLike, message?: string): this; /** * Requires the object to be an instance of a given constructor. * * @param constructor - the constructor function that the object must be an instance of. * @param name - an alternate name to use in validation errors. This is useful when the constructor function does not have a name. */ instance(constructor: Function, name?: string): this; /** * Sets or extends the allowed object keys. */ keys(schema?: SchemaMap): this; /** * Specifies the exact number of keys in the object. */ length(limit: number): this; /** * Specifies the maximum number of keys in the object. */ max(limit: number | Reference): this; /** * Specifies the minimum number of keys in the object. */ min(limit: number | Reference): this; /** * Defines a relationship between keys where not all peers can be present at the same time. * * Optional settings must be the last argument. */ nand(...peers: Array): this; /** * Defines a relationship between keys where one of the peers is required (and more than one is allowed). * * Optional settings must be the last argument. */ or(...peers: Array): this; /** * Defines an exclusive relationship between a set of keys where only one is allowed but none are required. * * Optional settings must be the last argument. */ oxor(...peers: Array): this; /** * Specify validation rules for unknown keys matching a pattern. * * @param pattern - a pattern that can be either a regular expression or a joi schema that will be tested against the unknown key names * @param schema - the schema object matching keys must validate against */ pattern(pattern: RegExp | SchemaLike, schema: SchemaLike, options?: ObjectPatternOptions): this; /** * Requires the object to be a Joi reference. */ ref(): this; /** * Requires the object to be a `RegExp` object. */ regex(): this; /** * Renames a key to another name (deletes the renamed key). */ rename(from: string | RegExp, to: string, options?: RenameOptions): this; /** * Requires the object to be a Joi schema instance. */ schema(type?: SchemaLike): this; /** * Overrides the handling of unknown keys for the scope of the current object only (does not apply to children). */ unknown(allow?: boolean): this; /** * Requires the presence of other keys whenever the specified key is present. */ with(key: string, peers: string | string[], options?: DependencyOptions): this; /** * Forbids the presence of other keys whenever the specified is present. */ without(key: string, peers: string | string[], options?: DependencyOptions): this; /** * Defines an exclusive relationship between a set of keys. one of them is required but not at the same time. * * Optional settings must be the last argument. */ xor(...peers: Array): this; /** * Sets a default value if the original value is `undefined`. * * @param value - The default value. Can be: * - A literal object value * - A reference to another schema value * - A function that returns the default value with signature `(parent, helpers) => value` * - `parent` - A clone of the object containing the value being validated * - `helpers` - Validation helper functions for custom validation logic * * When called without any value on an object schema type, a default value will be * automatically generated based on the default values of the object keys. */ default(value?: DefaultableValue): this; } declare interface ObjectSchema_2 extends AnySchema_2 { /** * Defines an all-or-nothing relationship between keys where if one of the peers is present, all of them are required as well. * * Optional settings must be the last argument. */ and(...peers: Array): this /** * Appends the allowed object keys. If schema is null, undefined, or {}, no changes will be applied. */ append(schema?: SchemaMap_2): this append(schema?: SchemaMap_2): ObjectSchema_2 /** * Verifies an assertion where. */ assert(ref: string | Reference, schema: SchemaLike_2, message?: string): this /** * Requires the object to be an instance of a given constructor. * * @param constructor - the constructor function that the object must be an instance of. * @param name - an alternate name to use in validation errors. This is useful when the constructor function does not have a name. */ // tslint:disable-next-line:ban-types instance(constructor: Function, name?: string): this /** * Sets or extends the allowed object keys. */ keys(schema?: SchemaMap_2): this /** * Specifies the exact number of keys in the object. */ length(limit: number): this /** * Specifies the maximum number of keys in the object. */ max(limit: number | Reference): this /** * Specifies the minimum number of keys in the object. */ min(limit: number | Reference): this /** * Defines a relationship between keys where not all peers can be present at the same time. * * Optional settings must be the last argument. */ nand(...peers: Array): this /** * Defines a relationship between keys where one of the peers is required (and more than one is allowed). * * Optional settings must be the last argument. */ or(...peers: Array): this /** * Defines an exclusive relationship between a set of keys where only one is allowed but none are required. * * Optional settings must be the last argument. */ oxor(...peers: Array): this /** * Specify validation rules for unknown keys matching a pattern. * * @param pattern - a pattern that can be either a regular expression or a joi schema that will be tested against the unknown key names * @param schema - the schema object matching keys must validate against */ pattern(pattern: RegExp | SchemaLike_2, schema: SchemaLike_2, options?: ObjectPatternOptions): this /** * Requires the object to be a Joi reference. */ ref(): this /** * Requires the object to be a `RegExp` object. */ regex(): this /** * Renames a key to another name (deletes the renamed key). */ rename(from: string | RegExp, to: string, options?: RenameOptions): this /** * Requires the object to be a Joi schema instance. */ schema(type?: SchemaLike_2): this /** * Overrides the handling of unknown keys for the scope of the current object only (does not apply to children). */ unknown(allow?: boolean): this /** * Requires the presence of other keys whenever the specified key is present. */ with(key: string, peers: string | string[], options?: DependencyOptions): this /** * Forbids the presence of other keys whenever the specified is present. */ without(key: string, peers: string | string[], options?: DependencyOptions): this /** * Defines an exclusive relationship between a set of keys. one of them is required but not at the same time. * * Optional settings must be the last argument. */ xor(...peers: Array): this } declare interface Options { /** * The required CIDR mode. * * @default 'optional' */ readonly cidr?: Cidr; /** * The allowed versions. * * @default ['ipv4', 'ipv6', 'ipvfuture'] */ readonly version?: Version | Version[]; } declare interface Options_2 { /** * Allow the use of [] in query parameters. * * @default false */ readonly allowQuerySquareBrackets?: boolean; /** * Allow relative URIs. * * @default false */ readonly allowRelative?: boolean; /** * Requires the URI to be relative. * * @default false */ readonly relativeOnly?: boolean; /** * Capture domain segment ($1). * * @default false */ readonly domain?: boolean; /** * The allowed URI schemes. */ readonly scheme?: Scheme | Scheme[]; } declare interface Options_3 { /** * A hash of key - value pairs used to convert constants to values. */ readonly constants?: Record; /** * A regular expression used to validate token variables. */ readonly tokenRx?: RegExp; /** * A variable resolver factory function. */ readonly reference?: Options_3.Reference; /** * A hash of key-value pairs used to resolve formula functions. */ readonly functions?: Record; } declare namespace Options_3 { type Reference = (name: string) => (context: any) => any; } /** * Types that can be parsed into a DateTime object. * * Supports Luxon DateTime objects, JavaScript Date objects, Day.js objects, * ISO strings, Unix timestamps, Luxon DateObjectUnits, and keyword strings. * * **Supported Keywords:** * - Time-based: `'now'` * - Day-based: `'today'`, `'yesterday'`, `'tomorrow'` * - Week-based: `'start of week'`, `'end of week'`, `'last week'`, `'next week'` * - Month-based: `'start of month'`, `'end of month'`, `'last month'`, `'next month'` * - Year-based: `'start of year'`, `'end of year'`, `'last year'`, `'next year'` * - Explicit boundaries: `'start of today'`, `'end of today'` * - CamelCase variants: `'startOfWeek'`, `'endOfMonth'`, etc. * * Keywords are operator-aware: when used with `beforeOrEqual()` or `max()`, * period keywords like `'today'` resolve to end-of-period (23:59:59.999) instead * of start-of-period (00:00:00) for intuitive "on or before today" behavior. * * @example * ```typescript * const schema = joi.datetime() * * // All of these are valid Parseable types: * schema.validate('2023-01-01T00:00:00Z') // ISO string * schema.validate(1672531200000) // Unix timestamp * schema.validate(new Date()) // JavaScript Date * schema.validate(DateTime.now()) // Luxon DateTime * schema.validate({ year: 2023, month: 1, day: 1 }) // DateObjectUnits * schema.validate('today') // Keyword * schema.validate('start of month') // Keyword * schema.validate('lastWeek') // Keyword (camelCase) * ``` */ declare type Parseable = DateTime | Date | Dayjs | string | number | DateObjectUnits; /** * Formula parser */ declare class Parser { /** * Create a new formula parser. * * @param formula - the formula string to parse. * @param options - optional settings. */ constructor(formula: string, options?: Options_3); /** * Evaluate the formula. * * @param context - optional object with runtime formula context used to resolve variables. * * @returns the string or number outcome of the resolved formula. */ evaluate(context?: any): T; } export declare type PartialSchemaMap = { [key in keyof TSchema]?: SchemaLike | SchemaLike[]; }; declare type PartialSchemaMap_2 = { [key in keyof TSchema]?: SchemaLike_2 | SchemaLike_2[] } /** * The `Phone` class represents a phone number and provides methods to retrieve information about it. * It implements the `PhoneModel` interface. * @implements {PhoneModel} */ declare class Phone implements PhoneModel { #private; /** * The `Phone` class constructor takes a `phone` argument of type `RawPhoneType` and an optional `country` argument of type `RawCountryType`. * It initializes `Phone` instance. * @constructor * @param {RawPhoneType} phone - The phone number to be parsed and validated. * @param {RawCountryType} [country] - The country code of the phone number. If not provided, the country will be guessed based on the phone number. */ constructor(phone: RawPhoneType, country?: RawCountryType); /** * Returns the phone number as a string stripped of all non-numeric characters. * @readonly * @type {string} */ readonly phone: string; /** * Returns the country code of the phone number. * @readonly * @type {CountryOrUnknown} */ readonly country: CountryOrUnknown; /** * Returns whether the phone number uses a valid format for the parsed country or not. * @readonly * @type {boolean} */ readonly valid: boolean; /** * Returns the type of the phone number. * @readonly * @type {PhoneTypes} */ readonly type: PhoneTypes; /** * Returns whether the phone number is a mobile number or not. * @readonly * @type {boolean} */ readonly mobile: boolean; /** * Returns the raw phone number. * @readonly * @type {string} * * @remarks * If the phone number is not a valid phone number, the initial phone number which was passed to the constructor is returned. */ readonly raw: string; /** * Returns the national format of the phone number. * @readonly * @type {string} * * @remarks * If the phone number is not a valid phone number, the initial phone number which was passed to the constructor is returned. */ readonly national: string; /** * Returns the international format of the phone number. * @readonly * @type {string} * * @remarks * If the phone number is not a valid phone number, the initial phone number which was passed to the constructor is returned. */ readonly international: string; /** * Returns the E.164 format of the phone number. * @readonly * @type {string} * * @remarks * If the phone number is not a valid phone number, the initial phone number which was passed to the constructor is returned. */ readonly e164: string; /** * Returns the timezone of the phone number. * @readonly * @type {PossiblePhoneTimezone} */ readonly timezone: PossiblePhoneTimezone; /** * Returns an object representation of the phone number. * @returns {{ * phone: string; * country: string; * valid: boolean; * type: PhoneTypes; * mobile: boolean; * raw: string; * national: string; * international: string; * e164: string; * timezone: PossiblePhoneTimezone; * }} - An object representation of the phone number. */ toObject(): { /** * The phone number as a string stripped of all non-numeric characters. */ phone: string; /** * The country code of the phone number. * @remarks * In cases where the country was not recognized and could not be guessed from the phone number, `'XX'` is used. * @type {CountryOrUnknown} */ country: CountryOrUnknown; /** * Whether the phone number uses a valid format for the parsed country or not. * @type {boolean} */ valid: boolean; /** * The type of the phone number. * @type {PhoneTypes} */ type: "FIXED_LINE" | "MOBILE" | "FIXED_LINE_OR_MOBILE" | "TOLL_FREE" | "PREMIUM_RATE" | "SHARED_COST" | "VOIP" | "PERSONAL_NUMBER" | "PAGER" | "UAN" | "VOICEMAIL" | "UNKNOWN" | "INVALID"; /** * Whether the phone number is possibly a mobile number or not. * @type {boolean} */ mobile: boolean; /** * The phone number as a string stripped of all non-numeric characters. * @type {string} */ raw: string; /** * The phone number as a string in the national format for the parsed country. * @type {string} */ national: string; /** * The phone number as a string in the international format for the parsed country. * @type {string} */ international: string; /** * The phone number as a string in the E.164 format. * @type {string} */ e164: string; /** * The estimated timezone of the phone number based on the phone number's country. It can be either a `CountryTimezone` or `'UTC'`. */ timezone: PossiblePhoneTimezone; }; /** * Returns a JSON representation of the phone number. * @returns {{ * phone: string; * country: string; * valid: boolean; * type: PhoneTypes; * mobile: boolean; * raw: string; * national: string; * international: string; * e164: string; * timezone: PossiblePhoneTimezone; * }} - A JSON-safe representation of the phone number. */ toJSON(): { /** * The phone number as a string stripped of all non-numeric characters. */ phone: string; /** * The country code of the phone number. * @remarks * In cases where the country was not recognized and could not be guessed from the phone number, `'XX'` is used. * @type {CountryOrUnknown} */ country: CountryOrUnknown; /** * Whether the phone number uses a valid format for the parsed country or not. * @type {boolean} */ valid: boolean; /** * The type of the phone number. * @type {PhoneTypes} */ type: "FIXED_LINE" | "MOBILE" | "FIXED_LINE_OR_MOBILE" | "TOLL_FREE" | "PREMIUM_RATE" | "SHARED_COST" | "VOIP" | "PERSONAL_NUMBER" | "PAGER" | "UAN" | "VOICEMAIL" | "UNKNOWN" | "INVALID"; /** * Whether the phone number is possibly a mobile number or not. * @type {boolean} */ mobile: boolean; /** * The phone number as a string stripped of all non-numeric characters. * @type {string} */ raw: string; /** * The phone number as a string in the national format for the parsed country. * @type {string} */ national: string; /** * The phone number as a string in the international format for the parsed country. * @type {string} */ international: string; /** * The phone number as a string in the E.164 format. * @type {string} */ e164: string; /** * The estimated timezone of the phone number based on the phone number's country. It can be either a `CountryTimezone` or `'UTC'`. */ timezone: PossiblePhoneTimezone; }; /** * Returns the E.164 format of the phone number as a string. * @returns {string} - The E.164 format of the phone number. */ toString(): string; /** * Returns a stringified representation of the phone number. * @returns {string} - A string representation of the phone number. */ inspect(): string; /** * Serializes the phone object to an obfuscated string which can be used to recreate the phone object from the `Phone.deserialize` method. * @returns {string} - The serialized phone object. */ serialize(): string; /** * Creates a new phone object from a serialized phone object. * @param serialized The serialized phone object returned from the `Phone.serialize` method. * @returns A Phone instance with the same properties as the original phone object. * @throws An error if the serialized phone object is not valid. */ static deserialize(serialized: string): Phone; } /** * The `PhoneModel` interface represents a phone number object with various properties and methods. * @interface */ declare interface PhoneModel { /** * The `country` property represents the country that was used to create the `Phone` instance. * @type {CountryOrUnknown} * @remarks * * In cases where the country was not recognized and could not be guessed from the phone number, `'XX'` is used. */ country: CountryOrUnknown; /** * The `valid` property represents whether the phone number uses a valid format for the parsed country or not. * @type {boolean} */ valid: boolean; /** * The `type` property represents the type of the phone number. It can be any of the keys of the `PhoneNumberType` object in the `google-libphonenumber` library, or `'INVALID'` if the phone number is not valid. * @type {PhoneTypes} */ type: PhoneTypes; /** * The `mobile` property represents whether the phone number is possibly a mobile phone number or not. * @type {boolean} * @remarks * * This property is `true` if the phone number type is either `'MOBILE'` or `'FIXED_LINE_OR_MOBILE'`. * This covers cases like in the United States and Canada where it is not possible to tell if a phone number is a mobile phone number or not based on the phone number alone. */ mobile: boolean; /** * The `raw` property represents the phone number as a string stripped of all non-numeric characters. * @type {string} */ raw: string; /** * The `national` property represents the phone number as a string in the national format for the parsed country. * @type {string} */ national: string; /** * The `international` property represents the phone number as a string in the international format for the parsed country. * @type {string} */ international: string; /** * The `e164` property represents the phone number as a string in the E.164 format. * @type {string} */ e164: string; /** * The `timezone` property represents the estimated timezone of the phone number based on the phone number's country. It can be either a `CountryTimezone` or `'UTC'`. * @type {PossiblePhoneTimezone} * @remarks * * In cases where the phone number's country has several timezones, the timezone with the greatest population is used. * In cases where the phone number's country is not recognized or has no timezone defined, `'UTC'` is used. */ timezone: PossiblePhoneTimezone; /** * The `toObject` method returns an object with the same properties as the `PhoneModelInstanceObject` interface. * @returns {PhoneModelInstanceObject} */ toObject(): PhoneModelInstanceObject; /** * The `toJSON` method returns an object with the same properties as the `PhoneModelInstanceObject` interface. * @returns {PhoneModelInstanceObject} */ toJSON(): PhoneModelInstanceObject; /** * The `toString` method returns the phone number as a string in the international format for the parsed country. * @returns {string} */ toString(): string; } /** * The `PhoneModelInstanceObject` interface represents the properties of a `Phone` instance. * @interface */ declare interface PhoneModelInstanceObject { /** * The `phone` property represents the raw phone number string that was used to create the `Phone` instance. * @type {string} */ phone: string; /** * The `country` property represents the country that was used to create the `Phone` instance. * @type {CountryOrUnknown} * @remarks * * In cases where the country was not recognized and could not be guessed from the phone number, `'XX'` is used. */ country: CountryOrUnknown; /** * The `valid` property represents whether the phone number uses a valid format for the parsed country or not. * @type {boolean} */ valid: boolean; /** * The `type` property represents the type of the phone number. It can be any of the keys of the `PhoneNumberType` object in the `google-libphonenumber` library, or `'INVALID'` if the phone number is not valid. * @type {PhoneTypes} */ type: PhoneTypes; /** * The `mobile` property represents whether the phone number is possibly a mobile phone number or not. * @type {boolean} * @remarks * * This property is `true` if the phone number type is either `'MOBILE'` or `'FIXED_LINE_OR_MOBILE'`. * This covers cases like in the United States and Canada where it is not possible to tell if a phone number is a mobile phone number or not based on the phone number alone. */ mobile: boolean; /** * The `raw` property represents the phone number as a string stripped of all non-numeric characters. * @type {string} */ raw: string; /** * The `national` property represents the phone number as a string in the national format for the parsed country. * @type {string} */ national: string; /** * The `international` property represents the phone number as a string in the international format for the parsed country. * @type {string} */ international: string; /** * The `e164` property represents the phone number as a string in the E.164 format. * @type {string} */ e164: string; /** * The `timezone` property represents the estimated timezone of the phone number based on the phone number's country. It can be either a `CountryTimezone` or `'UTC'`. * @type {PossiblePhoneTimezone} * @remarks * * In cases where the phone number's country has several timezones, the timezone with the greatest population is used. * In cases where the phone number's country is not recognized or has no timezone defined, `'UTC'` is used. */ timezone: PossiblePhoneTimezone; } /** * Phone number validation schema interface extending AnySchema. * Provides methods for validating and formatting phone numbers with various constraints. * * @template TSchema - The schema type, defaults to string * * @example * ```typescript * import Joi from 'joi' * import { phone } from './phone' * * const extended = Joi.extend(phone) * const schema = extended.phone().country('US').mobile() * * const result = schema.validate('+1234567890') * ``` */ export declare interface PhoneSchema extends Omit, 'cast'> { /** * Sets the country context for phone number validation. * * @param country - Country code (ISO 3166-1 alpha-2), country name, Joi reference, or null * @returns The schema instance for chaining * * @example * ```typescript * schema.country('US') * schema.country('United States') * schema.country(Joi.ref('countryField')) * ``` */ country(country: CountryOrUnknown | Reference | null): this; /** * Sets the output format for the phone number. * * @param as - The desired output format * @returns The schema instance for chaining * * @example * ```typescript * schema.format('international') // +1 234 567 8900 * schema.format('national') // (234) 567-8900 * schema.format('e164') // +12345678900 * ``` */ format(as: 'e164' | 'international' | 'national' | 'raw' | 'timezone' | 'type' | 'country'): this; /** * Validates that the phone number is a fixed line or fixed line/mobile number. * * @returns The schema instance for chaining */ fixedLine(): this; /** * Validates that the phone number is a mobile or fixed line/mobile number. * * @returns The schema instance for chaining */ mobile(): this; /** * Validates that the phone number is strictly a fixed line number only. * * @returns The schema instance for chaining */ strictFixedLine(): this; /** * Validates that the phone number is strictly a mobile number only. * * @returns The schema instance for chaining */ strictMobile(): this; /** * Validates that the phone number is either a fixed line or mobile number. * * @returns The schema instance for chaining */ fixedLineOrMobile(): this; /** * Validates that the phone number is a toll-free number. * * @returns The schema instance for chaining */ tollFree(): this; /** * Validates that the phone number is a premium rate number. * * @returns The schema instance for chaining */ premiumRate(): this; /** * Validates that the phone number is a shared cost number. * * @returns The schema instance for chaining */ sharedCost(): this; /** * Validates that the phone number is a VoIP number. * * @returns The schema instance for chaining */ voip(): this; /** * Validates that the phone number is a personal number. * * @returns The schema instance for chaining */ personalNumber(): this; /** * Validates that the phone number is a pager number. * * @returns The schema instance for chaining */ pager(): this; /** * Validates that the phone number is a UAN (Universal Access Number). * * @returns The schema instance for chaining */ uan(): this; /** * Validates that the phone number is a voicemail number. * * @returns The schema instance for chaining */ voicemail(): this; /** * Validates that the phone number is of unknown type. * * @returns The schema instance for chaining */ unknown(): this; /** * Validates that the phone number matches one of the specified types. * * @param types - Array of phone types to allow * @returns The schema instance for chaining * * @example * ```typescript * schema.types('MOBILE', 'FIXED_LINE') * ``` */ types(...types: PhoneTypes[]): this; cast(to: 'number' | 'string' | 'object'): this; } /** * The `PhoneTypes` type represents the possible types of a phone number. It can be any of the keys of the `PhoneNumberType` object in the `google-libphonenumber` library, or `'INVALID'` if the phone number is not valid. */ export declare const PhoneTypes: readonly ["FIXED_LINE", "MOBILE", "FIXED_LINE_OR_MOBILE", "TOLL_FREE", "PREMIUM_RATE", "SHARED_COST", "VOIP", "PERSONAL_NUMBER", "PAGER", "UAN", "VOICEMAIL", "UNKNOWN", "INVALID"]; /** * The `PhoneTypes` type represents the possible types of a phone number. It can be any of the keys of the `PhoneNumberType` object in the `google-libphonenumber` library, or `'INVALID'` if the phone number is not valid. */ export declare type PhoneTypes = (typeof PhoneTypes)[number]; declare type PickedDateTime = Values extends [] ? undefined : | (Values extends Array> ? | (AllValues extends true ? DateTime : never) | (AllValues extends false ? DateTime : never) : never) | ([] extends Values ? undefined : never); declare type PickedDateTime_2 = Values extends [] ? undefined : | (Values extends Array> ? | (AllValues extends true ? DateTime_2 : never) | (AllValues extends false ? DateTime_2 : never) : never) | ([] extends Values ? undefined : never); declare type PossibleDaysInMonth = 28 | 29 | 30 | 31; declare type PossibleDaysInMonth_2 = 28 | 29 | 30 | 31; declare type PossibleDaysInYear = 365 | 366; declare type PossibleDaysInYear_2 = 365 | 366; /** * The `PossiblePhoneTimezone` type represents the estimated timezone of a phone number based on the phone number's country. It can be either a `CountryTimezone` or `'UTC'`. * @typedef {CountryTimezone | 'UTC'} PossiblePhoneTimezone * @remarks * * In cases where the phone number's country has several timezones, the timezone with the greatest population is used. * In cases where the phone number's country is not recognized or has no timezone defined, `'UTC'` is used. */ declare type PossiblePhoneTimezone = CountryTimezone | 'UTC'; declare type PossibleWeeksInYear = 52 | 53; declare type PossibleWeeksInYear_2 = 52 | 53; export declare type PresenceMode = 'optional' | 'required' | 'forbidden' export declare type Primitives = string | number | boolean | bigint | symbol | null declare type QuarterNumbers = 1 | 2 | 3 | 4; declare type QuarterNumbers_2 = 1 | 2 | 3 | 4; export declare type QueryBuilder = KnexQueryBuilder | DatabaseQueryBuilderContract; export declare type QueryClient = KnexInstance | KnexTransaction | QueryClientContract; export { QueryClientContract } /** * The `RawCountryType` type represents the country which should be used to parse the phone number. It is of type `Country`. * @typedef {Country} RawCountryType */ declare type RawCountryType = Country; /** * The `RawPhoneType` type represents the phone number which should be parsed. It can be either a string or a number. * @typedef {string | number} RawPhoneType */ declare type RawPhoneType = string | number; export declare interface Reference extends Exclude { depth: number type: string key: string root: string path: string[] display: string toString(): string } declare type Reference_2 = Reference & { resolve: (value: any, state: State, prefs: ValidationOptions, local?: any, options?: ReferenceOptions) => any; }; export declare interface ReferenceOptions extends HierarchySeparatorOptions { /** * a function with the signature `function(value)` where `value` is the resolved reference value and the return value is the adjusted value to use. * Note that the adjust feature will not perform any type validation on the adjusted value and it must match the value expected by the rule it is used in. * Cannot be used with `map`. * * @example `(value) => value + 5` */ adjust?: (value: any) => any /** * an array of array pairs using the format `[[key, value], [key, value]]` used to maps the resolved reference value to another value. * If the resolved value is not in the map, it is returned as-is. * Cannot be used with `adjust`. */ map?: Array<[any, any]> /** * overrides default prefix characters. */ prefix?: { /** * references to the globally provided context preference. * * @default '$' */ global?: string /** * references to error-specific or rule specific context. * * @default '#' */ local?: string /** * references to the root value being validated. * * @default '/' */ root?: string } /** * If set to a number, sets the reference relative starting point. * Cannot be combined with separator prefix characters. * Defaults to the reference key prefix (or 1 if none present) */ ancestor?: number /** * creates an in-reference. */ in?: boolean /** * when true, the reference resolves by reaching into maps and sets. */ iterables?: boolean /** * when true, the value of the reference is used instead of its name in error messages * and template rendering. Defaults to false. */ render?: boolean } export declare interface RenameOptions { /** * if true, does not delete the old key name, keeping both the new and old keys in place. * * @default false */ alias?: boolean /** * if true, allows renaming multiple keys to the same destination where the last rename wins. * * @default false */ multiple?: boolean /** * if true, allows renaming a key over an existing key. * * @default false */ override?: boolean /** * if true, skip renaming of a key if it's undefined. * * @default false */ ignoreUndefined?: boolean } declare type ResolvedLocaleOptions = Required; declare type ResolvedLocaleOptions_2 = Required; export declare interface Root { /** * Current version of the joi package. */ version: string ValidationError: new ( message: string, details: ValidationErrorItem_2[], original: any ) => ValidationError_2 /** * Generates a schema object that matches any data type. */ any(): AnySchema_2 /** * Generates a schema object that matches an array data type. */ array(): ArraySchema_2 /** * Generates a schema object that matches a boolean data type (as well as the strings 'true' and 'false'). Can also be called via boolean(). */ bool(): BooleanSchema_2 /** * Generates a schema object that matches a boolean data type (as well as the strings 'true' and 'false'). Can also be called via bool(). */ boolean(): BooleanSchema_2 /** * Generates a schema object that matches a Buffer data type (as well as the strings which will be converted to Buffers). */ binary(): BinarySchema_2 /** * Generates a schema object that matches a date type (as well as a JavaScript date string or number of milliseconds). */ date(): DateSchema_2 /** * Generates a schema object that matches a function type. */ func(): FunctionSchema_2 /** * Generates a schema object that matches a function type. */ function(): FunctionSchema_2 /** * Generates a schema object that matches a number data type (as well as strings that can be converted to numbers). */ number(): NumberSchema_2 /** * Generates a schema object that matches an object data type (as well as JSON strings that have been parsed into objects). */ // tslint:disable-next-line:no-unnecessary-generics object( schema?: SchemaMap_2 ): ObjectSchema_2 /** * Generates a schema object that matches a string data type. Note that empty strings are not allowed by default and must be enabled with allow(''). */ string(): StringSchema_2 /** * Generates a schema object that matches any symbol. */ symbol(): SymbolSchema_2 /** * Generates a type that will match one of the provided alternative schemas */ alternatives(params: [SchemaLike_2, SchemaLike_2]): AlternativesSchema_2 alternatives( params: [SchemaLike_2, SchemaLike_2, SchemaLike_2] ): AlternativesSchema_2 alternatives( params: [SchemaLike_2, SchemaLike_2, SchemaLike_2, SchemaLike_2] ): AlternativesSchema_2 alternatives( params: [SchemaLike_2, SchemaLike_2, SchemaLike_2, SchemaLike_2, SchemaLike_2] ): AlternativesSchema_2 alternatives(a: SchemaLike_2, b: SchemaLike_2): AlternativesSchema_2 alternatives( a: SchemaLike_2, b: SchemaLike_2, c: SchemaLike_2 ): AlternativesSchema_2 alternatives( a: SchemaLike_2, b: SchemaLike_2, c: SchemaLike_2, d: SchemaLike_2 ): AlternativesSchema_2 alternatives( a: SchemaLike_2, b: SchemaLike_2, c: SchemaLike_2, d: SchemaLike_2, e: SchemaLike_2 ): AlternativesSchema_2 alternatives(types: SchemaLike_2[]): AlternativesSchema_2 alternatives(...types: SchemaLike_2[]): AlternativesSchema_2 /** * Alias for `alternatives` */ alt(params: [SchemaLike_2, SchemaLike_2]): AlternativesSchema_2 alt(params: [SchemaLike_2, SchemaLike_2, SchemaLike_2]): AlternativesSchema_2 alt( params: [SchemaLike_2, SchemaLike_2, SchemaLike_2, SchemaLike_2] ): AlternativesSchema_2 alt( params: [SchemaLike_2, SchemaLike_2, SchemaLike_2, SchemaLike_2, SchemaLike_2] ): AlternativesSchema_2 alt(a: SchemaLike_2, b: SchemaLike_2): AlternativesSchema_2 alt(a: SchemaLike_2, b: SchemaLike_2, c: SchemaLike_2): AlternativesSchema_2 alt( a: SchemaLike_2, b: SchemaLike_2, c: SchemaLike_2, d: SchemaLike_2 ): AlternativesSchema_2 alt( a: SchemaLike_2, b: SchemaLike_2, c: SchemaLike_2, d: SchemaLike_2, e: SchemaLike_2 ): AlternativesSchema_2 alt(types: SchemaLike_2[]): AlternativesSchema_2 alt(...types: SchemaLike_2[]): AlternativesSchema_2 /** * Links to another schema node and reuses it for validation, typically for creative recursive schemas. * * @param ref - the reference to the linked schema node. * Cannot reference itself or its children as well as other links. * Links can be expressed in relative terms like value references (`Joi.link('...')`), * in absolute terms from the schema run-time root (`Joi.link('/a')`), * or using schema ids implicitly using object keys or explicitly using `any.id()` (`Joi.link('#a.b.c')`). */ link(ref?: string): LinkSchema_2 /** * Validates a value against a schema and throws if validation fails. * * @param value - the value to validate. * @param schema - the schema object. * @param message - optional message string prefix added in front of the error message. may also be an Error object. */ assert(value: any, schema: Schema_2, options?: ValidationOptions): void assert(value: any, schema: Schema_2, message: string | Error, options?: ValidationOptions): void /** * Validates a value against a schema, returns valid object, and throws if validation fails. * * @param value - the value to validate. * @param schema - the schema object. * @param message - optional message string prefix added in front of the error message. may also be an Error object. */ attempt( value: any, schema: TSchema, options?: ValidationOptions ): TSchema extends Schema_2 ? Value : never attempt( value: any, schema: TSchema, message: string | Error, options?: ValidationOptions ): TSchema extends Schema_2 ? Value : never cache: CacheConfiguration /** * Converts literal schema definition to joi schema object (or returns the same back if already a joi schema object). */ compile(schema: SchemaLike_2, options?: CompileOptions): Schema_2 /** * Checks if the provided preferences are valid. * * Throws an exception if the prefs object is invalid. * * The method is provided to perform inputs validation for the `any.validate()` and `any.validateAsync()` methods. * Validation is not performed automatically for performance reasons. Instead, manually validate the preferences passed once and reuse. */ checkPreferences(prefs: ValidationOptions): void /** * Creates a custom validation schema. */ custom(fn: CustomValidator, description?: string): Schema_2 /** * Creates a new Joi instance that will apply defaults onto newly created schemas * through the use of the fn function that takes exactly one argument, the schema being created. * * @param fn - The function must always return a schema, even if untransformed. */ defaults(fn: SchemaFunction_2): Root /** * Generates a dynamic expression using a template string. */ expression(template: string, options?: ReferenceOptions): any /** * Creates a new Joi instance customized with the extension(s) you provide included. */ extend(...extensions: Array): any /** * Creates a reference that when resolved, is used as an array of values to match against the rule. */ in(ref: string, options?: ReferenceOptions): Reference /** * Checks whether or not the provided argument is an instance of ValidationError */ isError(error: any): error is ValidationError_2 /** * Checks whether or not the provided argument is an expression. */ isExpression(expression: any): boolean /** * Checks whether or not the provided argument is a reference. It's especially useful if you want to post-process error messages. */ isRef(ref: any): ref is Reference /** * Checks whether or not the provided argument is a joi schema. */ isSchema(schema: any, options?: CompileOptions): schema is AnySchema_2 /** * A special value used with `any.allow()`, `any.invalid()`, and `any.valid()` as the first value to reset any previously set values. */ override: symbol /** * Generates a reference to the value of the named key. */ ref(key: string, options?: ReferenceOptions): Reference /** * Returns an object where each key is a plain joi schema type. * Useful for creating type shortcuts using deconstruction. * Note that the types are already formed and do not need to be called as functions (e.g. `string`, not `string()`). */ types(): { alternatives: AlternativesSchema_2 any: AnySchema_2 array: ArraySchema_2 binary: BinarySchema_2 boolean: BooleanSchema_2 date: DateSchema_2 function: FunctionSchema_2 link: LinkSchema_2 number: NumberSchema_2 object: ObjectSchema_2 string: StringSchema_2 symbol: SymbolSchema_2 } /** * Generates a dynamic expression using a template string. */ x(template: string, options?: ReferenceOptions): any // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- // Below are undocumented APIs. use at your own risk // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- /** * Whitelists a value */ allow(...values: any[]): Schema_2 /** * Adds the provided values into the allowed whitelist and marks them as the only valid values allowed. */ valid(...values: any[]): Schema_2 equal(...values: any[]): Schema_2 /** * Blacklists a value */ invalid(...values: any[]): Schema_2 disallow(...values: any[]): Schema_2 not(...values: any[]): Schema_2 /** * Marks a key as required which will not allow undefined as value. All keys are optional by default. */ required(): Schema_2 /** * Alias of `required`. */ exist(): Schema_2 /** * Marks a key as optional which will allow undefined as values. Used to annotate the schema for readability as all keys are optional by default. */ optional(): Schema_2 /** * Marks a key as forbidden which will not allow any value except undefined. Used to explicitly forbid keys. */ forbidden(): Schema_2 /** * Overrides the global validate() options for the current key and any sub-key. */ preferences(options: ValidationOptions): Schema_2 /** * Overrides the global validate() options for the current key and any sub-key. */ prefs(options: ValidationOptions): Schema_2 /** * Converts the type into an alternatives type where the conditions are merged into the type definition where: */ when(ref: string | Reference, options: WhenOptions | WhenOptions[]): AlternativesSchema_2 when(ref: Schema_2, options: WhenSchemaOptions): AlternativesSchema_2 /** * Unsure, maybe alias for `compile`? */ build(...args: any[]): any /** * Unsure, maybe alias for `preferences`? */ options(...args: any[]): any /** * Unsure, maybe leaked from `@hapi/lab/coverage/initialize` */ trace(...args: any[]): any untrace(...args: any[]): any } export declare interface RuleArgs { name: string ref?: boolean assert?: ((value: any) => boolean) | AnySchema_2 message?: string /** * Undocumented properties */ normalize?(value: any): any } export declare type RuleMethod = (...args: any[]) => any export declare interface RuleOptions { /** * if true, the rules will not be replaced by the same unique rule later. * * For example, `Joi.number().min(1).rule({ keep: true }).min(2)` will keep both `min()` rules instead of the later rule overriding the first. * * @default false */ keep?: boolean /** * a single message string or a messages object where each key is an error code and corresponding message string as value. * * The object is the same as the messages used as an option in `any.validate()`. * The strings can be plain messages or a message template. */ message?: string | LanguageMessages /** * if true, turns any error generated by the ruleset to warnings. */ warn?: boolean } /** * A union type that includes all schema types. */ export declare type Schema

= AnySchema

| ArraySchema

| AlternativesSchema

| BinarySchema

| BooleanSchema

| DateSchema

| FunctionSchema

| NumberSchema

| ObjectSchema

| StringSchema

| LinkSchema

| SymbolSchema

| BigIntSchema

| DatetimeSchema

| PhoneSchema

; declare type Schema_2

= | AnySchema_2

| ArraySchema_2

| AlternativesSchema_2

| BinarySchema_2

| BooleanSchema_2

| DateSchema_2

| FunctionSchema_2

| NumberSchema_2

| ObjectSchema_2

| StringSchema_2

| LinkSchema_2

| SymbolSchema_2

export declare type SchemaFunction = (schema: Schema) => Schema; declare type SchemaFunction_2 = (schema: Schema_2) => Schema_2 export declare interface SchemaInternals { /** * Parent schema object. */ $_super: Schema_2 /** * Terms of current schema. */ $_terms: Record /** * Adds a rule to current validation schema. */ $_addRule(rule: string | AddRuleOptions): Schema_2 /** * Internally compiles schema. */ $_compile(schema: SchemaLike_2, options?: CompileOptions): Schema_2 /** * Creates a joi error object. */ $_createError( code: string, value: any, context: ValidationContext, state: State, prefs: ValidationOptions, options?: CreateErrorOptions ): Err /** * Get value from given flag. */ $_getFlag(name: string): any /** * Retrieve some rule configuration. */ $_getRule(name: string): GetRuleOptions | undefined $_mapLabels(path: string | string[]): string /** * Returns true if validations runs fine on given value. */ $_match(value: any, state: State, prefs: ValidationOptions): boolean $_modify(options?: ModifyOptions): Schema_2 /** * Resets current schema. */ $_mutateRebuild(): this $_mutateRegister(schema: Schema_2, options?: MutateRegisterOptions): void /** * Get value from given property. */ $_property(name: string): any /** * Get schema at given path. */ $_reach(path: string[]): Schema_2 /** * Get current schema root references. */ $_rootReferences(): any /** * Set flag to given value. */ $_setFlag(flag: string, value: any, options?: SetFlagOptions): void /** * Runs internal validations against given value. */ $_validate(value: any, state: State, prefs: ValidationOptions): ValidationResult } export declare type SchemaLike = SchemaLikeWithoutArray | object; declare type SchemaLike_2 = SchemaLikeWithoutArray_2 | object export declare type SchemaLikeWithoutArray = string | number | boolean | null | Schema | SchemaMap; declare type SchemaLikeWithoutArray_2 = Exclude< Primitives | Schema_2 | SchemaMap_2, any[] > export declare type SchemaMap = IsStrict extends true ? StrictSchemaMap : PartialSchemaMap; declare type SchemaMap_2 = IsStrict extends true ? StrictSchemaMap_2 : PartialSchemaMap_2 declare type Scheme = string | RegExp; declare type SecondNumbers = | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59; declare type SecondNumbers_2 = | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59; export declare interface SetFlagOptions { clone: boolean } /** * Callback function type for setting up internationalization. * * This function is used to configure the i18n system by providing a translation * callback. Once called, it sets up the root validator instance to use the * provided translation function for all validation messages. * * @param callback - The I18nCallback function that will handle message translation * * @example * ```typescript * // Set up Spanish translations * validator.$setI18n((term: string) => { * return spanishTranslations[term] || term * }) * * // Set up with external i18n library * validator.$setI18n((term: string) => { * return i18next.t(`validation.${term}`, { defaultValue: term }) * }) * ``` */ export declare interface SetI18nCallback { (this: T, callback: I18nCallback): T; } /** The Standard Schema interface. */ declare interface StandardSchemaV1 { /** The Standard Schema properties. */ readonly "~standard": StandardSchemaV1.Props; } declare namespace StandardSchemaV1 { /** The Standard Schema properties interface. */ interface Props extends StandardTypedV1.Props { /** Validates unknown input values. */ readonly validate: (value: unknown, options?: StandardSchemaV1.Options | undefined) => Result | Promise>; } /** The result interface of the validate function. */ type Result = SuccessResult | FailureResult; /** The result interface if validation succeeds. */ interface SuccessResult { /** The typed output value. */ readonly value: Output; /** A falsy value for `issues` indicates success. */ readonly issues?: undefined; } interface Options { /** Explicit support for additional vendor-specific parameters, if needed. */ readonly libraryOptions?: Record | undefined; } /** The result interface if validation fails. */ interface FailureResult { /** The issues of failed validation. */ readonly issues: ReadonlyArray; } /** The issue interface of the failure output. */ interface Issue { /** The error message of the issue. */ readonly message: string; /** The path of the issue, if any. */ readonly path?: ReadonlyArray | undefined; } /** The path segment interface of the issue. */ interface PathSegment { /** The key representing a path segment. */ readonly key: PropertyKey; } /** The Standard types interface. */ interface Types extends StandardTypedV1.Types { } /** Infers the input type of a Standard. */ type InferInput = StandardTypedV1.InferInput; /** Infers the output type of a Standard. */ type InferOutput = StandardTypedV1.InferOutput; } /** The Standard Typed interface. This is a base type extended by other specs. */ declare interface StandardTypedV1 { /** The Standard properties. */ readonly "~standard": StandardTypedV1.Props; } declare namespace StandardTypedV1 { /** The Standard Typed properties interface. */ interface Props { /** The version number of the standard. */ readonly version: 1; /** The vendor name of the schema library. */ readonly vendor: string; /** Inferred types associated with the schema. */ readonly types?: Types | undefined; } /** The Standard Typed types interface. */ interface Types { /** The input type of the schema. */ readonly input: Input; /** The output type of the schema. */ readonly output: Output; } /** Infers the input type of a Standard Typed. */ type InferInput = NonNullable["input"]; /** Infers the output type of a Standard Typed. */ type InferOutput = NonNullable["output"]; } declare type StartOfOptions = _UseLocaleWeekOption; declare type StartOfOptions_2 = _UseLocaleWeekOption_2; export declare interface State { key?: string path?: (string | number)[] parent?: any reference?: any ancestors?: any localize?(...args: any[]): State } export declare type StrictSchemaMap = { [key in keyof TSchema]-?: ObjectPropertiesSchema; }; declare type StrictSchemaMap_2 = { [key in keyof TSchema]-?: ObjectPropertiesSchema_2 } export declare interface StringRegexOptions { /** * optional pattern name. */ name?: string /** * when true, the provided pattern will be disallowed instead of required. * * @default false */ invert?: boolean } /** * Schema type for string validation. * * @public */ export declare interface StringSchema extends AnySchema { /** * Requires the string value to only contain a-z, A-Z, and 0-9. */ alphanum(): this; /** * Requires the string value to be a valid base64 string; does not check the decoded value. */ base64(options?: Base64Options): this; /** * Sets the required string case. */ case(direction: 'upper' | 'lower'): this; /** * Requires the number to be a credit card number (Using Luhn Algorithm). */ creditCard(): this; /** * Requires the string value to be a valid data URI string. */ dataUri(options?: DataUriOptions): this; /** * Requires the string value to be a valid domain. */ domain(options?: DomainOptions): this; /** * Requires the string value to be a valid email address. */ email(options?: EmailOptions): this; /** * Requires the string value to be a valid GUID. */ guid(options?: GuidOptions): this; /** * Requires the string value to be a valid hexadecimal string. */ hex(options?: HexOptions): this; /** * Requires the string value to be a valid hostname as per RFC1123. */ hostname(): this; /** * Allows the value to match any whitelist of blacklist item in a case insensitive comparison. */ insensitive(): this; /** * Requires the string value to be a valid ip address. */ ip(options?: IpOptions): this; /** * Requires the string value to be in valid ISO 8601 date format. */ isoDate(): this; /** * Requires the string value to be in valid ISO 8601 duration format. */ isoDuration(): this; /** * Specifies the exact string length required * @param limit - the required string length. It can also be a reference to another field. * @param encoding - if specified, the string length is calculated in bytes using the provided encoding. */ length(limit: number | Reference, encoding?: string): this; /** * Requires the string value to be all lowercase. If the validation convert option is on (enabled by default), the string will be forced to lowercase. */ lowercase(): this; /** * Specifies the maximum number of string characters. * @param limit - the maximum number of string characters allowed. It can also be a reference to another field. * @param encoding - if specified, the string length is calculated in bytes using the provided encoding. */ max(limit: number | Reference, encoding?: string): this; /** * Specifies the minimum number string characters. * @param limit - the minimum number of string characters required. It can also be a reference to another field. * @param encoding - if specified, the string length is calculated in bytes using the provided encoding. */ min(limit: number | Reference, encoding?: string): this; /** * Requires the string value to be in a unicode normalized form. If the validation convert option is on (enabled by default), the string will be normalized. * @param [form='NFC'] - The unicode normalization form to use. Valid values: NFC [default], NFD, NFKC, NFKD */ normalize(form?: 'NFC' | 'NFD' | 'NFKC' | 'NFKD'): this; /** * Defines a regular expression rule. * @param pattern - a regular expression object the string value must match against. * @param options - optional, can be: * Name for patterns (useful with multiple patterns). Defaults to 'required'. * An optional configuration object with the following supported properties: * name - optional pattern name. * invert - optional boolean flag. Defaults to false behavior. If specified as true, the provided pattern will be disallowed instead of required. */ pattern(pattern: RegExp, options?: string | StringRegexOptions): this; /** * Defines a regular expression rule. * @param pattern - a regular expression object the string value must match against. * @param options - optional, can be: * Name for patterns (useful with multiple patterns). Defaults to 'required'. * An optional configuration object with the following supported properties: * name - optional pattern name. * invert - optional boolean flag. Defaults to false behavior. If specified as true, the provided pattern will be disallowed instead of required. */ regex(pattern: RegExp, options?: string | StringRegexOptions): this; /** * Replace characters matching the given pattern with the specified replacement string where: * @param pattern - a regular expression object to match against, or a string of which all occurrences will be replaced. * @param replacement - the string that will replace the pattern. */ replace(pattern: RegExp | string, replacement: string): this; /** * Requires the string value to only contain a-z, A-Z, 0-9, and underscore _. */ token(): this; /** * Requires the string value to contain no whitespace before or after. If the validation convert option is on (enabled by default), the string will be trimmed. * @param [enabled=true] - optional parameter defaulting to true which allows you to reset the behavior of trim by providing a falsy value. */ trim(enabled?: any): this; /** * Specifies whether the string.max() limit should be used as a truncation. * @param [enabled=true] - optional parameter defaulting to true which allows you to reset the behavior of truncate by providing a falsy value. */ truncate(enabled?: boolean): this; /** * Requires the string value to be all uppercase. If the validation convert option is on (enabled by default), the string will be forced to uppercase. */ uppercase(): this; /** * Requires the string value to be a valid RFC 3986 URI. */ uri(options?: UriOptions): this; /** * Requires the string value to be a valid GUID. */ uuid(options?: GuidOptions): this; /** * Sets a default value if the original value is `undefined`. * * @param value - The default value. Can be: * - A literal string value * - A reference to another schema value * - A function that returns the default value with signature `(parent, helpers) => value` * - `parent` - A clone of the object containing the value being validated * - `helpers` - Validation helper functions for custom validation logic */ default(value?: DefaultableValue): this; /** * Requires the string value to be a valid fully qualified domain name. * * @tip This does not do fully RFC-compliant validation, but a practical approximation. */ fqdn(): this; } declare interface StringSchema_2 extends AnySchema_2 { /** * Requires the string value to only contain a-z, A-Z, and 0-9. */ alphanum(): this /** * Requires the string value to be a valid base64 string; does not check the decoded value. */ base64(options?: Base64Options): this /** * Sets the required string case. */ case(direction: 'upper' | 'lower'): this /** * Requires the number to be a credit card number (Using Luhn Algorithm). */ creditCard(): this /** * Requires the string value to be a valid data URI string. */ dataUri(options?: DataUriOptions): this /** * Requires the string value to be a valid domain. */ domain(options?: DomainOptions): this /** * Requires the string value to be a valid email address. */ email(options?: EmailOptions): this /** * Requires the string value to be a valid GUID. */ guid(options?: GuidOptions): this /** * Requires the string value to be a valid hexadecimal string. */ hex(options?: HexOptions): this /** * Requires the string value to be a valid hostname as per RFC1123. */ hostname(): this /** * Allows the value to match any whitelist of blacklist item in a case insensitive comparison. */ insensitive(): this /** * Requires the string value to be a valid ip address. */ ip(options?: IpOptions): this /** * Requires the string value to be in valid ISO 8601 date format. */ isoDate(): this /** * Requires the string value to be in valid ISO 8601 duration format. */ isoDuration(): this /** * Specifies the exact string length required * @param limit - the required string length. It can also be a reference to another field. * @param encoding - if specified, the string length is calculated in bytes using the provided encoding. */ length(limit: number | Reference, encoding?: string): this /** * Requires the string value to be all lowercase. If the validation convert option is on (enabled by default), the string will be forced to lowercase. */ lowercase(): this /** * Specifies the maximum number of string characters. * @param limit - the maximum number of string characters allowed. It can also be a reference to another field. * @param encoding - if specified, the string length is calculated in bytes using the provided encoding. */ max(limit: number | Reference, encoding?: string): this /** * Specifies the minimum number string characters. * @param limit - the minimum number of string characters required. It can also be a reference to another field. * @param encoding - if specified, the string length is calculated in bytes using the provided encoding. */ min(limit: number | Reference, encoding?: string): this /** * Requires the string value to be in a unicode normalized form. If the validation convert option is on (enabled by default), the string will be normalized. * @param [form='NFC'] - The unicode normalization form to use. Valid values: NFC [default], NFD, NFKC, NFKD */ normalize(form?: 'NFC' | 'NFD' | 'NFKC' | 'NFKD'): this /** * Defines a regular expression rule. * @param pattern - a regular expression object the string value must match against. * @param options - optional, can be: * Name for patterns (useful with multiple patterns). Defaults to 'required'. * An optional configuration object with the following supported properties: * name - optional pattern name. * invert - optional boolean flag. Defaults to false behavior. If specified as true, the provided pattern will be disallowed instead of required. */ pattern(pattern: RegExp, options?: string | StringRegexOptions): this /** * Defines a regular expression rule. * @param pattern - a regular expression object the string value must match against. * @param options - optional, can be: * Name for patterns (useful with multiple patterns). Defaults to 'required'. * An optional configuration object with the following supported properties: * name - optional pattern name. * invert - optional boolean flag. Defaults to false behavior. If specified as true, the provided pattern will be disallowed instead of required. */ regex(pattern: RegExp, options?: string | StringRegexOptions): this /** * Replace characters matching the given pattern with the specified replacement string where: * @param pattern - a regular expression object to match against, or a string of which all occurrences will be replaced. * @param replacement - the string that will replace the pattern. */ replace(pattern: RegExp | string, replacement: string): this /** * Requires the string value to only contain a-z, A-Z, 0-9, and underscore _. */ token(): this /** * Requires the string value to contain no whitespace before or after. If the validation convert option is on (enabled by default), the string will be trimmed. * @param [enabled=true] - optional parameter defaulting to true which allows you to reset the behavior of trim by providing a falsy value. */ trim(enabled?: any): this /** * Specifies whether the string.max() limit should be used as a truncation. * @param [enabled=true] - optional parameter defaulting to true which allows you to reset the behavior of truncate by providing a falsy value. */ truncate(enabled?: boolean): this /** * Requires the string value to be all uppercase. If the validation convert option is on (enabled by default), the string will be forced to uppercase. */ uppercase(): this /** * Requires the string value to be a valid RFC 3986 URI. */ uri(options?: UriOptions): this /** * Requires the string value to be a valid GUID. */ uuid(options?: GuidOptions): this } declare type StringUnitLength = "narrow" | "short" | "long"; declare type StringUnitLength_2 = "narrow" | "short" | "long"; export declare interface SwitchCases { /** * the required condition joi type. */ is: SchemaLike_2 /** * the alternative schema type if the condition is true. */ then: SchemaLike_2 } export declare interface SwitchDefault { /** * the alternative schema type if no cases matched. * Only one otherwise statement is allowed in switch as the last array item. */ otherwise: SchemaLike_2 } /** * Schema type for symbol validation. * * @public */ export declare interface SymbolSchema extends AnySchema { map(iterable: Iterable<[string | number | boolean | symbol, symbol]> | { [key: string]: symbol; }): this; } declare interface SymbolSchema_2 extends AnySchema_2 { // TODO: support number and symbol index map( iterable: Iterable<[string | number | boolean | symbol, symbol]> | { [key: string]: symbol } ): this } export declare const tlds: Set; declare interface TldsAllow { readonly allow: Set; } declare interface TldsDeny { readonly deny: Set; } declare interface ToHumanDurationOptions extends Intl.NumberFormatOptions { /** * How to format the merged list. * Corresponds to the `style` property of the options parameter of the native `Intl.ListFormat` constructor. * @default 'narrow' */ listStyle?: "long" | "short" | "narrow" | undefined; /** * Show all units previously used by the duration even if they are zero. * @default true */ showZeros?: boolean | undefined; } declare interface ToHumanDurationOptions_2 extends Intl.NumberFormatOptions { /** * How to format the merged list. * Corresponds to the `style` property of the options parameter of the native `Intl.ListFormat` constructor. * @default 'narrow' */ listStyle?: "long" | "short" | "narrow" | undefined; /** * Show all units previously used by the duration even if they are zero. * @default true */ showZeros?: boolean | undefined; } declare interface ToISODateOptions extends Pick { /** * Truncate output to desired presicion. * @default 'day' */ precision?: "year" | "years" | "month" | "months" | "day" | "days" | undefined; } declare interface ToISODateOptions_2 extends Pick { /** * Truncate output to desired presicion. * @default 'day' */ precision?: "year" | "years" | "month" | "months" | "day" | "days" | undefined; } declare type ToISOFormat = "basic" | "extended"; declare type ToISOFormat_2 = "basic" | "extended"; declare interface ToISOTimeDurationOptions { /** * Include the `T` prefix * @default false */ includePrefix?: boolean | undefined; /** * Exclude milliseconds from the format if they are 0 * @default false */ suppressMilliseconds?: boolean | undefined; /** * Exclude seconds from the format if they are 0 * @default false */ suppressSeconds?: boolean | undefined; /** * Choose between the basic and extended format * @default 'extended' */ format?: ToISOFormat | undefined; } declare interface ToISOTimeDurationOptions_2 { /** * Include the `T` prefix * @default false */ includePrefix?: boolean | undefined; /** * Exclude milliseconds from the format if they are 0 * @default false */ suppressMilliseconds?: boolean | undefined; /** * Exclude seconds from the format if they are 0 * @default false */ suppressSeconds?: boolean | undefined; /** * Choose between the basic and extended format * @default 'extended' */ format?: ToISOFormat_2 | undefined; } declare interface ToISOTimeOptions extends ToISOTimeDurationOptions { /** * Include the offset, such as 'Z' or '-04:00' * @default true */ includeOffset?: boolean | undefined; /** * add the time zone format extension * @default false */ extendedZone?: boolean | undefined; /** * Truncate output to desired presicion. * When precision and suppressSeconds or suppressMilliseconds are used together, * precision sets the maximum unit shown in the output, * however seconds or milliseconds will still be suppressed if they are 0. * @default 'milliseconds' */ precision?: | "year" | "years" | "month" | "months" | "day" | "days" | "hour" | "hours" | "minute" | "minutes" | "second" | "seconds" | "millisecond" | "milliseconds"; } declare interface ToISOTimeOptions_2 extends ToISOTimeDurationOptions_2 { /** * Include the offset, such as 'Z' or '-04:00' * @default true */ includeOffset?: boolean | undefined; /** * add the time zone format extension * @default false */ extendedZone?: boolean | undefined; /** * Truncate output to desired presicion. * When precision and suppressSeconds or suppressMilliseconds are used together, * precision sets the maximum unit shown in the output, * however seconds or milliseconds will still be suppressed if they are 0. * @default 'milliseconds' */ precision?: | "year" | "years" | "month" | "months" | "day" | "days" | "hour" | "hours" | "minute" | "minutes" | "second" | "seconds" | "millisecond" | "milliseconds"; } declare interface TokenParser { [tokenParserBrand]: true; } declare interface TokenParser_2 { [tokenParserBrand_2]: true; } declare const tokenParserBrand: unique symbol; declare const tokenParserBrand_2: unique symbol; /** * # Table of tokens * * (The example values below come from this time `2014-08-06T13:07:04.054` * considered as a local time in America/New_York). * * Note that many tokens supported by the formatter are **not** supported by the parser. * * | Standalone token | Format token | Description | Example | * | ---------------- | ------------ | ----------------------------------------------------------------- | --------------------------- | * | S | | millisecond, no padding | `54` | * | SSS | | millisecond, padded to 3 | `054` | * | u | | fractional seconds, (5 is a half second, 54 is slightly more) | `54` | * | uu | | fractional seconds, (one or two digits) | `05` | * | uuu | | fractional seconds, (only one digit) | `5` | * | s | | second, no padding | `4` | * | ss | | second, padded to 2 padding | `04` | * | m | | minute, no padding | `7` | * | mm | | minute, padded to 2 | `07` | * | h | | hour in 12-hour time, no padding | `1` | * | hh | | hour in 12-hour time, padded to 2 | `01` | * | H | | hour in 24-hour time, no padding | `13` | * | HH | | hour in 24-hour time, padded to 2 | `13` | * | Z | | narrow offset | `+5` | * | ZZ | | short offset | `+05:00` | * | ZZZ | | techie offset | `+0500` | * | z | | IANA zone | `America/New_York` | * | a | | meridiem | `AM` | * | d | | day of the month, no padding | `6` | * | dd | | day of the month, padded to 2 | `06` | * | E | c | day of the week, as number from 1-7 (Monday is 1, Sunday is 7) | `3` | * | EEE | ccc | day of the week, as an abbreviate localized string | `Wed` | * | EEEE | cccc | day of the week, as an unabbreviated localized string | `Wednesday` | * | M | L | month as an unpadded number | `8` | * | MM | LL | month as an padded number | `08` | * | MMM | LLL | month as an abbreviated localized string | `Aug` | * | MMMM | LLLL | month as an unabbreviated localized string | `August` | * | y | | year, 1-6 digits, very literally | `2014` | * | yy | | two-digit year, interpreted as > 1960 by default (also accepts 4) | `14` | * | yyyy | | four-digit year | `2014` | * | yyyyy | | four- to six-digit years | `10340` | * | yyyyyy | | six-digit years | `010340` | * | G | | abbreviated localized era | `AD` | * | GG | | unabbreviated localized era | `Anno Domini` | * | GGGGG | | one-letter localized era | `A` | * | kk | | ISO week year, unpadded | `17` | * | kkkk | | ISO week year, padded to 4 | `2014` | * | W | | ISO week number, unpadded | `32` | * | WW | | ISO week number, padded to 2 | `32` | * | o | | ordinal (day of year), unpadded | `218` | * | ooo | | ordinal (day of year), padded to 3 | `218` | * | q | | quarter, no padding | `3` | * | D | | localized numeric date | `9/6/2014` | * | DD | | localized date with abbreviated month | `Aug 6, 2014` | * | DDD | | localized date with full month | `August 6, 2014` | * | DDDD | | localized date with full month and weekday | `Wednesday, August 6, 2014` | * | t | | localized time | `1:07 AM` | * | tt | | localized time with seconds | `1:07:04 PM` | * | T | | localized 24-hour time | `13:07` | * | TT | | localized 24-hour time with seconds | `13:07:04` | * | f | | short localized date and time | `8/6/2014, 1:07 PM` | * | ff | | less short localized date and time | `Aug 6, 2014, 1:07 PM` | * | F | | short localized date and time with seconds | `8/6/2014, 1:07:04 PM` | * | FF | | less short localized date and time with seconds | `Aug 6, 2014, 1:07:04 PM` | * | ' | | literal start/end, characters between are not tokenized | `'T'` | * * Sourced from [here](https://moment.github.io/luxon/#/parsing?id=table-of-tokens). */ declare type Tokens = string; /** * # Table of tokens * * (The example values below come from this time `2014-08-06T13:07:04.054` * considered as a local time in America/New_York). * * Note that many tokens supported by the formatter are **not** supported by the parser. * * | Standalone token | Format token | Description | Example | * | ---------------- | ------------ | ----------------------------------------------------------------- | --------------------------- | * | S | | millisecond, no padding | `54` | * | SSS | | millisecond, padded to 3 | `054` | * | u | | fractional seconds, (5 is a half second, 54 is slightly more) | `54` | * | uu | | fractional seconds, (one or two digits) | `05` | * | uuu | | fractional seconds, (only one digit) | `5` | * | s | | second, no padding | `4` | * | ss | | second, padded to 2 padding | `04` | * | m | | minute, no padding | `7` | * | mm | | minute, padded to 2 | `07` | * | h | | hour in 12-hour time, no padding | `1` | * | hh | | hour in 12-hour time, padded to 2 | `01` | * | H | | hour in 24-hour time, no padding | `13` | * | HH | | hour in 24-hour time, padded to 2 | `13` | * | Z | | narrow offset | `+5` | * | ZZ | | short offset | `+05:00` | * | ZZZ | | techie offset | `+0500` | * | z | | IANA zone | `America/New_York` | * | a | | meridiem | `AM` | * | d | | day of the month, no padding | `6` | * | dd | | day of the month, padded to 2 | `06` | * | E | c | day of the week, as number from 1-7 (Monday is 1, Sunday is 7) | `3` | * | EEE | ccc | day of the week, as an abbreviate localized string | `Wed` | * | EEEE | cccc | day of the week, as an unabbreviated localized string | `Wednesday` | * | M | L | month as an unpadded number | `8` | * | MM | LL | month as an padded number | `08` | * | MMM | LLL | month as an abbreviated localized string | `Aug` | * | MMMM | LLLL | month as an unabbreviated localized string | `August` | * | y | | year, 1-6 digits, very literally | `2014` | * | yy | | two-digit year, interpreted as > 1960 by default (also accepts 4) | `14` | * | yyyy | | four-digit year | `2014` | * | yyyyy | | four- to six-digit years | `10340` | * | yyyyyy | | six-digit years | `010340` | * | G | | abbreviated localized era | `AD` | * | GG | | unabbreviated localized era | `Anno Domini` | * | GGGGG | | one-letter localized era | `A` | * | kk | | ISO week year, unpadded | `17` | * | kkkk | | ISO week year, padded to 4 | `2014` | * | W | | ISO week number, unpadded | `32` | * | WW | | ISO week number, padded to 2 | `32` | * | o | | ordinal (day of year), unpadded | `218` | * | ooo | | ordinal (day of year), padded to 3 | `218` | * | q | | quarter, no padding | `3` | * | D | | localized numeric date | `9/6/2014` | * | DD | | localized date with abbreviated month | `Aug 6, 2014` | * | DDD | | localized date with full month | `August 6, 2014` | * | DDDD | | localized date with full month and weekday | `Wednesday, August 6, 2014` | * | t | | localized time | `1:07 AM` | * | tt | | localized time with seconds | `1:07:04 PM` | * | T | | localized 24-hour time | `13:07` | * | TT | | localized 24-hour time with seconds | `13:07:04` | * | f | | short localized date and time | `8/6/2014, 1:07 PM` | * | ff | | less short localized date and time | `Aug 6, 2014, 1:07 PM` | * | F | | short localized date and time with seconds | `8/6/2014, 1:07:04 PM` | * | FF | | less short localized date and time with seconds | `Aug 6, 2014, 1:07:04 PM` | * | ' | | literal start/end, characters between are not tokenized | `'T'` | * * Sourced from [here](https://moment.github.io/luxon/#/parsing?id=table-of-tokens). */ declare type Tokens_2 = string; /** * # Table of tokens * * (The example values below come from this time `2014-08-06T13:07:04.054` * considered as a local time in America/New_York). * * Note that many tokens supported by the formatter are **not** supported by the parser. * * | Standalone token | Format token | Description | Example | * | ---------------- | ------------ | ----------------------------------------------------------------- | --------------------------- | * | S | | millisecond, no padding | `54` | * | SSS | | millisecond, padded to 3 | `054` | * | u | | fractional seconds, (5 is a half second, 54 is slightly more) | `54` | * | uu | | fractional seconds, (one or two digits) | `05` | * | uuu | | fractional seconds, (only one digit) | `5` | * | s | | second, no padding | `4` | * | ss | | second, padded to 2 padding | `04` | * | m | | minute, no padding | `7` | * | mm | | minute, padded to 2 | `07` | * | h | | hour in 12-hour time, no padding | `1` | * | hh | | hour in 12-hour time, padded to 2 | `01` | * | H | | hour in 24-hour time, no padding | `13` | * | HH | | hour in 24-hour time, padded to 2 | `13` | * | Z | | narrow offset | `+5` | * | ZZ | | short offset | `+05:00` | * | ZZZ | | techie offset | `+0500` | * | z | | IANA zone | `America/New_York` | * | a | | meridiem | `AM` | * | d | | day of the month, no padding | `6` | * | dd | | day of the month, padded to 2 | `06` | * | E | c | day of the week, as number from 1-7 (Monday is 1, Sunday is 7) | `3` | * | EEE | ccc | day of the week, as an abbreviate localized string | `Wed` | * | EEEE | cccc | day of the week, as an unabbreviated localized string | `Wednesday` | * | M | L | month as an unpadded number | `8` | * | MM | LL | month as an padded number | `08` | * | MMM | LLL | month as an abbreviated localized string | `Aug` | * | MMMM | LLLL | month as an unabbreviated localized string | `August` | * | y | | year, 1-6 digits, very literally | `2014` | * | yy | | two-digit year, interpreted as > 1960 by default (also accepts 4) | `14` | * | yyyy | | four-digit year | `2014` | * | yyyyy | | four- to six-digit years | `10340` | * | yyyyyy | | six-digit years | `010340` | * | G | | abbreviated localized era | `AD` | * | GG | | unabbreviated localized era | `Anno Domini` | * | GGGGG | | one-letter localized era | `A` | * | kk | | ISO week year, unpadded | `17` | * | kkkk | | ISO week year, padded to 4 | `2014` | * | W | | ISO week number, unpadded | `32` | * | WW | | ISO week number, padded to 2 | `32` | * | o | | ordinal (day of year), unpadded | `218` | * | ooo | | ordinal (day of year), padded to 3 | `218` | * | q | | quarter, no padding | `3` | * | D | | localized numeric date | `9/6/2014` | * | DD | | localized date with abbreviated month | `Aug 6, 2014` | * | DDD | | localized date with full month | `August 6, 2014` | * | DDDD | | localized date with full month and weekday | `Wednesday, August 6, 2014` | * | t | | localized time | `1:07 AM` | * | tt | | localized time with seconds | `1:07:04 PM` | * | T | | localized 24-hour time | `13:07` | * | TT | | localized 24-hour time with seconds | `13:07:04` | * | f | | short localized date and time | `8/6/2014, 1:07 PM` | * | ff | | less short localized date and time | `Aug 6, 2014, 1:07 PM` | * | F | | short localized date and time with seconds | `8/6/2014, 1:07:04 PM` | * | FF | | less short localized date and time with seconds | `Aug 6, 2014, 1:07:04 PM` | * | ' | | literal start/end, characters between are not tokenized | `'T'` | * * Sourced from [here](https://moment.github.io/luxon/#/parsing?id=table-of-tokens). */ declare type Tokens_3 = string; declare type ToObjectOutput< IncludeConfig extends boolean | undefined = undefined, IsValid extends boolean | undefined = undefined, > = IsValid extends true ? _ToObjectOutput : CanBeInvalid extends false ? _ToObjectOutput : Partial<_ToObjectOutput>; export type _ToObjectOutput = & Record<_ToObjectUnit, number> & (IncludeConfig extends true ? LocaleOptions : unknown); declare type ToObjectOutput_2< IncludeConfig extends boolean | undefined = undefined, IsValid extends boolean | undefined = undefined, > = IsValid extends true ? _ToObjectOutput_2 : CanBeInvalid_2 extends false ? _ToObjectOutput_2 : Partial<_ToObjectOutput_2>; declare type _ToObjectOutput_2 = & Record<_ToObjectUnit_2, number> & (IncludeConfig extends true ? LocaleOptions_2 : unknown); export type _ToObjectUnit = Exclude; declare type _ToObjectUnit_2 = Exclude; export declare interface TopLevelDomainOptions { /** * - `true` to use the IANA list of registered TLDs. This is the default value. * - `false` to allow any TLD not listed in the `deny` list, if present. * - A `Set` or array of the allowed TLDs. Cannot be used together with `deny`. */ allow?: Set | string[] | boolean /** * - A `Set` or array of the forbidden TLDs. Cannot be used together with a custom `allow` list. */ deny?: Set | string[] } declare interface ToRelativeCalendarOptions { /** * The DateTime to use as the basis to which this time is compared * @default now */ base?: DateTime | undefined; /** * Override the locale of this DateTime */ locale?: string | undefined; /** If omitted, the method will pick the unit. */ unit?: ToRelativeUnit | undefined; /** * Override the numberingSystem of this DateTime. * The Intl system may choose not to honor this. */ numberingSystem?: NumberingSystem | undefined; } declare interface ToRelativeCalendarOptions_2 { /** * The DateTime to use as the basis to which this time is compared * @default now */ base?: DateTime_2 | undefined; /** * Override the locale of this DateTime */ locale?: string | undefined; /** If omitted, the method will pick the unit. */ unit?: ToRelativeUnit_2 | undefined; /** * Override the numberingSystem of this DateTime. * The Intl system may choose not to honor this. */ numberingSystem?: NumberingSystem_2 | undefined; } declare interface ToRelativeOptions extends Omit { /** * The style of units, must be "long", "short", or "narrow". * @default long */ style?: StringUnitLength | undefined; /** * A single unit or an array of units. If an array is supplied, the method will pick the best one * to use from the array. If omitted, the method will pick the unit from a default set. */ unit?: ToRelativeUnit | ToRelativeUnit[] | undefined; /** * Whether or not to round the numbers in the output. * @default true */ round?: boolean | undefined; /** * Rounding method to use when rounding the numbers in the output * @default 'trunc' */ rounding?: "trunc" | "expand" | "round" | "floor" | "ceil" | undefined; /** * Padding in milliseconds. This allows you to round up the result if it fits inside the threshold. * Do not use this in combination with `{round: false}` because the decimal output will include the padding. * @default 0 */ padding?: number | undefined; } declare interface ToRelativeOptions_2 extends Omit { /** * The style of units, must be "long", "short", or "narrow". * @default long */ style?: StringUnitLength_2 | undefined; /** * A single unit or an array of units. If an array is supplied, the method will pick the best one * to use from the array. If omitted, the method will pick the unit from a default set. */ unit?: ToRelativeUnit_2 | ToRelativeUnit_2[] | undefined; /** * Whether or not to round the numbers in the output. * @default true */ round?: boolean | undefined; /** * Rounding method to use when rounding the numbers in the output * @default 'trunc' */ rounding?: "trunc" | "expand" | "round" | "floor" | "ceil" | undefined; /** * Padding in milliseconds. This allows you to round up the result if it fits inside the threshold. * Do not use this in combination with `{round: false}` because the decimal output will include the padding. * @default 0 */ padding?: number | undefined; } declare type ToRelativeUnit = "years" | "quarters" | "months" | "weeks" | "days" | "hours" | "minutes" | "seconds"; declare type ToRelativeUnit_2 = "years" | "quarters" | "months" | "weeks" | "days" | "hours" | "minutes" | "seconds"; declare interface ToSQLOptions { /** * Include the offset, such as 'Z' or '-04:00' * @default true */ includeOffset?: boolean | undefined; /** * Include the zone, such as 'America/New_York'. Overrides includeOffset. * @default false */ includeZone?: boolean | undefined; /** * include the space between the time and the offset, such as '05:15:16.345 -04:00' * @default true */ includeOffsetSpace?: boolean; } declare interface ToSQLOptions_2 { /** * Include the offset, such as 'Z' or '-04:00' * @default true */ includeOffset?: boolean | undefined; /** * Include the zone, such as 'America/New_York'. Overrides includeOffset. * @default false */ includeZone?: boolean | undefined; /** * include the space between the time and the offset, such as '05:15:16.345 -04:00' * @default true */ includeOffsetSpace?: boolean; } /** * TS only settings. Consumers can declaration merge this interface to change TS options. * * @see Settings.throwOnInvalid */ // eslint-disable-next-line @typescript-eslint/no-empty-interface declare interface TSSettings {} /** * TS only settings. Consumers can declaration merge this interface to change TS options. * * @see Settings.throwOnInvalid */ // eslint-disable-next-line @typescript-eslint/no-empty-interface declare interface TSSettings_2 {} export declare type Types = | 'any' | 'alternatives' | 'array' | 'boolean' | 'binary' | 'date' | 'function' | 'link' | 'number' | 'object' | 'string' | 'symbol' export declare type UnwrapSchemaLikeWithoutArray = T extends SchemaLikeWithoutArray_2 ? U : never /** * Faster version of decodeURIComponent() that does not throw. * * @param string - the URL string to decode. * * @returns the decoded string or null if invalid. */ declare function uriDecode(string: string): string; export declare interface UriOptions { /** * Specifies one or more acceptable Schemes, should only include the scheme name. * Can be an Array or String (strings are automatically escaped for use in a Regular Expression). */ scheme?: string | RegExp | Array /** * Allow relative URIs. * * @default false */ allowRelative?: boolean /** * Restrict only relative URIs. * * @default false */ relativeOnly?: boolean /** * Allows unencoded square brackets inside the query string. * This is NOT RFC 3986 compliant but query strings like abc[]=123&abc[]=456 are very common these days. * * @default false */ allowQuerySquareBrackets?: boolean /** * Validate the domain component using the options specified in `string.domain()`. */ domain?: DomainOptions /** * Encode URI before validation. * * @default false */ encodeUri?: boolean } /** * Generates a regular expression used to validate URI addresses. * * @param options - optional settings. * * @returns an object with the regular expression and meta data. */ declare function uriRegex(options?: Options_2): Expression_2; declare interface _UseLocaleWeekOption { /** If true, use weeks based on the locale, i.e., use the locale-dependent start of the week */ useLocaleWeeks?: boolean; } declare interface _UseLocaleWeekOption_2 { /** If true, use weeks based on the locale, i.e., use the locale-dependent start of the week */ useLocaleWeeks?: boolean; } declare type Valid = true; declare type Valid_2 = true; declare function validateDomainOptions(options: DomainOptions_2): void; export declare interface ValidationContext { [key: string]: any key?: string label?: string value?: any } export declare interface ValidationError extends Error { name: 'ValidationError'; isJoi: boolean; /** * array of errors. */ details: ValidationErrorItem[]; /** * function that returns a string with an annotated version of the object pointing at the places where errors occurred. * * NOTE: This method does not exist in browser builds of Joi * * @param stripColors - if truthy, will strip the colors out of the output. */ annotate(stripColors?: boolean): string; _original: any; } /** * Represents a validation error encountered during the validation of a payload. * When using syncronous validation, this error is returned along an undefined value. * When using asynchronous validation, this error is thrown. */ export declare const ValidationError: ValidationError; declare interface ValidationError_2 extends Error { name: 'ValidationError' isJoi: boolean /** * array of errors. */ details: ValidationErrorItem_2[] /** * function that returns a string with an annotated version of the object pointing at the places where errors occurred. * * NOTE: This method does not exist in browser builds of Joi * * @param stripColors - if truthy, will strip the colors out of the output. */ annotate(stripColors?: boolean): string _original: any } export declare type ValidationErrorFunction = ( errors: ErrorReport[] ) => string | ValidationErrorItem_2 | Error | ErrorReport[] export declare interface ValidationErrorItem { message: string; path: Array; type: string; context?: Context; } declare interface ValidationErrorItem_2 { message: string path: Array type: string context?: ValidationContext } export declare interface ValidationOptions extends BaseValidationOptions { /** * overrides individual error messages. Defaults to no override (`{}`). * Messages use the same rules as templates. * Variables in double braces `{{var}}` are HTML escaped if the option `errors.escapeHtml` is set to true. * * @default {} */ messages?: LanguageMessages } export declare type ValidationResult = | { error: undefined warning?: ValidationError_2 value: TSchema } | { error: ValidationError_2 warning?: ValidationError_2 value: any } /** * Extended Joi root interface that includes custom schema types for * additional validation scenarios. * * This interface extends the standard Joi Root interface to include * additional schema types * * @example * ```typescript * import { validator } from '@nhtio/validation' * * const schema = validator.object({ * id: validator.bigint().positive().required(), * balance: validator.bigint().min(0n).optional() * }) * ``` * * @public */ export declare interface ValidationRoot extends Omit { /** * Generates a schema object that matches any data type. */ any(): AnySchema; /** * Generates a schema object that matches an array data type. */ array(): ArraySchema; /** * Generates a schema object that matches a boolean data type (as well as the strings 'true', 'false', 'yes', and 'no'). Can also be called via boolean(). */ bool(): BooleanSchema; /** * Generates a schema object that matches a boolean data type (as well as the strings 'true', 'false', 'yes', and 'no'). Can also be called via bool(). */ boolean(): BooleanSchema; /** * Generates a schema object that matches a Buffer data type (as well as the strings which will be converted to Buffers). */ binary(): BinarySchema; /** * Generates a schema object that matches a date type (as well as a JavaScript date string or number of milliseconds). */ date(): DateSchema; /** * Generates a schema object that matches a function type. */ func(): FunctionSchema; /** * Generates a schema object that matches a function type. */ function(): FunctionSchema; /** * Generates a schema object that matches a number data type (as well as strings that can be converted to numbers). */ number(): NumberSchema; /** * Generates a schema object that matches an object data type (as well as JSON strings that have been parsed into objects). */ object(schema?: SchemaMap_2): ObjectSchema; /** * Generates a schema object that matches a string data type. Note that empty strings are not allowed by default and must be enabled with allow(''). */ string(): StringSchema; /** * Generates a schema object that matches any symbol. */ symbol(): SymbolSchema; /** * Generates a type that will match one of the provided alternative schemas */ alternatives(types: SchemaLike_2[]): AlternativesSchema; alternatives(...types: SchemaLike_2[]): AlternativesSchema; /** * Alias for `alternatives` */ alt(types: SchemaLike_2[]): AlternativesSchema; alt(...types: SchemaLike_2[]): AlternativesSchema; /** * Links to another schema node and reuses it for validation, typically for creative recursive schemas. * * @param ref - the reference to the linked schema node. * Cannot reference itself or its children as well as other links. * Links can be expressed in relative terms like value references (`Joi.link('...')`), * in absolute terms from the schema run-time root (`Joi.link('/a')`), * or using schema ids implicitly using object keys or explicitly using `any.id()` (`Joi.link('#a.b.c')`). */ link(ref?: string): LinkSchema; /** * Generates a schema object that matches a BigInt data type. */ bigint(): BigIntSchema; /** * Generates a schema object that matches a DateTime data type. */ datetime(): DatetimeSchema; /** * Generates a schema object that matches a phone number data type. * * @param country - Optional country code or reference for phone validation */ phone(country?: CountryOrUnknown | Reference_2 | null): PhoneSchema; /** * Returns an object where each key is a plain joi schema type. * Useful for creating type shortcuts using deconstruction. * Note that the types are already formed and do not need to be called as functions (e.g. `string`, not `string()`). */ types(): { alternatives: AlternativesSchema; any: AnySchema; array: ArraySchema; binary: BinarySchema; boolean: BooleanSchema; date: DateSchema; function: FunctionSchema; link: LinkSchema; number: NumberSchema; object: ObjectSchema; string: StringSchema; symbol: SymbolSchema; bigint: BigIntSchema; datetime: DatetimeSchema; phone: PhoneSchema; }; /** * Whitelists a value */ allow(...values: any[]): Schema; /** * Adds the provided values into the allowed whitelist and marks them as the only valid values allowed. */ valid(...values: any[]): Schema; equal(...values: any[]): Schema; /** * Blacklists a value */ invalid(...values: any[]): Schema; disallow(...values: any[]): Schema; not(...values: any[]): Schema; /** * Marks a key as required which will not allow undefined as value. All keys are optional by default. */ required(): Schema; /** * Alias of `required`. */ exist(): Schema; /** * Marks a key as optional which will allow undefined as values. Used to annotate the schema for readability as all keys are optional by default. */ optional(): Schema; /** * Marks a key as forbidden which will not allow any value except undefined. Used to explicitly forbid keys. */ forbidden(): Schema; /** * Overrides the global validate() options for the current key and any sub-key. */ preferences(options: ValidationOptions): Schema; /** * Overrides the global validate() options for the current key and any sub-key. */ prefs(options: ValidationOptions): Schema; /** * Converts the type into an alternatives type where the conditions are merged into the type definition where: */ when(ref: string | Reference_2, options: WhenOptions | WhenOptions[]): AlternativesSchema; when(ref: Schema, options: WhenSchemaOptions): AlternativesSchema; /** * Creates a reference to another schema key. */ ref(key: string, options?: ReferenceOptions): Reference_2; /** * Sets a global internationalization callback that applies to all validator instances. * * This method sets a fallback translation function that will be used by the `$i18n` method * when no instance-specific callback has been set via `$setI18n`. Once `$setI18n` is called * on an instance, that instance will use its own callback instead of the global one. * * The global callback provides a convenient way to set default translations across your * entire application while still allowing individual validator instances to override * with their own translations when needed. * * @param callback - The I18nCallback function that will handle global message translation * @returns The validator instance for chaining * * @example * ```typescript * // Set up global Spanish translations * validator.$setGlobalI18n((term: string) => { * return spanishTranslations[term] || term * }) * * // All validators will now use Spanish by default * const schema1 = validator.string().min(5) * const schema2 = validator.number().positive() * * // But you can still override for specific instances * const germanSchema = validator.string().$setI18n(germanCallback) * ``` */ $setI18n: SetI18nCallback; /** * Clears the global internationalization callback. * * This method removes any previously set global i18n callback, causing the `$i18n` method * to fall back to default English messages for validator instances that haven't had their * own callback set via `$setI18n`. * * This is useful for testing scenarios, dynamic language switching, or memory cleanup * when you no longer need global translations. * * @returns The validator instance for chaining * * @example * ```typescript * // Set up global translations * validator.$setGlobalI18n(spanishCallback) * * // Later, clear them to return to default English * validator.$clearGlobalI18n() * * // Now all validators use default English messages again * const schema = validator.string().min(5) // Uses English messages * ``` */ $clearI18n: () => ValidationRoot; $i18n: I18nCallback; } export declare interface ValidationWarning { message: string details: ValidationErrorItem_2[] } export declare const validator: ValidationRoot; declare type Version = 'ipv4' | 'ipv6' | 'ipvfuture'; /** * The current version of the package. * * @tip This is a constant that is replaced during the build process with the actual version of the package. */ export declare const version: string; declare type WeekdayNumbers = 1 | 2 | 3 | 4 | 5 | 6 | 7; declare type WeekdayNumbers_2 = 1 | 2 | 3 | 4 | 5 | 6 | 7; declare type WeekNumbers = | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53; declare type WeekNumbers_2 = | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53; declare interface WeekSettings { firstDay: WeekdayNumbers; minimalDays: WeekdayNumbers; weekend: WeekdayNumbers[]; } declare interface WeekSettings_2 { firstDay: WeekdayNumbers_2; minimalDays: WeekdayNumbers_2; weekend: WeekdayNumbers_2[]; } export declare interface WhenOptions { /** * the required condition joi type. */ is?: SchemaLike_2 /** * the negative version of `is` (`then` and `otherwise` have reverse * roles). */ not?: SchemaLike_2 /** * the alternative schema type if the condition is true. Required if otherwise or switch are missing. */ then?: SchemaLike_2 /** * the alternative schema type if the condition is false. Required if then or switch are missing. */ otherwise?: SchemaLike_2 /** * the list of cases. Required if then is missing. Required if then or otherwise are missing. */ switch?: Array /** * whether to stop applying further conditions if the condition is true. */ break?: boolean } export declare interface WhenSchemaOptions { /** * the alternative schema type if the condition is true. Required if otherwise is missing. */ then?: SchemaLike_2 /** * the alternative schema type if the condition is false. Required if then is missing. */ otherwise?: SchemaLike_2 } declare abstract class Zone { /** * The type of zone */ get type(): IfValid; /** * The name of this zone. */ get name(): string; /** * Returns whether the offset is known to be fixed for the whole year. */ get isUniversal(): IfValid; /** * Returns the offset's common name (such as EST) at the specified timestamp * * @param ts - Epoch milliseconds for which to get the name * @param options - Options to affect the format * @param options.format - What style of offset to return. * @param options.locale - What locale to return the offset name in. */ offsetName(ts: number, options: ZoneOffsetOptions): IfValid; /** * Returns the offset's value as a string * * @param ts - Epoch milliseconds for which to get the offset * @param format - What style of offset to return. * Accepts 'narrow', 'short', or 'techie'. Returning '+6', '+06:00', or '+0600' respectively */ formatOffset(ts: number, format: ZoneOffsetFormat): IfValid; /** * Return the offset in minutes for this zone at the specified timestamp. * * @param ts - Epoch milliseconds for which to compute the offset */ offset(ts: number): IfValid; /** * Return whether this Zone is equal to another zone * * @param other - the zone to compare */ equals(other: Zone): IfValid; /** * Return whether this Zone is valid. */ get isValid(): IfValid; } declare abstract class Zone_2 { /** * The type of zone */ get type(): IfValid_2; /** * The name of this zone. */ get name(): string; /** * Returns whether the offset is known to be fixed for the whole year. */ get isUniversal(): IfValid_2; /** * Returns the offset's common name (such as EST) at the specified timestamp * * @param ts - Epoch milliseconds for which to get the name * @param options - Options to affect the format * @param options.format - What style of offset to return. * @param options.locale - What locale to return the offset name in. */ offsetName(ts: number, options: ZoneOffsetOptions_2): IfValid_2; /** * Returns the offset's value as a string * * @param ts - Epoch milliseconds for which to get the offset * @param format - What style of offset to return. * Accepts 'narrow', 'short', or 'techie'. Returning '+6', '+06:00', or '+0600' respectively */ formatOffset(ts: number, format: ZoneOffsetFormat_2): IfValid_2; /** * Return the offset in minutes for this zone at the specified timestamp. * * @param ts - Epoch milliseconds for which to compute the offset */ offset(ts: number): IfValid_2; /** * Return whether this Zone is equal to another zone * * @param other - the zone to compare */ equals(other: Zone_2): IfValid_2; /** * Return whether this Zone is valid. */ get isValid(): IfValid_2; } /** * What style of offset to return. * Returning '+6', '+06:00', or '+0600' respectively */ declare type ZoneOffsetFormat = "narrow" | "short" | "techie"; /** * What style of offset to return. * Returning '+6', '+06:00', or '+0600' respectively */ declare type ZoneOffsetFormat_2 = "narrow" | "short" | "techie"; declare interface ZoneOffsetOptions { /** * What style of offset to return. */ format?: "short" | "long" | undefined; /** * What locale to return the offset name in. */ locale?: string | undefined; } declare interface ZoneOffsetOptions_2 { /** * What style of offset to return. */ format?: "short" | "long" | undefined; /** * What locale to return the offset name in. */ locale?: string | undefined; } declare interface ZoneOptions { /** * If true, adjust the underlying time so that the local time stays the same, but in the target zone. * You should rarely need this. * Defaults to false. */ keepLocalTime?: boolean | undefined; /** * @deprecated since 0.2.12. Use keepLocalTime instead */ keepCalendarTime?: boolean | undefined; } declare interface ZoneOptions_2 { /** * If true, adjust the underlying time so that the local time stays the same, but in the target zone. * You should rarely need this. * Defaults to false. */ keepLocalTime?: boolean | undefined; /** * @deprecated since 0.2.12. Use keepLocalTime instead */ keepCalendarTime?: boolean | undefined; } export { }