class FluentValidation::RuleBuilder
Public Class Methods
new(attribute_rule)
click to toggle source
# File lib/fluent_validation/rule_builder.rb, line 16 def initialize(attribute_rule) @attribute_rule = attribute_rule end
Public Instance Methods
email_address()
click to toggle source
# File lib/fluent_validation/rule_builder.rb, line 44 def email_address validator = Validators::EmailValidator.new @attribute_rule.add_validator validator self end
exact_length(length)
click to toggle source
# File lib/fluent_validation/rule_builder.rb, line 38 def exact_length(length) validator = Validators::ExactLengthValidator.new(length) @attribute_rule.add_validator validator self end
greater_than(comparison_value)
click to toggle source
# File lib/fluent_validation/rule_builder.rb, line 62 def greater_than(comparison_value) validator = Validators::GreaterThanValidator.new(comparison_value) @attribute_rule.add_validator validator self end
greater_than_or_equal(comparison_value)
click to toggle source
# File lib/fluent_validation/rule_builder.rb, line 68 def greater_than_or_equal(comparison_value) validator = Validators::GreaterThanOrEqualValidator.new(comparison_value) @attribute_rule.add_validator validator self end
length(min, max)
click to toggle source
# File lib/fluent_validation/rule_builder.rb, line 32 def length(min, max) validator = Validators::LengthValidator.new(min, max) @attribute_rule.add_validator validator self end
less_than(comparison_value)
click to toggle source
# File lib/fluent_validation/rule_builder.rb, line 50 def less_than(comparison_value) validator = Validators::LessThanValidator.new(comparison_value) @attribute_rule.add_validator validator self end
less_than_or_equal(comparison_value)
click to toggle source
# File lib/fluent_validation/rule_builder.rb, line 56 def less_than_or_equal(comparison_value) validator = Validators::LessThanOrEqualValidator.new(comparison_value) @attribute_rule.add_validator validator self end
matches(regexp)
click to toggle source
# File lib/fluent_validation/rule_builder.rb, line 74 def matches(regexp) validator = Validators::RegularExpressionValidator.new(regexp) @attribute_rule.add_validator validator self end
must(&expression)
click to toggle source
# File lib/fluent_validation/rule_builder.rb, line 80 def must(&expression) validator = Validators::PredicateValidator.new(expression) @attribute_rule.add_validator validator self end
not_empty()
click to toggle source
# File lib/fluent_validation/rule_builder.rb, line 26 def not_empty validator = Validators::NotEmptyValidator.new @attribute_rule.add_validator validator self end
not_nil()
click to toggle source
# File lib/fluent_validation/rule_builder.rb, line 20 def not_nil validator = Validators::NotNilValidator.new @attribute_rule.add_validator validator self end
set_collection_validator(validator)
click to toggle source
# File lib/fluent_validation/rule_builder.rb, line 86 def set_collection_validator(validator) validator_adaptor = Validators::ChildCollectionValidatorAdaptor.new validator @attribute_rule.add_validator validator_adaptor self end
when(&expression)
click to toggle source
# File lib/fluent_validation/rule_builder.rb, line 102 def when(&expression) @attribute_rule.condition = expression self end
with_error_code(error_code)
click to toggle source
# File lib/fluent_validation/rule_builder.rb, line 97 def with_error_code(error_code) @attribute_rule.error_code = error_code self end
with_name(name)
click to toggle source
# File lib/fluent_validation/rule_builder.rb, line 92 def with_name(name) @attribute_rule.attribute_name = name self end