Class: Stannum::Constraints::Properties::Base
- Defined in:
- lib/stannum/constraints/properties/base.rb
Overview
Abstract base class for property constraints.
Direct Known Subclasses
Constant Summary collapse
- FILTERED_PARAMETERS =
Default parameter names to filter out of errors.
%i[ passw secret token _key crypt salt certificate otp ssn ].freeze
Constants inherited from Base
Base::NEGATED_TYPE, Base::TYPE
Instance Attribute Summary collapse
-
#property_names ⇒ Array<String, Symbol>
readonly
The name or names of the properties to match.
Attributes inherited from Base
Instance Method Summary collapse
-
#allow_empty? ⇒ true, false
If true, will match against an object with empty property values, such as an empty string.
-
#allow_nil? ⇒ true, false
If true, will match against an object with nil property values.
-
#initialize(*property_names, **options) ⇒ Base
constructor
A new instance of Base.
Methods inherited from Base
#==, #clone, #does_not_match?, #dup, #errors_for, #match, #matches?, #message, #negated_errors_for, #negated_match, #negated_message, #negated_type, #type, #with_options
Constructor Details
#initialize(*property_names, **options) ⇒ Base
Returns a new instance of Base.
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/stannum/constraints/properties/base.rb', line 32 def initialize(*property_names, **) @property_names = property_names validate_property_names super( allow_empty: !![:allow_empty], allow_nil: !![:allow_nil], property_names: property_names, ** ) end |
Instance Attribute Details
#property_names ⇒ Array<String, Symbol> (readonly)
Returns the name or names of the properties to match.
47 48 49 |
# File 'lib/stannum/constraints/properties/base.rb', line 47 def property_names @property_names end |
Instance Method Details
#allow_empty? ⇒ true, false
Returns if true, will match against an object with empty property values, such as an empty string.
51 52 53 |
# File 'lib/stannum/constraints/properties/base.rb', line 51 def allow_empty? [:allow_empty] end |
#allow_nil? ⇒ true, false
Returns if true, will match against an object with nil property values.
57 58 59 |
# File 'lib/stannum/constraints/properties/base.rb', line 57 def allow_nil? [:allow_nil] end |