How can we describe a string with a length restriction?
e.g.:
gives the following error message:
otp must be valid otp (was 3)
I would expect the description to override the insertion of the current length. Is there a way to do this?
Similarly, is there an easy way to remove the field name from the error, for use in inline form error display?9 Replies
I do plan to implement https://github.com/arktypeio/arktype/issues/977 soon which it looks like you've seen that would let you pass
actual
inline without a narrowGitHub
Allow other error config like
expected
, actual
, problem
and `...This would allow more granular customization e.g. of a field like password to omit actual.
ah, I just found that 🙂
thank you! this is helpful
Also re: your initial expression you can also do
string == 6
for exact length constraint
I know it looks a little weird, but it makes more sense in the context of the other comparators 😛oh, I couldn't figure that out
I tried
string = 6
but that failed
iirc, min and max are in the docs, but not exact lengthYeah you're probably right I'll add that
another quick docs note: https://arktype.io/docs/expressions has a broken link.
"Narrow expressions allow you to add custom validation logic and error messages. You can read more about them in their intro section" has a link to an intro section that 404s
Thanks for letting me know. I wish the build would fail on broken links I kind of expected it to