cartodb-4.29/lib/carto/password_validator.rb
2020-06-15 10:58:47 +08:00

25 lines
583 B
Ruby

require_dependency 'carto/standard_password_strategy'
module Carto
class PasswordValidator
def initialize(strategy = Carto::StandardPasswordStrategy.new)
@strategy = strategy
end
def validate(password, password_confirmation, user = nil)
@strategy.validate(password, password_confirmation, user)
end
def formatted_error_message(errors)
return nil if errors.empty?
return errors.first if errors.size == 1
message = errors.first(errors.size - 1).join(', ')
message << " and #{errors.last}"
message
end
end
end