2016-06-17 06:06:48 -04:00
|
|
|
module Gitlab
|
|
|
|
module Ci
|
|
|
|
class Config
|
|
|
|
module Node
|
|
|
|
module Validators
|
|
|
|
class ArrayOfStringsValidator < ActiveModel::EachValidator
|
|
|
|
include LegacyValidationHelpers
|
|
|
|
|
|
|
|
def validate_each(record, attribute, value)
|
|
|
|
unless validate_array_of_strings(value)
|
|
|
|
record.errors.add(attribute, 'should be an array of strings')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2016-06-17 08:51:39 -04:00
|
|
|
|
2016-06-21 05:43:32 -04:00
|
|
|
class TypeValidator < ActiveModel::EachValidator
|
2016-06-17 08:51:39 -04:00
|
|
|
def validate_each(record, attribute, value)
|
2016-06-21 05:43:32 -04:00
|
|
|
type = options[:with]
|
|
|
|
raise unless type.is_a?(Class)
|
|
|
|
|
|
|
|
unless value.is_a?(type)
|
|
|
|
record.errors.add(attribute, "should be a #{type.name}")
|
2016-06-17 08:51:39 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2016-06-17 06:06:48 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|