Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Easier identification/exposition of When conditions #2114

Copy link
Copy link
@Zxenop

Description

@Zxenop
Issue body actions

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:

  • When uses Func<T, bool> for the predicate, which makes it basically impossible to translate to javascript
  • IRuleComponent only exposes HasCondition which 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 Func to Expression<Func and exposing the condition in IRuleComponent, 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 ?) on AbstractValidator would 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 When to Expression compiling it to the use the existing internal logic but passing the original Expression down to the RuleComponents and exposing it

Describe alternatives you've considered

No response

Additional Context

No response

PhenX and fanta759

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.