Sha256: 3b2041db21532ebda2c05b73f2ee570f27949034eba9810e1bff7dcf8c5e34e0

Contents?: true

Size: 361 Bytes

Versions: 16

Compression:

Stored size: 361 Bytes

Contents

class PathValidator < ActiveModel::Validator
  def validate(record)
    if match?(record.path)
      record.errors[:path] << "is Reserved!"
    end
  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

16 entries across 16 versions & 1 rubygems

Version Path
landable-1.13.1 app/validators/path_validator.rb
landable-1.12.3 app/validators/path_validator.rb
landable-1.12.2 app/validators/path_validator.rb
landable-1.12.1 app/validators/path_validator.rb
landable-1.11.1 app/validators/path_validator.rb
landable-1.11.0 app/validators/path_validator.rb
landable-1.10.0.rc2 app/validators/path_validator.rb
landable-1.10.0.rc1 app/validators/path_validator.rb
landable-1.9.2 app/validators/path_validator.rb
landable-1.9.1 app/validators/path_validator.rb
landable-1.9.0 app/validators/path_validator.rb
landable-1.9.0.rc2 app/validators/path_validator.rb
landable-1.9.0.rc1 app/validators/path_validator.rb
landable-1.8.0 app/validators/path_validator.rb
landable-1.7.1.rc1 app/validators/path_validator.rb
landable-1.7.0 app/validators/path_validator.rb