Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for iron derivation for GreaterEqual, LessEqual, In #3790

Merged
merged 4 commits into from
May 28, 2024

Conversation

kciesielski
Copy link
Member

@kciesielski kciesielski commented May 27, 2024

These fixes should address issues reported here: https://softwaremill.community/t/how-to-improve-open-api-documentation-for-iron-refined-types/396/9

  1. LessEqual and GreaterEqual validators aren't resolved correctly if these predicates are combined with other predicates using Or or And. They would be handled by validatorForDescribedOr, so I added variants called validatorForDescribedOrGe and validatorForDescribedOrLe witch additional "witnesses" like isGe: P =:= GreaterEqual[Num] to redirect back to validatorForGreaterEqual and validatorForLessEqual.

  2. Constraint In[(1, 2, 3)] was handled as a standard union type constraint, resulting in a list of validators, where each validator was a Validator.enumeration(List(int)) with a single value in the list. I have added some tweaks to fix this:

  • constrains like In[(a, b, c, d)] are now represented as a single Validator.enumeration(List(a, b, c, d))
  • raw strict equals in unions are handled as well, so constraint like StrictEquals[1] | StrictEquals[2] will also produce a single enumeration
  • Mixed unions of StrictEquals and other constrains are also supported, as long as StrictEquals are the first constrains in the union, for example: StrictEquals[3] | StrictEquals[4] | GreaterEqual[23] will give a Validator.Enumeration(List(3, 4), _, _), Validator.Min(23, false))

@kciesielski kciesielski marked this pull request as ready for review May 28, 2024 11:19
@kciesielski kciesielski requested a review from adamw May 28, 2024 11:19
@adamw adamw merged commit 1033160 into master May 28, 2024
26 checks passed
@adamw adamw deleted the fix-iron-le-ge-enum branch May 28, 2024 11:24
@adamw
Copy link
Member

adamw commented May 28, 2024

Nice! :) Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants