veto 0.1.3 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (104) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +7 -94
  3. data/lib/veto/blocks/block.rb +25 -0
  4. data/lib/veto/blocks/checker.rb +28 -0
  5. data/lib/veto/blocks/conditional_block.rb +26 -0
  6. data/lib/veto/blocks/validate_block.rb +18 -0
  7. data/lib/veto/blocks/validates_block.rb +51 -0
  8. data/lib/veto/blocks/with_options_block.rb +7 -0
  9. data/lib/veto/check_context_object.rb +10 -0
  10. data/lib/veto/checks/attribute_check.rb +19 -0
  11. data/lib/veto/checks/check.rb +7 -0
  12. data/lib/veto/checks/check_factory.rb +18 -0
  13. data/lib/veto/{validators/exact_length_validator.rb → checks/exact_length_check.rb} +5 -4
  14. data/lib/veto/{validators/format_validator.rb → checks/format_check.rb} +5 -4
  15. data/lib/veto/{validators/greater_than_validator.rb → checks/greater_than_check.rb} +2 -4
  16. data/lib/veto/{validators/greater_than_or_equal_to_validator.rb → checks/greater_than_or_equal_to_check.rb} +2 -4
  17. data/lib/veto/{validators/inclusion_validator.rb → checks/inclusion_check.rb} +2 -4
  18. data/lib/veto/{validators/integer_validator.rb → checks/integer_check.rb} +2 -4
  19. data/lib/veto/{validators/length_range_validator.rb → checks/length_range_check.rb} +2 -4
  20. data/lib/veto/{validators/less_than_validator.rb → checks/less_than_check.rb} +2 -4
  21. data/lib/veto/{validators/less_than_or_equal_to_validator.rb → checks/less_than_or_equal_to_check.rb} +2 -4
  22. data/lib/veto/{validators/max_length_validator.rb → checks/max_length_check.rb} +2 -4
  23. data/lib/veto/checks/method_check.rb +17 -0
  24. data/lib/veto/{validators/min_length_validator.rb → checks/min_length_check.rb} +2 -4
  25. data/lib/veto/{validators/not_null_validator.rb → checks/not_null_check.rb} +2 -4
  26. data/lib/veto/{validators/numeric_validator.rb → checks/numeric_check.rb} +2 -4
  27. data/lib/veto/{validators/presence_validator.rb → checks/presence_check.rb} +2 -4
  28. data/lib/veto/conditions/condition.rb +7 -0
  29. data/lib/veto/conditions/condition_factory.rb +18 -0
  30. data/lib/veto/conditions/conditions.rb +21 -0
  31. data/lib/veto/conditions/context_method_condition.rb +11 -0
  32. data/lib/veto/conditions/entity_eval_condition.rb +11 -0
  33. data/lib/veto/conditions/if_conditions.rb +8 -0
  34. data/lib/veto/conditions/if_unless_conditions.rb +21 -0
  35. data/lib/veto/conditions/passing_condition.rb +7 -0
  36. data/lib/veto/conditions/primative_condition.rb +11 -0
  37. data/lib/veto/conditions/proc_condition.rb +11 -0
  38. data/lib/veto/conditions/unless_conditions.rb +8 -0
  39. data/lib/veto/configuration.rb +38 -37
  40. data/lib/veto/errors.rb +27 -27
  41. data/lib/veto/exceptions.rb +13 -3
  42. data/lib/veto/model.rb +33 -35
  43. data/lib/veto/validator.rb +68 -169
  44. data/lib/veto/version.rb +1 -1
  45. data/lib/veto.rb +90 -49
  46. data/spec/blocks/block_spec.rb +31 -0
  47. data/spec/blocks/check_block_spec.rb +46 -0
  48. data/spec/blocks/conditional_block_spec.rb +36 -0
  49. data/spec/blocks/validate_block_spec.rb +18 -0
  50. data/spec/blocks/validates_block_spec.rb +22 -0
  51. data/spec/checks/exact_length_check_spec.rb +37 -0
  52. data/spec/checks/format_validator_spec.rb +37 -0
  53. data/spec/checks/greater_than_check_spec.rb +48 -0
  54. data/spec/checks/greater_than_or_equal_to_check_spec.rb +48 -0
  55. data/spec/checks/inclusion_check_spec.rb +37 -0
  56. data/spec/checks/integer_check_spec.rb +37 -0
  57. data/spec/checks/length_range_check_spec.rb +37 -0
  58. data/spec/checks/less_than_check_spec.rb +48 -0
  59. data/spec/checks/less_than_or_equal_to_check_spec.rb +48 -0
  60. data/spec/checks/max_length_check_spec.rb +48 -0
  61. data/spec/checks/method_check_spec.rb +13 -0
  62. data/spec/checks/min_length_check_spec.rb +48 -0
  63. data/spec/checks/not_null_check_spec.rb +37 -0
  64. data/spec/checks/numeric_check_spec.rb +37 -0
  65. data/spec/checks/presence_check_spec.rb +48 -0
  66. data/spec/conditions/condition_factory_spec.rb +31 -0
  67. data/spec/conditions/conditions_spec.rb +25 -0
  68. data/spec/conditions/context_method_condition_spec.rb +25 -0
  69. data/spec/conditions/entity_eval_condition_spec.rb +21 -0
  70. data/spec/conditions/if_conditions_spec.rb +65 -0
  71. data/spec/conditions/if_unless_conditions_spec.rb +33 -0
  72. data/spec/conditions/primative_condition_spec.rb +22 -0
  73. data/spec/conditions/proc_condition_spec.rb +25 -0
  74. data/spec/conditions/unless_conditions_spec.rb +65 -0
  75. data/spec/configuration/message_spec.rb +18 -23
  76. data/spec/spec_helper.rb +2 -1
  77. data/spec/validator_spec.rb +224 -115
  78. metadata +96 -61
  79. data/lib/veto/attribute_validator_factory.rb +0 -36
  80. data/lib/veto/builder.rb +0 -65
  81. data/lib/veto/conditions.rb +0 -23
  82. data/lib/veto/conditions_evaluator.rb +0 -30
  83. data/lib/veto/validators/abstract_validator.rb +0 -15
  84. data/lib/veto/validators/attribute_validator.rb +0 -22
  85. data/lib/veto/validators/custom_method_validator.rb +0 -19
  86. data/spec/attribute_validator_factory_spec.rb +0 -72
  87. data/spec/builder_spec.rb +0 -38
  88. data/spec/conditions_evaluator_spec.rb +0 -90
  89. data/spec/conditions_spec.rb +0 -16
  90. data/spec/configuration_spec.rb +0 -6
  91. data/spec/errors_spec.rb +0 -22
  92. data/spec/model_spec.rb +0 -67
  93. data/spec/system/validator_spec.rb +0 -530
  94. data/spec/validators/exact_length_validator_spec.rb +0 -37
  95. data/spec/validators/format_validator_spec.rb +0 -32
  96. data/spec/validators/inclusion_validator_spec.rb +0 -45
  97. data/spec/validators/integer_validator_spec.rb +0 -42
  98. data/spec/validators/length_range_validator_spec.rb +0 -55
  99. data/spec/validators/max_length_validator_spec.rb +0 -32
  100. data/spec/validators/min_length_validator_spec.rb +0 -32
  101. data/spec/validators/not_null_validator_spec.rb +0 -27
  102. data/spec/validators/numeric_validator_spec.rb +0 -42
  103. data/spec/validators/presence_validator_spec.rb +0 -47
  104. data/spec/veto_spec.rb +0 -24
@@ -0,0 +1,11 @@
1
+ module Veto
2
+ class PrimativeCondition < Condition
3
+ def initialize(object)
4
+ @object = object
5
+ end
6
+
7
+ def pass?(*args)
8
+ !!@object
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module Veto
2
+ class ProcCondition < Condition
3
+ def initialize(proc)
4
+ @proc = proc
5
+ end
6
+
7
+ def pass?(cco)
8
+ !!@proc.call(cco.entity)
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,8 @@
1
+ module Veto
2
+ class UnlessConditions < Conditions
3
+ def pass?(*args)
4
+ conditions.each {|c| return(false) if c.pass?(*args) }
5
+ true
6
+ end
7
+ end
8
+ end
@@ -1,46 +1,47 @@
1
1
  module Veto
2
- class Configuration
3
- class Message
4
- DEFAULT_MESSAGES = {
5
- :exact_length => lambda{|exact| "is not #{exact} characters"},
6
- :format => lambda{"is not valid"},
7
- :greater_than => lambda{|boundary| "must be greater than #{boundary}"},
8
- :greater_than_or_equal_to => lambda{|boundary| "must be greater than or equal to #{boundary}"},
9
- :inclusion => lambda{|set| "is not in set: #{set.inspect}"},
10
- :integer => lambda{"is not a number"},
11
- :length_range => lambda{"is too short or too long"},
12
- :less_than => lambda{|boundary| "must be less than #{boundary}"},
13
- :less_than_or_equal_to => lambda{|boundary| "must be less than or equal to #{boundary}"},
14
- :max_length => lambda{|max| "is longer than #{max} characters"},
15
- :min_length => lambda{|min| "is shorter than #{min} characters"},
16
- :not_null => lambda{"is not present"},
17
- :numeric => lambda{"is not a number"},
18
- :presence => lambda{"is not present"}
19
- }
2
+ class Configuration
3
+ class Message
4
+ DEFAULT_MESSAGES = {
5
+ :default => lambda {"is not valid"},
6
+ :exact_length => lambda {|exact| "is not #{exact} characters"},
7
+ :format => lambda {"is not valid"},
8
+ :greater_than => lambda {|boundary| "must be greater than #{boundary}"},
9
+ :greater_than_or_equal_to => lambda {|boundary| "must be greater than or equal to #{boundary}"},
10
+ :inclusion => lambda {|set| "is not in set: #{set.inspect}"},
11
+ :integer => lambda {"is not a number"},
12
+ :length_range => lambda {"is too short or too long"},
13
+ :less_than => lambda {|boundary| "must be less than #{boundary}"},
14
+ :less_than_or_equal_to => lambda {|boundary| "must be less than or equal to #{boundary}"},
15
+ :max_length => lambda {|max| "is longer than #{max} characters"},
16
+ :min_length => lambda {|min| "is shorter than #{min} characters"},
17
+ :not_null => lambda {"is not present"},
18
+ :numeric => lambda {"is not a number"},
19
+ :presence => lambda {"is not present"}
20
+ }
20
21
 
