Class: Ree::Contracts::RegexpValidator

Inherits:
BaseValidator show all
Defined in:
lib/ree/contracts/validators/regexp_validator.rb

Instance Attribute Summary

Attributes inherited from BaseValidator

#contract

Instance Method Summary collapse

Methods inherited from BaseValidator

#initialize

Methods included from Truncatable

#truncate

Constructor Details

This class inherits a constructor from Ree::Contracts::BaseValidator

Instance Method Details

#call(value) ⇒ Object



5
6
7
# File 'lib/ree/contracts/validators/regexp_validator.rb', line 5

def call(value)
  value =~ contract
end

#message(value, name, lvl = 1) ⇒ Object



13
14
15
# File 'lib/ree/contracts/validators/regexp_validator.rb', line 13

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

#to_sObject



9
10
11
# File 'lib/ree/contracts/validators/regexp_validator.rb', line 9

def to_s
  contract.to_s
end