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 #6432 - add validation for attributes missing :presence => true and remove duplicate validation messages 'can't be blank' #1624
Conversation
@@ -22,7 +22,8 @@ class ComputeResource < ActiveRecord::Base | |||
|
|||
before_destroy EnsureNotUsedBy.new(:hosts) | |||
has_and_belongs_to_many :users, :join_table => "user_compute_resources" | |||
validates :name, :uniqueness => true, :format => { :with => /\A(\S+)\Z/, :message => N_("can't be blank or contain white spaces.") } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add :required => true
to :name in api/v2/compute_resources_controller.rb now that it's validated?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and v1
👍 for me, it's nearly done, just misses some changes in the API docs to match the presence validators. |
@@ -22,7 +22,8 @@ class ComputeResource < ActiveRecord::Base | |||
|
|||
before_destroy EnsureNotUsedBy.new(:hosts) | |||
has_and_belongs_to_many :users, :join_table => "user_compute_resources" | |||
validates :name, :uniqueness => true, :format => { :with => /\A(\S+)\Z/, :message => N_("can't be blank or contain white spaces.") } | |||
validates :name, :presence => true, :uniqueness => true, | |||
:format => { :with => /\A(\S+)\Z/, :message => N_("can't be blank or contain white spaces.") } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you double check the behaviour of error messages in case they're duplicated? I think you may see the Rails message about presence and our message saying it can't be blank if you leave the field blank.
wait to merge. fixing more attributres |
…ce => true and remove duplicate validation messages 'can't be blank'
re-committed after removing more "can't be blank" duplicate validation messages |
Merged as 4df26ec , thanks @isratrade ! |
No description provided.