New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The email validations (uniqueness and regexp) is not working with client_side_validations #4574
Comments
Hi, For the regex or format problem, It is an issue in client side validation gem. It returns true if the validation condition contains But it looks like now Devise using new Rails 5 syntax in validatable module it checks for the email validation using So to fix the problem now you can add file in your initializers folder # frozen_string_literal: true
require 'client_side_validations/core_ext'
require 'client_side_validations/extender'
require 'client_side_validations/active_model/conditionals'
module ClientSideValidations
module ActiveModel
module Validations
include ClientSideValidations::ActiveModel::Conditionals
def check_conditionals(attr, validator, force)
return true if validator.options[:if] && (validator.options[:if] =~ /changed\?/ || validator.options[:if] =~ /\Awill_save_change_to/)
result = can_force_validator?(attr, validator, force)
if validator.options[:if]
result &&= run_conditionals(validator.options[:if], :if)
end
if validator.options[:unless]
result &&= run_conditionals(validator.options[:unless], :unless)
end
result
end
end
end
end And I am currently working in a PR to fix this issue in client_side_validation gem. |
This commit reflects changes in ActiveRecord::Dirty API version 5.1 Ref: #710, heartcombo/devise#4574, rails/rails#25337
I'm closing this because it seems like it was fixed in the Thanks |
This commit reflects changes in ActiveRecord::Dirty API version 5.1 Ref: #710, heartcombo/devise#4574, rails/rails#25337
This commit reflects changes in ActiveRecord::Dirty API version 5.1 Ref: #710, heartcombo/devise#4574, rails/rails#25337
This commit reflects changes in ActiveRecord::Dirty API version 5.1 Ref: #710, heartcombo/devise#4574, rails/rails#25337
This commit reflects changes in ActiveRecord::Dirty API version 5.1 Ref: #710, heartcombo/devise#4574, rails/rails#25337
Version of Devise: 4.3.0
Version of ClientSideValidations: 9.3.3
Version of Rails: 5.1.1
User model:
The template form code:
Result:
On blurring the email's input field, an error only shown if it is empty but if it already existed or if it has invalid format, no error is shown. I need the client_side_validations to be shown for all cases of the email errors, any help please??
The text was updated successfully, but these errors were encountered: