@nhtio/validation 1.20250719.2 → 1.20250804.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -0
- package/index.cjs +10 -4
- package/index.cjs.map +1 -1
- package/index.mjs +10 -4
- package/index.mjs.map +1 -1
- package/package.json +1 -1
- package/private/patches/index.d.ts +3 -0
- package/private/patches/json.d.ts +2 -0
- package/private/schemas/datetime.d.ts +18 -9
package/package.json
CHANGED
|
@@ -2,8 +2,8 @@ import { DateTime } from 'luxon';
|
|
|
2
2
|
import { Dayjs } from 'dayjs';
|
|
3
3
|
import type { Tokens } from '../types';
|
|
4
4
|
import type { AnySchema } from '../schemas';
|
|
5
|
-
import type { Zone, LocaleOptions, DateObjectUnits } from 'luxon';
|
|
6
5
|
import type { ExtensionFactory, Reference } from 'joi';
|
|
6
|
+
import type { Zone, LocaleOptions, DateObjectUnits, ZoneOptions, ToISOTimeOptions, ToISODateOptions, ToSQLOptions, ToRelativeOptions } from 'luxon';
|
|
7
7
|
/**
|
|
8
8
|
* Types that can be parsed into a DateTime object.
|
|
9
9
|
*
|
|
@@ -232,7 +232,7 @@ export interface DatetimeSchema<TSchema = DateTime> extends AnySchema<TSchema> {
|
|
|
232
232
|
* // Returns DateTime in Eastern timezone
|
|
233
233
|
* ```
|
|
234
234
|
*/
|
|
235
|
-
setZone(zone: string | Zone): this;
|
|
235
|
+
setZone(zone: string | Zone, opts?: ZoneOptions): this;
|
|
236
236
|
/**
|
|
237
237
|
* Formats the datetime using a custom format string during validation.
|
|
238
238
|
*
|
|
@@ -264,6 +264,7 @@ export interface DatetimeSchema<TSchema = DateTime> extends AnySchema<TSchema> {
|
|
|
264
264
|
/**
|
|
265
265
|
* Converts the datetime to ISO 8601 string format during validation.
|
|
266
266
|
*
|
|
267
|
+
* @param opts - Options for ISO string formatting
|
|
267
268
|
* @returns The schema instance for method chaining
|
|
268
269
|
*
|
|
269
270
|
* @example
|
|
@@ -273,10 +274,11 @@ export interface DatetimeSchema<TSchema = DateTime> extends AnySchema<TSchema> {
|
|
|
273
274
|
* // Returns: "2023-07-15T15:30:00.000Z"
|
|
274
275
|
* ```
|
|
275
276
|
*/
|
|
276
|
-
toISO(): this;
|
|
277
|
+
toISO(opts?: ToISOTimeOptions): this;
|
|
277
278
|
/**
|
|
278
279
|
* Converts the datetime to ISO date format (YYYY-MM-DD) during validation.
|
|
279
280
|
*
|
|
281
|
+
* @param opts - Options for ISO date formatting
|
|
280
282
|
* @returns The schema instance for method chaining
|
|
281
283
|
*
|
|
282
284
|
* @example
|
|
@@ -286,7 +288,7 @@ export interface DatetimeSchema<TSchema = DateTime> extends AnySchema<TSchema> {
|
|
|
286
288
|
* // Returns: "2023-07-15"
|
|
287
289
|
* ```
|
|
288
290
|
*/
|
|
289
|
-
toISODate(): this;
|
|
291
|
+
toISODate(opts?: ToISODateOptions): this;
|
|
290
292
|
/**
|
|
291
293
|
* Converts the datetime to ISO week date format during validation.
|
|
292
294
|
*
|
|
@@ -303,6 +305,7 @@ export interface DatetimeSchema<TSchema = DateTime> extends AnySchema<TSchema> {
|
|
|
303
305
|
/**
|
|
304
306
|
* Converts the datetime to ISO time format during validation.
|
|
305
307
|
*
|
|
308
|
+
* @param opts - Options for ISO time formatting
|
|
306
309
|
* @returns The schema instance for method chaining
|
|
307
310
|
*
|
|
308
311
|
* @example
|
|
@@ -312,7 +315,7 @@ export interface DatetimeSchema<TSchema = DateTime> extends AnySchema<TSchema> {
|
|
|
312
315
|
* // Returns: "15:30:00.000Z"
|
|
313
316
|
* ```
|
|
314
317
|
*/
|
|
315
|
-
toISOTime(): this;
|
|
318
|
+
toISOTime(opts?: ToISOTimeOptions): this;
|
|
316
319
|
/**
|
|
317
320
|
* Converts the datetime to RFC 2822 format during validation.
|
|
318
321
|
*
|
|
@@ -355,6 +358,7 @@ export interface DatetimeSchema<TSchema = DateTime> extends AnySchema<TSchema> {
|
|
|
355
358
|
/**
|
|
356
359
|
* Converts the datetime to SQL time format (HH:mm:ss.SSS) during validation.
|
|
357
360
|
*
|
|
361
|
+
* @param opts - Options for SQL time formatting
|
|
358
362
|
* @returns The schema instance for method chaining
|
|
359
363
|
*
|
|
360
364
|
* @example
|
|
@@ -364,10 +368,11 @@ export interface DatetimeSchema<TSchema = DateTime> extends AnySchema<TSchema> {
|
|
|
364
368
|
* // Returns: "15:30:45.123"
|
|
365
369
|
* ```
|
|
366
370
|
*/
|
|
367
|
-
toSQLTime(): this;
|
|
371
|
+
toSQLTime(opts?: ToSQLOptions): this;
|
|
368
372
|
/**
|
|
369
373
|
* Converts the datetime to SQL datetime format during validation.
|
|
370
374
|
*
|
|
375
|
+
* @param opts - Options for SQL formatting
|
|
371
376
|
* @returns The schema instance for method chaining
|
|
372
377
|
*
|
|
373
378
|
* @example
|
|
@@ -377,7 +382,7 @@ export interface DatetimeSchema<TSchema = DateTime> extends AnySchema<TSchema> {
|
|
|
377
382
|
* // Returns: "2023-07-15 15:30:45.123 Z"
|
|
378
383
|
* ```
|
|
379
384
|
*/
|
|
380
|
-
toSQL(): this;
|
|
385
|
+
toSQL(opts?: ToSQLOptions): this;
|
|
381
386
|
/**
|
|
382
387
|
* Converts the datetime to milliseconds since Unix epoch during validation.
|
|
383
388
|
*
|
|
@@ -446,6 +451,7 @@ export interface DatetimeSchema<TSchema = DateTime> extends AnySchema<TSchema> {
|
|
|
446
451
|
/**
|
|
447
452
|
* Converts the datetime to a plain object representation during validation.
|
|
448
453
|
*
|
|
454
|
+
* @param opts - Options for object conversion
|
|
449
455
|
* @returns The schema instance for method chaining
|
|
450
456
|
*
|
|
451
457
|
* @example
|
|
@@ -455,7 +461,9 @@ export interface DatetimeSchema<TSchema = DateTime> extends AnySchema<TSchema> {
|
|
|
455
461
|
* // Returns: { year: 2023, month: 7, day: 15, hour: 15, minute: 30, second: 0, millisecond: 0 }
|
|
456
462
|
* ```
|
|
457
463
|
*/
|
|
458
|
-
toObject(
|
|
464
|
+
toObject(opts?: {
|
|
465
|
+
includeConfig?: boolean;
|
|
466
|
+
}): this;
|
|
459
467
|
/**
|
|
460
468
|
* Converts the datetime to a JavaScript Date object during validation.
|
|
461
469
|
*
|
|
@@ -472,6 +480,7 @@ export interface DatetimeSchema<TSchema = DateTime> extends AnySchema<TSchema> {
|
|
|
472
480
|
/**
|
|
473
481
|
* Converts the datetime to a relative time string during validation.
|
|
474
482
|
*
|
|
483
|
+
* @param opts - Options for relative time formatting
|
|
475
484
|
* @returns The schema instance for method chaining
|
|
476
485
|
*
|
|
477
486
|
* @example
|
|
@@ -481,7 +490,7 @@ export interface DatetimeSchema<TSchema = DateTime> extends AnySchema<TSchema> {
|
|
|
481
490
|
* // Returns: "2 hours ago" (relative to current time)
|
|
482
491
|
* ```
|
|
483
492
|
*/
|
|
484
|
-
toRelative(): this;
|
|
493
|
+
toRelative(opts?: ToRelativeOptions): this;
|
|
485
494
|
/**
|
|
486
495
|
* Sets the locale for the datetime during validation.
|
|
487
496
|
*
|