endsWith
Creates an ends with validation action.
const Action = v.endsWith<TInput, TRequirement, TMessage>(requirement, message);
Generics
TInputextends stringTRequirementextends stringTMessageextends ErrorMessage<EndsWithIssue<TInput, TRequirement>> | undefined
Parameters
requirementTRequirementmessageTMessage
Explanation
With endsWith you can validate the end of a string. If the end does not match the requirement, you can use message to customize the error message.
Returns
ActionEndsWithAction<TInput, TRequirement, TMessage>
Examples
The following examples show how endsWith can be used.
Email schema
Schema to validate an email with a specific domain.
const EmailSchema = v.pipe(v.string(), v.email(), v.endsWith('@example.com'));
Related
The following APIs can be combined with endsWith.
Schemas
Methods
Utils
© Fabian Hiller
Licensed under the MIT License.
https://valibot.dev/api/endsWith/