Sha256: f2767e1bb70cb1026ba50ef6cef96716befd83e266db58e2aa45fe07588ab732

Contents?: true

Size: 319 Bytes

Versions: 50

Compression:

Stored size: 319 Bytes

Contents

# frozen_string_literal: true

module Ree::Contracts
  class RegexpValidator < BaseValidator
    def call(value)
      value =~ contract
    end

    def to_s
      contract.to_s
    end

    def message(value, name, lvl = 1)
      "expected to match #{contract.to_s}, got #{truncate(value.inspect)}"
    end
  end
end

Version data entries

50 entries across 50 versions & 1 rubygems

Version Path
ree-1.1.1 lib/ree/contracts/validators/regexp_validator.rb
ree-1.1.0 lib/ree/contracts/validators/regexp_validator.rb
ree-1.0.47 lib/ree/contracts/validators/regexp_validator.rb
ree-1.0.46 lib/ree/contracts/validators/regexp_validator.rb
ree-1.0.45 lib/ree/contracts/validators/regexp_validator.rb
ree-1.0.44 lib/ree/contracts/validators/regexp_validator.rb
ree-1.0.43 lib/ree/contracts/validators/regexp_validator.rb
ree-1.0.42 lib/ree/contracts/validators/regexp_validator.rb
ree-1.0.41 lib/ree/contracts/validators/regexp_validator.rb
ree-1.0.40 lib/ree/contracts/validators/regexp_validator.rb
ree-1.0.39 lib/ree/contracts/validators/regexp_validator.rb
ree-1.0.38 lib/ree/contracts/validators/regexp_validator.rb
ree-1.0.37 lib/ree/contracts/validators/regexp_validator.rb
ree-1.0.36 lib/ree/contracts/validators/regexp_validator.rb
ree-1.0.35 lib/ree/contracts/validators/regexp_validator.rb
ree-1.0.34 lib/ree/contracts/validators/regexp_validator.rb
ree-1.0.33 lib/ree/contracts/validators/regexp_validator.rb
ree-1.0.32 lib/ree/contracts/validators/regexp_validator.rb
ree-1.0.31 lib/ree/contracts/validators/regexp_validator.rb
ree-1.0.30 lib/ree/contracts/validators/regexp_validator.rb