mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-12-20 12:32:39 -05:00
12 lines
368 B
Ruby
12 lines
368 B
Ruby
class PasswordValidator < ActiveModel::EachValidator
|
|
|
|
def validate_each(record, attribute, value)
|
|
return unless record.password_required?
|
|
if value.nil?
|
|
record.errors.add(attribute, :blank)
|
|
elsif value.length < SiteSetting.min_password_length
|
|
record.errors.add(attribute, :too_short, count: SiteSetting.min_password_length)
|
|
end
|
|
end
|
|
|
|
end
|