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

Improve constraint violation parameter output #200

Open
Blacksmoke16 opened this issue Sep 9, 2022 · 0 comments
Open

Improve constraint violation parameter output #200

Blacksmoke16 opened this issue Sep 9, 2022 · 0 comments
Labels
component:validator good first issue kind:enhancement New functionality to an existing feature

Comments

@Blacksmoke16
Copy link
Member

Non-scalar parameters are currently simply converted to strings via their default #to_s method. This leaves for less than ideal outputs in some cases depending on what the value is. E.g.

constraint = AVD::Constraints::Choice.new(
  ["one", "two", "three"],
  message: "{{ value}} is not one of {{ choices }}."
)

puts AVD.validator.validate "four", constraint
# four:
#     {{ value}} is not one of ["one", "two", "three"]. (code: c7398ea5-e787-4ee9-9fca-5f2c130614d6)

It might not be a bad idea to have a bit more robust/predictable output for these parameters. Can maybe reference https://github.com/symfony/validator/blob/6.2/ConstraintValidator.php#L76-L145.

@Blacksmoke16 Blacksmoke16 added component:validator good first issue kind:enhancement New functionality to an existing feature labels Sep 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:validator good first issue kind:enhancement New functionality to an existing feature
Development

No branches or pull requests

1 participant