You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

15 lines
475 B

module Carto
module OauthProvider
module Scopes
class ScopesValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
return record.errors[attribute] = ['has to be an array'] unless value&.is_a?(Array)
invalid_scopes = Scopes.invalid_scopes(value)
record.errors[attribute] << "contains unsupported scopes: #{invalid_scopes.join(', ')}" if invalid_scopes.any?
end
end
end
end
end