Sha256: a6dd9b0cc54653473187753c9f70ca103ac9fd42d250e7b99ff3cb012c13bdeb
Contents?: true
Size: 985 Bytes
Versions: 250
Compression:
Stored size: 985 Bytes
Contents
module Katello module Validators class KatelloLabelFormatValidator < ActiveModel::EachValidator def validate_each(record, attribute, value) if value record.errors[attribute] << N_("cannot contain characters other than ascii alpha numerals, '_', '-'. ") unless value =~ /\A[a-zA-Z0-9_\-]+\z/ NoTrailingSpaceValidator.validate_trailing_space(record, attribute, value) KatelloLabelFormatValidator.validate_length(record, attribute, value) else record.errors[attribute] << N_("can't be blank") end end def self.validate_length(record, attribute, value, max_length = 128, min_length = 1) if value record.errors[attribute] << N_("cannot contain more than %s characters") % max_length unless value.length <= max_length record.errors[attribute] << N_("must contain at least %s character") % min_length unless value.length >= min_length end end end end end
Version data entries
250 entries across 250 versions & 1 rubygems