Module: Validate
- Defined in:
- lib/validate.rb,
lib/validate/ast.rb,
lib/validate/scope.rb,
lib/validate/errors.rb,
lib/validate/compare.rb,
lib/validate/helpers.rb,
lib/validate/version.rb,
lib/validate/arguments.rb,
lib/validate/assertions.rb,
lib/validate/constraint.rb,
lib/validate/validators.rb,
lib/validate/constraints.rb,
lib/validate/validators/dsl.rb,
lib/validate/constraints/validation_context.rb
Overview
typed: strict frozen_string_literal: true
Defined Under Namespace
Modules: AST, Arguments, Assertions, ClassMethods, Compare, Constraints, Error, Helpers, Validators Classes: Constraint, Scope
Constant Summary collapse
- VERSION =
'1.1.0'
Class Method Summary collapse
-
.included(base) ⇒ Object
Hook to allow for inclusion in class or module.
-
.validate(object, as: object.class) ⇒ Array<Constraint::Violation>
Validate an object and get constraint violations list back.
-
.validator?(name) ⇒ Boolean
Check if a given validator exists.
Class Method Details
.included(base) ⇒ Object
Hook to allow for inclusion in class or module
71 72 73 |
# File 'lib/validate.rb', line 71 def self.included(base) base.extend(ClassMethods) end |
.validate(object, as: object.class) ⇒ Array<Constraint::Violation>
Validate an object and get constraint violations list back
53 54 55 56 57 58 59 |
# File 'lib/validate.rb', line 53 def self.validate(object, as: object.class) violations = [] Scope.current .validator(as) .validate(Constraints::ValidationContext.root(object, violations)) violations.freeze end |