Class: PathValidator

Inherits:
ActiveModel::Validator
  • Object
show all
Defined in:
app/validators/path_validator.rb

Instance Method Summary collapse

Instance Method Details

#match?(path) ⇒ Boolean

Returns:

  • (Boolean)


6
7
8
9
# File 'app/validators/path_validator.rb', line 6

def match?(path)
  # See if the applying path matches any reserved_paths via a Regex
  Landable.configuration.reserved_paths.any? { |reserved| Regexp.new("^#{reserved}$", 'i').match(path) }
end

#validate(record) ⇒ Object



2
3
4
# File 'app/validators/path_validator.rb', line 2

def validate(record)
  record.errors[:path] << 'is Reserved!' if match?(record.path)
end