Class: Katello::Validators::ContainerImageNameValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- Katello::Validators::ContainerImageNameValidator
- Defined in:
- app/lib/katello/validators/container_image_name_validator.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.validate_name(name) ⇒ Object
10 11 12 13 14 15 16 |
# File 'app/lib/katello/validators/container_image_name_validator.rb', line 10 def self.validate_name(name) # regexp-source: https://specs.opencontainers.org/distribution-spec/?v=v1.0.0#DISTRIBUTION-SPEC-26 if name.empty? || name.length > 255 || !/\A[a-z0-9]+([\-_.][a-z0-9]+)*(\/[a-z0-9]+([\-_.][a-z0-9]+)*)*\z/.match?(name) return false end true end |
Instance Method Details
#validate_each(record, attribute, value) ⇒ Object
4 5 6 7 8 |
# File 'app/lib/katello/validators/container_image_name_validator.rb', line 4 def validate_each(record, attribute, value) if value && !ContainerImageNameValidator.validate_name(value) record.errors.add(attribute, N_("The generated container repository name is invalid. Please review the lifecycle environment's registry name pattern. It may be caused by special characters in the components that make up the name, like the organization.")) end end |