blob: 92041e0a7730139e9c914dd17df66d8ca49c961c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
|
class GitEnvironmentVariablesValidator < ActiveModel::EachValidator
def validate_each(record, attribute, env)
variables_to_validate = %w(GIT_OBJECT_DIRECTORY GIT_ALTERNATE_OBJECT_DIRECTORIES)
variables_to_validate.each do |variable_name|
variable_value = env[variable_name]
if variable_value.present? && !(variable_value =~ /^#{record.project.repository.path_to_repo}/)
record.errors.add(attribute, "The #{variable_name} variable must start with the project repo path")
end
end
end
end
|