Class: Katello::Validators::KatelloNameFormatValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- Katello::Validators::KatelloNameFormatValidator
- Defined in:
- app/lib/katello/validators/katello_name_format_validator.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.validate_length(record, attribute, value, min_length = 1) ⇒ Object
15 16 17 18 19 |
# File 'app/lib/katello/validators/katello_name_format_validator.rb', line 15 def self.validate_length(record, attribute, value, min_length = 1) if value record.errors[attribute] << _("must contain at least %s character") % min_length unless value.length >= min_length end end |
Instance Method Details
#validate_each(record, attribute, value) ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'app/lib/katello/validators/katello_name_format_validator.rb', line 6 def validate_each(record, attribute, value) if value NoTrailingSpaceValidator.validate_trailing_space(record, attribute, value) KatelloNameFormatValidator.validate_length(record, attribute, value) else record.errors[attribute] << N_("cannot be blank") end end |