You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
educoder/app/forms/users/apply_trail_form.rb

16 lines
474 B

class Users::ApplyTrailForm
include ActiveModel::Model
attr_accessor :user, :phone, :code, :reason
validates :reason, presence: true
validates :phone, presence: true, format: { with: CustomRegexp::PHONE }, unless: -> { user.phone_binded? }
validates :code, presence: true, unless: -> { user.phone_binded? }
validate :check_user_certification
def check_user_certification
return if user.certification != 1
errors.add(:user, :already_trial)
end
end