Is there a way to create custom validator string syntax?
I would want to be able to extend the awesome string typechecking
1 Reply
Hey! Super cool to see other folks interested in this.
Unfortunately since the goal of ArkType's string parser is to be as optimized as possible for the syntax it parses, it doesn't allow custom operators or expressions as this would require higher kinded types and slow everything down.
To some extent Scopes do allow you to customize the parser to add custom keywords or disallow some of those that are built in (I can explain how to do the second if you're interested), but it's not the same level of control that would allow you to create new operators analogous to
|
or &
:
https://arktype.io/docs/scopes
The best thing to do would probably be to just fork the parser code and change it to the behavior you need, as it is a good template for very efficient string parsing in TS. That's essentially what I've done for the upcoming regex parser in @ark/regex