refactor: sizesSchema

This commit is contained in:
P. Reis 2024-11-03 20:27:52 -03:00
parent c411a871ef
commit 34d604dded

View file

@ -66,7 +66,9 @@ const localeSchema = z.string().transform<Intl.Locale>((val, ctx) => {
});
/** White-space separated list of sizes, each in the format <number with up to 4 digits>x<number with up to 4 digits> or with "X" in upper case. */
const sizesSchema = z.string().regex(/^(?:[1-9]\d{0,3}[xX][1-9]\d{0,3})(?:\s+[1-9]\d{0,3}[xX][1-9]\d{0,3})*$/);
const sizesSchema = z.string().refine((value) =>
value.split(' ').every((v) => /^[1-9]\d{0,3}[xX][1-9]\d{0,3}$/.test(v))
);
export {
booleanParamSchema,