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 #6432 - add validation for attributes missing :presence => true and remove duplicate validation messages 'can't be blank' #1624

Closed
wants to merge 1 commit into from

Conversation

isratrade
Copy link
Member

No description provided.

@isratrade
Copy link
Member Author

This commit was previously part of PR #1512, but it will likely be merged quickly if it's separate.

This commit is needed to show * indicating a required field when PR #1623 is merged.

@@ -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.") }
Copy link
Member

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?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and v1

@dLobatog
Copy link
Member

👍 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.") }
Copy link
Contributor

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.

@isratrade
Copy link
Member Author

@elobato, @domcleal, fixed per comments and re-committed.

@isratrade
Copy link
Member Author

wait to merge. fixing more attributres

…ce => true and remove duplicate validation messages 'can't be blank'
@isratrade
Copy link
Member Author

re-committed after removing more "can't be blank" duplicate validation messages

@isratrade isratrade changed the title fixes #6432 - attributes missing :presence => true fixes #6432 - add validation for attributes missing :presence => true and remove duplicate validation messages 'can't be blank' Jul 29, 2014
@dLobatog
Copy link
Member

Merged as 4df26ec , thanks @isratrade !

@dLobatog dLobatog closed this Jul 30, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants