0

我想禁止字段中的“/”。

我在文档中读到它应该是这样的:

valid_name_regex = /
验证:name,存在:true,唯一性:{ case_sensitive: true },格式:{ with:valid_name_regex }

但我想要相反的。

谢谢

4

1 回答 1

4

尝试类似的东西

validates :name, presence: true, uniqueness: { case_sensitive: true }, format: { with: /^[^\/]+$/ }
于 2012-08-03T10:22:44.600 回答