Skip to content

promise

Validates a field using a custom asynchronous function.

Options

OptionTypeDefaultDescription
promise(input: ValidatorInput) => Promise<{ valid: boolean, message?: string }>requiredCustom async validation function
messagestringlocale defaultCustom error message

Playground

Valid values

ValueNotes
Promise resolves { valid: true }Validation passes

Invalid values

ValueReason
Promise resolves { valid: false }Validation fails with default or inline message

Notes

  • Empty string ("") always returns valid: true — validators only run on non-empty values. Combine with notEmpty to require a value.
  • Same input object as callback: value, elements, options, field.
  • For synchronous checks, use callback instead.
  • Rejection (thrown error) is treated as invalid.

Released under the MIT License.