Reputation: 535
i would like to forbid "/" from a field.
I read in the doc that it should be something like that:
valid_name_regex = /
validates :name, presence: true, uniqueness: { case_sensitive: true }, format: { with: valid_name_regex }
But i'd like the opposite.
thanks
Upvotes: 0
Views: 141
Reputation: 12818
Try something like
validates :name, presence: true, uniqueness: { case_sensitive: true }, format: { with: /^[^\/]+$/ }
Upvotes: 4