Class: Tuning::Validations::ComplexityValidator

Inherits:
ActiveModel::EachValidator
  • Object
show all
Defined in:
lib/tuning/validations/complexity.rb

Instance Method Summary collapse

Instance Method Details

#validate_each(record, attribute, value) ⇒ Object



7
8
9
10
11
# File 'lib/tuning/validations/complexity.rb', line 7

def validate_each(record, attribute, value)
  if value !~ /\A(?=.*[a-z])(?=.*[A-Z])(?=.*[\d])(?=.*[\W\_]).{8,}*\z/
    record.errors.add attribute, :too_easy
  end
end