-
-
Notifications
You must be signed in to change notification settings - Fork 30
Open
Labels
Type: EnhancementImproving an existing featureImproving an existing feature
Description
Hello,
I’d like to request template-literal support in Vine for narrow string validations, maybe something like this:
import { vine } from "vine";
const literalValidator = vine
.string()
.literal(`${vine.number()}.foo.${vine.string().toLowerCase()}`);
const result = await request.validateUsing(literalValidator);
// typeof result === `${number}.foo.${Lowercase<string>}`Zod does not quite solve this either, but has a handy:
const literal = z.custom<`${number}.${number}.${number}`>((val) =>
/^\d+\.\d+\.\d+$/g.test(val as string)
);This issue on Zod describes how they do it currently:
colinhacks/zod#419
Metadata
Metadata
Assignees
Labels
Type: EnhancementImproving an existing featureImproving an existing feature