21
- def get type, *args
22
- args.compact.length > 0 ? message(type).call(*args) : message(type).call
23
- end
22
+ def initialize
23
+ @messages = {}
24
+ end
24
25
 
25
- def set type, proc
26
- custom_messages[type] = proc
27
- end
26
+ def get(type, *args)
27
+ args.compact.length > 0 ? message(type).call(*args) : message(type).call
28
+ end
28
29
 
29
- private
30
+ def set(type, proc)
31
+ @messages[type] = proc
32
+ end
30
33
 
31
- def custom_messages
32
- @custom_messages ||= {}
33
- end
34
+ private
34
35
 
35
- def message type
36
- custom_messages[type] || DEFAULT_MESSAGES.fetch(type)
37
- end
38
- end
36
+ def message(type)
37
+ @messages[type] || DEFAULT_MESSAGES[type] || DEFAULT_MESSAGES[:default]
38
+ end
39
+ end
39
40
 
40
- attr_reader :message
41
+ attr_reader :message
41
42
 
42
- def initialize
43
- @message = Message.new
44
- end
45
- end
43
+ def initialize
44
+ @message = Message.new
45
+ end
46
+ end
46
47
  end
data/lib/veto/errors.rb CHANGED
@@ -1,35 +1,35 @@
1
1
  module Veto
2
- class Errors < ::Hash
3
- def add atr, msg, *msg_opts
4
- fetch(atr){self[atr] = []} << msg_lookup(msg, *msg_opts)
5
- end
2
+ class Errors < ::Hash
3
+ def add(atr, msg, *msg_opts)
4
+ fetch(atr){self[atr] = []} << msg_lookup(msg, *msg_opts)
5
+ end
6
6
 
7
- def count
8
- values.inject(0){|m, v| m + v.length}
9
- end
7
+ def count
8
+ values.inject(0){|m, v| m + v.length}
9
+ end
10
10
 
11
- def empty?
12
- count == 0
13
- end
11
+ def empty?
12
+ count == 0
13
+ end
14
14
 
15
- def full_messages
16
- inject([]) do |m, kv|
17
- atr, errors = *kv
18
- errors.each {|e| m << "#{atr} #{e}"}
19
- m
20
- end
21
- end
15
+ def full_messages
16
+ inject([]) do |m, kv|
17
+ atr, errors = *kv
18
+ errors.each {|e| m << "#{atr} #{e}"}
19
+ m
20
+ end
21
+ end
22
22
 
23
- def on(atr)
24
- if v = fetch(atr, nil) and !v.empty?
25
- v
26
- end
27
- end
23
+ def on(atr)
24
+ if v = fetch(atr, nil) and !v.empty?
25
+ v
26
+ end
27
+ end
28
28
 
29
- private
29
+ private
30
30
 
31
- def msg_lookup msg, *msg_opts
32
- msg.is_a?(Symbol) ? ::Veto.configuration.message.get(msg, *msg_opts) : msg
33
- end
34
- end
31
+ def msg_lookup(msg, *msg_opts)
32
+ msg.is_a?(Symbol) ? ::Veto.configuration.message.get(msg, *msg_opts) : msg
33
+ end
34
+ end
35
35
  end
@@ -1,5 +1,15 @@
1
1
  module Veto
2
- class VetoError < StandardError; end
3
- class InvalidEntity < VetoError; end
4
- class ValidatorNotAssigned < VetoError; end
2
+ class VetoError < StandardError; end
3
+
4
+ class CheckNotAssigned < VetoError; end
5
+
6
+ class InvalidEntity < VetoError
7
+ def initialize(errors)
8
+ @errors = errors
9
+ end
10
+
11
+ def message
12
+ @errors.full_messages
13
+ end
14
+ end
5
15
  end
data/lib/veto/model.rb CHANGED
@@ -1,37 +1,35 @@
1
- require 'veto/exceptions'
2
-
3
1
  module Veto
4
- module Model
5
- def self.included(base)
6
- base.extend ClassMethods
7
- end
8
-
9
- module ClassMethods
10
- def validates_with veto_validator
11
- @validator = veto_validator
12
- end
13
-
14
- def validator
15
- @validator || raise(::Veto::ValidatorNotAssigned, 'validator not assigned')
16
- end
17
- end
18
-
19
- def valid?
20
- validator.valid?
21
- end
22
-
23
- def validate!
24
- validator.validate!
25
- end
26
-
27
- def errors
28
- validator.errors
29
- end
30
-
31
- private
32
-
33
- def validator
34
- @validator ||= self.class.validator.new(self)
35
- end
36
- end
2
+ module Model
3
+ def self.included(base)
4
+ base.extend ClassMethods
5
+ end
6
+
7
+ module ClassMethods
8
+ def validates_with(veto_validator)
9
+ @validator = veto_validator
10
+ end
11
+
12
+ def validator
13
+ @validator || raise(::Veto::ValidatorNotAssigned, 'validator not assigned')
14
+ end
15
+ end
16
+
17
+ def valid?
18
+ validator.valid?(self)
19
+ end
20
+
21
+ def validate!
22
+ validator.validate!(self)
23
+ end
24
+
25
+ def errors
26
+ validator.errors
27
+ end
28
+
29
+ private
30
+
31
+ def validator
32
+ self.class.validator
33
+ end
34
+ end
37
35
  end
@@ -1,171 +1,70 @@
1
- require 'veto/errors'
2
- require 'veto/exceptions'
3
- require 'veto/builder'
4
-
5
1
  module Veto
6
- module Validator
7
- def self.included(base)
8
- base.extend ClassMethods
9
- end
10
-
11
- module ClassMethods
12
- def with_options *args, &block
13
- builder.with_options(*args, &block)
14
- end
15
-
16
- def validates *args
17
- builder.validates(*args)
18
- end
19
-
20
- def validate *args
21
- builder.validate(*args)
22
- end
23
-
24
- # Used to add a validator, or set of validators, to the
25
- # validators list. Generally used by the `validates` and `validate`
26
- # methods internally.
27
- #
28
- # @example
29
- # PersonValidator.validates_with PresenceValidator.new(:first_name)
30
- # # OR
31
- # PersonValidator.validates_with PresenceValidator.new(:first_name), IntegerValidator.new(:age)
32
- #
33
- # @param validator_set [Array] A single, or list, of validator instances
34
- def validate_with *validator_set
35
- validators.concat validator_set.flatten
36
- end
37
-
38
- # Memoizes a flat list of internal validator instances that
39
- # will perform validations on the assigned entity.
40
- #
41
- # @example
42
- # PersonValidator.validators # => [
43
- # <Veto::FormatValidator:0xXXXXXX @attribute=#<Mock:0xXXXXXX>, @options=#<Mock:0xXXXXXX>>,
44
- # <Veto::PresenceValidator:0xXXXXXX @attribute=#<Mock:0xXXXXXX>, @options=#<Mock:0xXXXXXX>>,
45
- # <Veto::ExactLengthValidator:0xXXXXXX @attribute=#<Mock:0xXXXXXX>, @options=#<Mock:0xXXXXXX>>]
46
- #
47
- # @return [Array]
48
- def validators
49
- @validators ||= []
50
- end
51
-
52
- # Returns boolean value representing the validaty of the entity
53
- #
54
- # @param entity [Object] the entity instance to validate.
55
- #
56
- # @return [Boolean]
57
- def valid? *args
58
- new(*args).valid?
59
- end
60
-
61
- # Raises exception if entity is invalid
62
- #
63
- # @example
64
- # person = Person.new
65
- # PersonValidator.validate!(person) # => Veto::InvalidEntity, ["first name is not present", "..."]
66
- #
67
- # @param entity [Object] the entity instance to be validated.
68
- # @raise [Veto::InvalidEntity] if the entity is invalid
69
- def validate! *args
70
- new(*args).validate!
71
- end
72
-
73
- private
74
-
75
- def builder
76
- @builder ||= ::Veto::Builder.new(self)
77
- end
78
-
79
- # Ensures that when a Validator class is subclassed, the
80
- # validation rules will be carried into the subclass as well,
81
- # where they may be added upon.
82
- #
83
- # @example
84
- # class PersonValidator
85
- # include Veto.validator
86
- # validates :name, :presence => true
87
- # end
88
- #
89
- # class EmployeeValidator < PersonValidator
90
- # validates :employee_id, :presence => true
91
- # end
92
- #
93
- # employee = Employee.new
94
- # EmployeeValidator.validate!(employee) # => ["name is not present", "employee_id is not present"]
95
-
96
- def inherited(descendant)
97
- descendant.validate_with validators
98
- end
99
- end
100
-
101
- # Initializes validator
102
- #
103
- # @param entity [Object] the entity instance to validate.
104
- def initialize entity
105
- @entity = entity
106
- end
107
-
108
- # Returns validating entity instance
109
- # @return [Object]
110
- def entity
111
- @entity
112
- end
113
-
114
- # Returns errors object
115
- #
116
- # @return [Veto::Errors]
117
- def errors
118
- @errors ||= ::Veto::Errors.new
119
- end
120
-
121
- # Sets errors to nil.
122
- def clear_errors
123
- @errors = nil
124
- end
125
-
126
- # Returns boolean value representing the validaty of the entity
127
- #
128
- # @return [Boolean]
129
- def valid?
130
- execute
131
- errors.empty?
132
- end
133
-
134
- # Raises exception if entity is invalid
135
- #
136
- # @example
137
- # person = Person.new
138
- # validator = PersonValidator.new(person)
139
- # validator.validate! # => Veto::InvalidEntity, ["first name is not present", "..."]
140
- #
141
- # @raise [Veto::InvalidEntity] if the entity is invalid
142
- def validate!
143
- raise(::Veto::InvalidEntity, errors.full_messages) unless valid?
144
- end
145
-
146
- private
147
-
148
- # Executes validation on the entity
149
- def execute
150
- clear_errors
151
- run_validators
152
- populate_entity_errors
153
- end
154
-
155
- # Runs each of the classes configured validators, passing the
156
- # validator instance, entity, and errors object as arguments.
157
- # Each validator will inspect the entity, run validations, and
158
- # update the errors object according the the validation rules.
159
- def run_validators
160
- self.class.validators.each { |validator| validator.execute(self, entity, errors) }
161
- end
162
-
163
- # If the entity being validated has an errors accessor defined,
164
- # assign the errors object to the entity.
165
- def populate_entity_errors
166
- if entity.respond_to?(:errors=)
167
- entity.errors = errors
168
- end
169
- end
170
- end
2
+ module Validator
3
+ def self.included(base)
4
+ base.extend ClassMethods
5
+ end
6
+
7
+ module ClassMethods
8
+ def with_options(*args, &block)
9
+ checker.with_options(*args, &block)
10
+ end
11
+
12
+ def validates(*args)
13
+ checker.validates(*args)
14
+ end
15
+
16
+ def validate(*args)
17
+ checker.validate(*args)
18
+ end
19
+
20
+ def check_with(val)
21
+ @checker = val
22
+ end
23
+
24
+ def checker
25
+ @checker ||= build_checker
26
+ end
27
+
28
+ private
29
+
30
+ def build_checker(children=[])
31
+ Checker.from_children(children)
32
+ end
33
+
34
+ def inherited(descendant)
35
+ descendant.check_with(build_checker(checker.children.dup))
36
+ end
37
+ end
38
+
39
+ def errors
40
+ @errors ||= ::Veto::Errors.new
41
+ end
42
+
43
+ def valid?(entity)
44
+ validate(entity)
45
+ errors.empty?
46
+ end
47
+
48
+ def validate!(entity)
49
+ raise(::Veto::InvalidEntity, errors) unless valid?(entity)
50
+ end
51
+
52
+ private
53
+
54
+ def clear_errors
55
+ @errors = nil
56
+ end
57
+
58
+ def validate(entity)
59
+ clear_errors
60
+ self.class.checker.call(CheckContextObject.new(entity, self, errors))
61
+ populate_entity_errors(entity)
62
+ end
63
+
64
+ def populate_entity_errors(entity)
65
+ if entity.respond_to?(:errors=)
66
+ entity.errors = errors
67
+ end
68
+ end
69
+ end
171
70
  end
data/lib/veto/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Veto
2
- VERSION = "0.1.3"
2
+ VERSION = "1.0.0"
3
3
  end
data/lib/veto.rb CHANGED
@@ -1,53 +1,94 @@
1
+ module Veto
2
+ # Provides access to the anonymous validator extension module
3
+ #
4
+ # @example
5
+ # class PersonValidator
6
+ # include Veto.validator
7
+ # end
8
+ #
9
+ # @return [Module] the object converted into the expected format.
10
+ def self.validator
11
+ mod = Module.new
12
+ mod.define_singleton_method :included do |base|
13
+ base.send(:include, ::Veto::Validator)
14
+ end
15
+ mod
16
+ end
17
+
18
+ # Provides access to the anonymous model extension module
19
+ #
20
+ # @example
21
+ # class Person
22
+ # include Veto.model(PersonValidator)
23
+ # end
24
+ #
25
+ # @param validator [Class] the Veto validator class
26
+ # @return [Module] the object converted into the expected format.
27
+ def self.model validator
28
+ mod = Module.new
29
+ mod.define_singleton_method :included do |base|
30
+ base.send(:include, ::Veto::Model)
31
+ base.validates_with validator
32
+ end
33
+ mod
34
+ end
35
+
36
+ def self.configure
37
+ yield(configuration)
38
+ end
39
+
40
+ def self.configuration
41
+ @configuration ||= Configuration.new
42
+ end
43
+ end
44
+
45
+ # base
1
46
  require 'veto/version'
2
- require 'veto/model'
3
- require 'veto/validator'
47
+ require 'veto/exceptions'
48
+ require 'veto/errors'
4
49
  require 'veto/configuration'
50
+ require 'veto/check_context_object'
5
51
 
6
- module Veto
52
+ # conditions
53
+ require 'veto/conditions/condition'
54
+ require 'veto/conditions/entity_eval_condition'
55
+ require 'veto/conditions/context_method_condition'
56
+ require 'veto/conditions/proc_condition'
57
+ require 'veto/conditions/primative_condition'
58
+ require 'veto/conditions/conditions'
59
+ require 'veto/conditions/if_conditions'
60
+ require 'veto/conditions/unless_conditions'
61
+ require 'veto/conditions/if_unless_conditions'
62
+ require 'veto/conditions/condition_factory'
63
+
64
+ # checks
65
+ require 'veto/checks/check'
66
+ require 'veto/checks/method_check'
67
+ require 'veto/checks/attribute_check'
68
+ require 'veto/checks/exact_length_check'
69
+ require 'veto/checks/format_check'
70
+ require 'veto/checks/greater_than_or_equal_to_check'
71
+ require 'veto/checks/greater_than_check'
72
+ require 'veto/checks/inclusion_check'
73
+ require 'veto/checks/integer_check'
74
+ require 'veto/checks/length_range_check'
75
+ require 'veto/checks/less_than_or_equal_to_check'
76
+ require 'veto/checks/less_than_check'
77
+ require 'veto/checks/max_length_check'
78
+ require 'veto/checks/min_length_check'
79
+ require 'veto/checks/not_null_check'
80
+ require 'veto/checks/numeric_check'
81
+ require 'veto/checks/presence_check'
82
+ require 'veto/checks/check_factory'
7
83
 
8
- # Provides access to the anonymous validator extension module
9
- #
10
- # @example
11
- # class PersonValidator
12
- # include Veto.validator
13
- # end
14
- #
15
- # @return [Module] the object converted into the expected format.
16
- def self.validator
17
- mod = Module.new
18
- mod.define_singleton_method :included do |base|
19
- base.send(:include, ::Veto::Validator)
20
- end
21
- mod
22
- end
23
-
24
- # Provides access to the anonymous model extension module
25
- #
26
- # @example
27
- # class Person
28
- # include Veto.model(PersonValidator)
29
- # end
30
- #
31
- # @param validator [Class] the Veto validator class
32
- # @return [Module] the object converted into the expected format.
33
- def self.model validator
34
- mod = Module.new
35
- mod.define_singleton_method :included do |base|
36
- base.send(:include, ::Veto::Model)
37
- base.validates_with validator
38
- end
39
- mod
40
- end
41
-
42
- def self.configure
43
- yield(configuration)
44
- end
45
-
46
- def self.configuration
47
- @configuration ||= ::Veto::Configuration.new
48
- end
49
-
50
- def self.configuration= val
51
- @configuration = val
52
- end
53
- end
84
+ # validates
85
+ require 'veto/blocks/block'
86
+ require 'veto/blocks/conditional_block'
87
+ require 'veto/blocks/validate_block'
88
+ require 'veto/blocks/validates_block'
89
+ require 'veto/blocks/with_options_block'
90
+ require 'veto/blocks/checker'
91
+
92
+ # modules
93
+ require 'veto/validator'
94
+ require 'veto/model'