Class: Validate::Validators::Validator

Inherits:
Object
  • Object
show all
Defined in:
lib/validate/validators/dsl.rb

Direct Known Subclasses

None

Defined Under Namespace

Classes: None

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ Validator

Returns a new instance of Validator.



23
24
25
# File 'lib/validate/validators/dsl.rb', line 23

def initialize(&block)
  @constraints = AST::DefinitionContext.create(&block)
end

Instance Method Details

#validate(ctx) ⇒ Object



27
28
29
# File 'lib/validate/validators/dsl.rb', line 27

def validate(ctx)
  @constraints.evaluate(ctx)
end