@@ -266,11 +266,12 @@ export type NumberField = {
266
266
/** Set a value for the number field to increment / decrement using browser controls. */
267
267
step ?: number
268
268
} & Admin
269
- /** Maximum value accepted. Used in the default `validation ` function. */
269
+ /** Maximum value accepted. Used in the default `validate ` function. */
270
270
max ?: number
271
- /** Minimum value accepted. Used in the default `validation ` function. */
271
+ /** Minimum value accepted. Used in the default `validate ` function. */
272
272
min ?: number
273
273
type : 'number'
274
+ validate ?: Validate < number | number [ ] , unknown , unknown , NumberField >
274
275
} & (
275
276
| {
276
277
/** Makes this field an ordered array of numbers instead of just a single number. */
@@ -306,6 +307,7 @@ export type TextField = {
306
307
maxLength ?: number
307
308
minLength ?: number
308
309
type : 'text'
310
+ validate ?: Validate < string | string [ ] , unknown , unknown , TextField >
309
311
} & (
310
312
| {
311
313
/** Makes this field an ordered array of strings instead of just a single string. */
@@ -338,6 +340,7 @@ export type EmailField = {
338
340
placeholder ?: Record < string , string > | string
339
341
} & Admin
340
342
type : 'email'
343
+ validate ?: Validate < string , unknown , unknown , EmailField >
341
344
} & FieldBase
342
345
343
346
export type TextareaField = {
@@ -355,6 +358,7 @@ export type TextareaField = {
355
358
maxLength ?: number
356
359
minLength ?: number
357
360
type : 'textarea'
361
+ validate ?: Validate < string , unknown , unknown , TextareaField >
358
362
} & FieldBase
359
363
360
364
export type CheckboxField = {
@@ -367,6 +371,7 @@ export type CheckboxField = {
367
371
}
368
372
} & Admin
369
373
type : 'checkbox'
374
+ validate ?: Validate < unknown , unknown , unknown , CheckboxField >
370
375
} & FieldBase
371
376
372
377
export type DateField = {
@@ -381,6 +386,7 @@ export type DateField = {
381
386
placeholder ?: Record < string , string > | string
382
387
} & Admin
383
388
type : 'date'
389
+ validate ?: Validate < unknown , unknown , unknown , DateField >
384
390
} & FieldBase
385
391
386
392
export type GroupField = {
@@ -396,15 +402,16 @@ export type GroupField = {
396
402
*/
397
403
interfaceName ?: string
398
404
type : 'group'
399
- } & Omit < FieldBase , 'required' | 'validation' >
405
+ validate ?: Validate < unknown , unknown , unknown , GroupField >
406
+ } & Omit < FieldBase , 'required' >
400
407
401
408
export type RowAdmin = Omit < Admin , 'description' >
402
409
403
410
export type RowField = {
404
411
admin ?: RowAdmin
405
412
fields : Field [ ]
406
413
type : 'row'
407
- } & Omit < FieldBase , 'admin' | 'label' | 'name' >
414
+ } & Omit < FieldBase , 'admin' | 'label' | 'name' | 'validate' >
408
415
409
416
export type CollapsibleField = {
410
417
fields : Field [ ]
@@ -426,7 +433,7 @@ export type CollapsibleField = {
426
433
label : Required < FieldBase [ 'label' ] >
427
434
}
428
435
) &
429
- Omit < FieldBase , 'label' | 'name' >
436
+ Omit < FieldBase , 'label' | 'name' | 'validate' >
430
437
431
438
export type TabsAdmin = Omit < Admin , 'description' >
432
439
@@ -435,7 +442,7 @@ type TabBase = {
435
442
fields : Field [ ]
436
443
interfaceName ?: string
437
444
saveToJWT ?: boolean | string
438
- } & Omit < FieldBase , 'required' | 'validation ' >
445
+ } & Omit < FieldBase , 'required' | 'validate ' >
439
446
440
447
export type NamedTab = {
441
448
/** Customize generated GraphQL and Typescript schema names.
@@ -521,6 +528,7 @@ export type UploadField = {
521
528
maxDepth ?: number
522
529
relationTo : CollectionSlug
523
530
type : 'upload'
531
+ validate ?: Validate < unknown , unknown , unknown , UploadField >
524
532
} & FieldBase
525
533
526
534
type CodeAdmin = {
@@ -537,6 +545,7 @@ export type CodeField = {
537
545
maxLength ?: number
538
546
minLength ?: number
539
547
type : 'code'
548
+ validate ?: Validate < string , unknown , unknown , CodeField >
540
549
} & Omit < FieldBase , 'admin' >
541
550
542
551
type JSONAdmin = {
@@ -555,6 +564,7 @@ export type JSONField = {
555
564
uri : string
556
565
}
557
566
type : 'json'
567
+ validate ?: Validate < Record < string , unknown > , unknown , unknown , JSONField >
558
568
} & Omit < FieldBase , 'admin' >
559
569
560
570
export type SelectField = {
@@ -577,6 +587,7 @@ export type SelectField = {
577
587
hasMany ?: boolean
578
588
options : Option [ ]
579
589
type : 'select'
590
+ validate ?: Validate < string , unknown , unknown , SelectField >
580
591
} & FieldBase
581
592
582
593
type SharedRelationshipProperties = {
@@ -589,6 +600,7 @@ type SharedRelationshipProperties = {
589
600
*/
590
601
maxDepth ?: number
591
602
type : 'relationship'
603
+ validate ?: Validate < unknown , unknown , unknown , SharedRelationshipProperties >
592
604
} & (
593
605
| {
594
606
hasMany : true
@@ -627,12 +639,14 @@ type RelationshipAdmin = {
627
639
}
628
640
isSortable ?: boolean
629
641
} & Admin
642
+
630
643
export type PolymorphicRelationshipField = {
631
644
admin ?: {
632
645
sortOptions ?: { [ collectionSlug : CollectionSlug ] : string }
633
646
} & RelationshipAdmin
634
647
relationTo : CollectionSlug [ ]
635
648
} & SharedRelationshipProperties
649
+
636
650
export type SingleRelationshipField = {
637
651
admin ?: {
638
652
sortOptions ?: string
@@ -707,6 +721,7 @@ export type ArrayField = {
707
721
maxRows ?: number
708
722
minRows ?: number
709
723
type : 'array'
724
+ validate ?: Validate < unknown [ ] , unknown , unknown , ArrayField >
710
725
} & FieldBase
711
726
712
727
export type RadioField = {
@@ -727,6 +742,7 @@ export type RadioField = {
727
742
enumName ?: DBIdentifierName
728
743
options : Option [ ]
729
744
type : 'radio'
745
+ validate ?: Validate < string , unknown , unknown , RadioField >
730
746
} & FieldBase
731
747
732
748
export type Block = {
@@ -781,10 +797,12 @@ export type BlockField = {
781
797
maxRows ?: number
782
798
minRows ?: number
783
799
type : 'blocks'
800
+ validate ?: Validate < string , unknown , unknown , BlockField >
784
801
} & FieldBase
785
802
786
803
export type PointField = {
787
804
type : 'point'
805
+ validate ?: Validate < unknown , unknown , unknown , PointField >
788
806
} & FieldBase
789
807
790
808
export type Field =
0 commit comments