Sha256: da6113523f75bc62dbca076304b4ae8624321eb179117f8046f0856b1c26c92b

Contents?: true

Size: 347 Bytes

Versions: 2

Compression:

Stored size: 347 Bytes

Contents

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

  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
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
landable-1.14.0 app/validators/path_validator.rb
landable-1.13.2 app/validators/path_validator.rb