据我所知,设计只对电子邮件和密码进行验证,可以在初始化程序devise.rb中重新配置:
# ==> Configuration for :validatable
# Range for password length. Default is 6..128.
# config.password_length = 6..128
# Regex to use to validate the email address
# config.email_regexp = /\A([\w\.%\+\-]+)@([\w\-]+\.)+([\w]{2,})\z/i
如何为自定义字段添加验证,已添加到devise_invitable的邀请表单中?
例如,我需要验证表单中的first_和last_名称:
= simple_form_for resource, :as => resource_name, :url => invitation_path(resource_name) do |f|
= f.input :first_name
= f.input :last_name
= f.input :email
= f.button :submit
提前致谢!