Spec-Zone.ru › Valibot

endsWith

Creates an ends with validation action.

const Action = v.endsWith<TInput, TRequirement, TMessage>(requirement, message);

Generics

  • TInput extends string
  • TRequirement extends string
  • TMessage extends ErrorMessage<EndsWithIssue<TInput, TRequirement>> | undefined

Parameters

  • requirement TRequirement
  • message TMessage

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

  • Action EndsWithAction<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

any, custom, string

Methods

pipe

Utils

isOfKind, isOfType

© Fabian Hiller
Licensed under the MIT License.
https://valibot.dev/api/endsWith/

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API