You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
at the moment Response object uses an Array (initialized here) to keep track of errors encountered during validation.
at the moment, it's very human-friendly – i.e. if you wanted to display errors to users, you could just consume errors in your controller after is_valid? check and be done. however, i think it would be better for programmatically traversing errors and making sense of them if errors was a Hash.
easiest pattern i can think of is to leverage the suffix for each validate_XXX method. e.g.
defvalidate_num_assertion# validation fails...append_error(:num_assertion,"SAML Response must contain 1 assertion")enddefvalidate_destination# validation fails...append_error(:destination,"The response was received at #{destination} instead of #{settings.assertion_consumer_service_url}")end
obviously, this would be a breaking change; but, i think errors could be declared as deprecated and a Hash named errors_hash could be defined as a start to allow people upgrade easily. until deprecated error arrays is completely removed, errors and errors_hash could work side-by-side.
repo owners, i would appreciate if you could let me know if this makes sense. if it does, i am open to taking a first stab at it with a pull request.
The text was updated successfully, but these errors were encountered:
@alperkokmen (or anyone else), I think the right way to do this would be to make a global config option that toggles between the old way and the new way. PR would be welcome here.
at the moment
Response
object uses anArray
(initialized here) to keep track of errors encountered during validation.at the moment, it's very human-friendly – i.e. if you wanted to display errors to users, you could just consume
errors
in your controller afteris_valid?
check and be done. however, i think it would be better for programmatically traversing errors and making sense of them iferrors
was aHash
.easiest pattern i can think of is to leverage the suffix for each
validate_XXX
method. e.g.obviously, this would be a breaking change; but, i think
errors
could be declared as deprecated and aHash
namederrors_hash
could be defined as a start to allow people upgrade easily. until deprecatederror
arrays is completely removed,errors
anderrors_hash
could work side-by-side.repo owners, i would appreciate if you could let me know if this makes sense. if it does, i am open to taking a first stab at it with a pull request.
The text was updated successfully, but these errors were encountered: