Context-sensitive validation / validation with parameters
What is the best/easiest way to write a validator which ensures that all
bar
s are present in bars
?30 Replies
Probably a narrow? Even if we implemented the relative path comparison syntax, it would likely only be for equality checks like
password: "string", "repeatPassword: "./password"
or whatever.
This is definitely too complex for a dedicated syntax.I guess it would be possible with something like
or something
, but would like to implement it like
So the thing I'm looking for is
beforeValidate
/afterValidate
hooks to do smth like
Oh maybe you were asking for the opposite
bar
s bars
a bit confusing hahaOr even better, being able to use
context
like
That might be achievable at some point with the path syntax because it would be something like
../../bars[number]
I can't '..' because "I have no idea where the
bar
values are placed deep in the object"Maybe
/bars[number]
would be from the root of the type@ssalbdivad what is the most straightforward way to
(i.e. ordered validation)
Oror something
Unknown User•14mo ago
Message Not Public
Sign In & Join Server To View
What is the goal here? There's actually this related question I've been thinking about regarding preserving ordering through intersections of narrows.
In general, narrows will run sequentially in the order they're defined, but they're not like morphs where the order itself is part of the type.
// as long as the narrows in l and r are individually safe to check // in the order they're specified, checking them in the order // resulting from this intersection should also be safe.
can you return Out from narrow, again?
No? Narrow is a constraint, not a morph
If you mean can it be a type guard then yes, you use
is
like you normally would in TSerm I dunno what I wrote
Couldn't you just use a morph?
...I wrote not the thing I did want I guess
I'm not sure, I huess I can