13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'app/models/validators/app_validator.rb', line 13
def validate_name(record, attribute, val)
if val.nil?
record.errors.add(attribute, {:message => "Name is required and cannot be blank.", :exit_code => 105})
end
if !(val =~ /\A[A-Za-z0-9]+\z/)
record.errors.add(attribute, {:message => "Invalid name. Name must only contain alphanumeric characters.", :exit_code => 105})
end
if val and val.length > APP_NAME_MAX_LENGTH
record.errors.add(attribute, {:message => "Name is too long. Maximum length is #{APP_NAME_MAX_LENGTH} characters.", :exit_code => 105})
end
if val and val.length < APP_NAME_MIN_LENGTH
record.errors.add(attribute, {:message => "Name is too short. Minimum length is #{APP_NAME_MIN_LENGTH} characters.", :exit_code => 105})
end
if val and OpenShift::ApplicationContainerProxy.blacklisted? val
record.errors.add(attribute, {:message => "Name is not allowed. Please choose another.", :exit_code => 105})
end
end
|