giovaZ
giovaZ

Reputation: 1470

AngularJS and Rails live validation

In my Ruby on Rails application i've set up a user registration / login system that have some validations in the class ( for register a User).

 class User < ActiveRecord::Base
  # Put the email downcase before save the User
  before_save {self.email = email.downcase}

  # Confirmation of the password before save
  validates_confirmation_of :password
  has_secure_password

  validates :first_name, :last_name,
            presence: true,
            format:{ without: /\s/ }

  validates :email, uniqueness: true,
            format:{
                with: /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
            }
  def to_s
    "#{first_name} #{last_name}"
  end

end

In this application i also use AngularJS and the question is, can i use AngularJS for the live validation of the user during the registration?

Upvotes: 0

Views: 34

Answers (1)

Olivier
Olivier

Reputation: 696

If you want to validate live your fields you'll have to use AngularJS validators. Those ruby validators will be called when you'll submit the form.

Upvotes: 1

Related Questions