anispwyn
anispwyn
Aarktype
Created by anispwyn on 4/26/2025 in #questions
customize errors
i am quite new to this library and knowing that arktype support regexp validation, i am surprised, but now my question is how do i even explain this regexp to the user? i know that i can do
import {type} from "arktype";
const regexp1 = type("[a-z]").configure({
problem: ctx => `${ctx.actual} does not match ${ctx.expected}`
});
import {type} from "arktype";
const regexp1 = type("[a-z]").configure({
problem: ctx => `${ctx.actual} does not match ${ctx.expected}`
});
but that doesnt explain much to the user that has no regexp experience, is there a way to return a more reasonable errors? like for example the regexp: "/^\\s*[a-zA-Z0-9_]{3,16}\\s*$/" when the user put less than 3 characters in the username field then return the username must be atleast 3 character thanks in advance
7 replies