-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
Is your feature request related to a problem? Please describe.
To give some background, we are working on an exporter à la Typegen to export FV schemas to Yup schemas, works a treat on basics schemas but I'm facing issues with when conditional rules are used.
The two problems I have are:
WhenusesFunc<T, bool>for the predicate, which makes it basically impossible to translate to javascriptIRuleComponentonly exposesHasConditionwhich doesn't allow identification of the condition
The func issue I can work around by making a custom abstract validation that's exposes a When with an Expression and caching the expression. That custom When is called over the one with the Func parameter so it's transparent for the rest of the team
For the second issue I've had to resort to reflection shenanigans by getting the internal Rules on the validator and invoking OnItemAdded on it, in my custom When, and caching the added rules with the Expression, lots of fun but not very sustainable
Describe the solution you'd like
Not entirely sure to be honest
- Replacing the type for conditions from
FunctoExpression<Funcand exposing the condition inIRuleComponent, would be the 'logical' solution but I realize this would be huge undertaking mostly because the condition on the RuleComponents is not the Func that was passed originally - Alternatively exposing a public version of
OnItemAdded(OnRuleAdded perhaps ?) onAbstractValidatorwould help a ton, don't know what use it would be beside helping in my particular case though - Alternatively alternatively, changing only the type of the predicate parameter on
WhentoExpressioncompiling it to the use the existing internal logic but passing the originalExpressiondown to theRuleComponentsand exposing it
Describe alternatives you've considered
No response
Additional Context
No response