startsWith
Creates a starts with validation action.
const Action = v.startsWith<TInput, TRequirement, TMessage>(
requirement,
message
);
Generics
TInputextends stringTRequirementextends stringTMessageextends ErrorMessage<StartsWithIssue<TInput, TRequirement>> | undefined
Parameters
requirementTRequirementmessageTMessage
Explanation
With startsWith you can validate the start of a string. If the start does not match the requirement, you can use message to customize the error message.
Returns
ActionStartsWithAction<TInput, TRequirement, TMessage>
Examples
The following examples show how startsWith can be used.
HTTPS URL schema
Schema to validate a HTTPS URL.
const HttpsUrlSchema = v.pipe(v.string(), v.url(), v.startsWith('https://'));
Related
The following APIs can be combined with startsWith.
Schemas
Methods
Utils
© Fabian Hiller
Licensed under the MIT License.
https://valibot.dev/api/startsWith/