Ruby on Rails Password Validation

前端 未结 4 779
鱼传尺愫
鱼传尺愫 2020-12-29 08:16

So I have interesting password validation requirements:

  • When a user signs up, I want them to have to type in password and confirm and be between 6..4

4条回答
  •  自闭症患者
    2020-12-29 08:54

    yet another variant

    validates_presence_of :password_digest
    
    validates_length_of :password, minimum: 6, if: Proc.new { |user| user.password.present? }
    

提交回复
热议问题