lib/percheron/validators/container.rb in percheron-0.7.1 vs lib/percheron/validators/container.rb in percheron-0.7.2
- old
+ new
@@ -6,16 +6,11 @@
@container = container
end
def valid?
message = rules.return { |rule| send(rule) }
-
- if message
- fail Errors::ContainerInvalid, formatted_message(message)
- else
- true
- end
+ message ? fail(Errors::ContainerInvalid, formatted_message(message)) : true
end
private
attr_reader :container
@@ -39,36 +34,36 @@
end
# rubocop:disable Style/GuardClause
def validate_name
if container.name.nil? || !container.name.to_s.match(/[\w]{3,}/)
- 'Container name is invalid'
+ 'Name is invalid'
end
end
def validate_dockerfile_and_image_name
if container.dockerfile.nil? && container.docker_image.nil?
- 'Container Dockerfile OR image name not provided'
+ 'Dockerfile OR image name not provided'
end
end
def validate_dockerfile
if !container.dockerfile.nil? && !File.exist?(container.dockerfile)
- 'Container Dockerfile is invalid'
+ 'Dockerfile is invalid'
end
end
def validate_image
if !container.docker_image.nil? && !container.docker_image.match(/^.+:.+$/)
- 'Container Docker image is invalid'
+ 'Docker image is invalid'
end
end
# rubocop:enable Style/GuardClause
def validate_version
container.version ? nil : fail(ArgumentError)
rescue ArgumentError
- 'Container version is invalid'
+ 'Version is invalid'
end
end
end
end