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

How to handle when the starting field value is present and an invalid param is sent #83

Open
paulcsmith opened this issue Apr 26, 2019 · 1 comment
Labels
clarify api Rename/remove/add something to make the API easier to understand discussion

Comments

@paulcsmith
Copy link
Member

Let's say you have an age : Int32 field.

You have a record with age as 32. You then fill out an HTML form and set age to thirty two. Avram will correctly say that this is invalid. The problem is that because it is invalid age.value will be the old value 32. I wonder what we should do? Is this correct behavior? We can't set it to "thirty two" because it is the wrong type. Maybe it should be nil? Or maybe this is just a weird edge case where there is no "correct" way to handle it

@jwoertink jwoertink added clarify api Rename/remove/add something to make the API easier to understand discussion labels Jul 26, 2019
@jwoertink
Copy link
Member

It should be set to nil, but attributes also have an original_value method. We could maybe set that just as an escape hatch deal..

attribute age : Int32
{"age" => "thirty two"}
age.value #=> nil
age.original_value #=> "thirty two"
operation.errors[:age] #=> ["wrong type or whatever"]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clarify api Rename/remove/add something to make the API easier to understand discussion
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants