Module: Compel

Extended by:
Builder::Methods
Defined in:
lib/compel/validators/hash_validator.rb,
lib/compel.rb,
lib/compel/errors.rb,
lib/compel/result.rb,
lib/compel/version.rb,
lib/compel/contract.rb,
lib/compel/builder/any.rb,
lib/compel/builder/date.rb,
lib/compel/builder/hash.rb,
lib/compel/builder/json.rb,
lib/compel/builder/time.rb,
lib/compel/builder/array.rb,
lib/compel/builder/float.rb,
lib/compel/builder/common.rb,
lib/compel/builder/schema.rb,
lib/compel/builder/string.rb,
lib/compel/builder/boolean.rb,
lib/compel/builder/integer.rb,
lib/compel/builder/methods.rb,
lib/compel/coercion/result.rb,
lib/compel/validators/base.rb,
lib/compel/builder/datetime.rb,
lib/compel/coercion/coercion.rb,
lib/compel/validation/result.rb,
lib/compel/coercion/types/any.rb,
lib/compel/coercion/nil_result.rb,
lib/compel/coercion/types/date.rb,
lib/compel/coercion/types/hash.rb,
lib/compel/coercion/types/json.rb,
lib/compel/coercion/types/time.rb,
lib/compel/coercion/types/type.rb,
lib/compel/builder/common_value.rb,
lib/compel/coercion/types/array.rb,
lib/compel/coercion/types/float.rb,
lib/compel/coercion/types/regexp.rb,
lib/compel/coercion/types/string.rb,
lib/compel/exceptions/type_error.rb,
lib/compel/validation/validation.rb,
lib/compel/coercion/types/boolean.rb,
lib/compel/coercion/types/integer.rb,
lib/compel/coercion/types/datetime.rb,
lib/compel/coercion/types/date_type.rb,
lib/compel/validation/conditions/if.rb,
lib/compel/validation/conditions/in.rb,
lib/compel/validation/conditions/is.rb,
lib/compel/validation/conditions/max.rb,
lib/compel/validation/conditions/min.rb,
lib/compel/validators/type_validator.rb,
lib/compel/validators/array_validator.rb,
lib/compel/validation/conditions/format.rb,
lib/compel/validation/conditions/length.rb,
lib/compel/exceptions/invalid_object_error.rb,
lib/compel/validation/conditions/condition.rb,
lib/compel/validation/conditions/max_length.rb,
lib/compel/validation/conditions/min_length.rb

Overview

Validates a type, given an input, type and options output is a coerced value error is an array of strings

Defined Under Namespace

Modules: Builder, Coercion, Validation, Validators Classes: Contract, Errors, InvalidObjectError, Result, TypeError

Constant Summary collapse

VERSION =
'0.5.1'

Class Method Summary collapse

Methods included from Builder::Methods

any, array, boolean, date, datetime, float, hash, integer, json, string, time

Class Method Details

.run(params, schema) ⇒ Object



27
28
29
# File 'lib/compel.rb', line 27

def self.run(params, schema)
  Contract.new(params, schema).validate
end

.run!(params, schema) ⇒ Object



19
20
21
# File 'lib/compel.rb', line 19

def self.run!(params, schema)
  Contract.new(params, schema).validate.raise?
end

.run?(params, schema) ⇒ Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/compel.rb', line 23

def self.run?(params, schema)
  Contract.new(params, schema).validate.valid?
end