( value: unknown, labelOrRecipe: string | ValidationWithMessagesRecipe, recipe?: ValidationRecipe, )
| 586 | recipe: ValidationRecipe, |
| 587 | ): void |
| 588 | export function validate( |
| 589 | value: unknown, |
| 590 | labelOrRecipe: string | ValidationWithMessagesRecipe, |
| 591 | recipe?: ValidationRecipe, |
| 592 | ): void { |
| 593 | let label, validationRecipe |
| 594 | |
| 595 | if (typeof labelOrRecipe === 'object') { |
| 596 | label = '' |
| 597 | validationRecipe = labelOrRecipe |
| 598 | } else { |
| 599 | label = labelOrRecipe |
| 600 | validationRecipe = recipe as ValidationRecipe |
| 601 | } |
| 602 | |
| 603 | for (const [validator, options] of Object.entries(validationRecipe)) { |
| 604 | if (typeof options === 'undefined') { |
| 605 | continue |
| 606 | } |
| 607 | |
| 608 | VALIDATORS[validator as keyof typeof VALIDATORS](value, label, options) |
| 609 | } |
| 610 | } |
| 611 | |
| 612 | // Run a custom validation function which should either throw or return nothing. |
| 613 | // Why not just write your own function? Because GraphQL will swallow it and |
no test coverage detected