Early codependent field validation
I’m making a signup form following the example here https://arktype.io/docs/expressions#narrow
If you add another field, e.g. email, the narrow doesn’t run until email is valid.
After reading other posts, I believe this is intended behavior. So then I went to try and add the .narrow into confirmPassword, but the type of
ctx.root
ends up being unknown, since we’re still validating the type, which makes sense.
Since it’s unknown, this means having to do some really gross checks and type coercions to correctly check that password and confirmPassword don’t match. Wondering if there’s anything better I can do here.1 Reply
Was hoping I could do something like this:
This works but not really ideal, especially in the case of a more complex schema
This is the aforementioned solution of narrowing directly on the dependent field. Probably the best solution I’ve got, though not ideal due to root being unknown and having to validate it myself.