Module: RedTape
- Extended by:
- Support
- Defined in:
- lib/red_tape.rb,
lib/red_tape/errors.rb,
lib/red_tape/support.rb,
lib/red_tape/version.rb,
lib/red_tape/validator.rb,
lib/red_tape/validators/de.rb
Defined Under Namespace
Modules: Support, Validators
Classes: Error, ValidationError, Validator
Constant Summary
collapse
- COUNTRIES =
%w[BE BG DK DE EE FI FR EL GB IE IT LV LT LU MT NL AT PL PT RO SE SK SL ES CZ HU CY]
- VERSION =
'2.0.0'
Class Method Summary
collapse
Class Method Details
.valid?(own, other, options = {}) ⇒ Boolean
30
31
32
|
# File 'lib/red_tape.rb', line 30
def valid?(own, other, options = {})
validator(own, other, options)&.valid?
end
|
.validatable?(own, other) ⇒ Boolean
20
21
22
|
# File 'lib/red_tape.rb', line 20
def validatable?(own, other)
!!(COUNTRIES.include?(country(other)) && validator_for(country(own)))
end
|
.validator(own, other, options = {}) ⇒ Object
24
25
26
27
28
|
# File 'lib/red_tape.rb', line 24
def validator(own, other, options = {})
if klass = validator_for(country(own))
klass.new(own, other, options)
end
end
|
.validator_for(country) ⇒ Object
16
17
18
|
# File 'lib/red_tape.rb', line 16
def validator_for(country)
Validators.const_get(country.to_sym) if Validators.constants.include?(country.to_sym)
end
|