Class: Restspec::Schema::Types::DecimalStringType
- Inherits:
-
DecimalType
- Object
- BasicType
- DecimalType
- Restspec::Schema::Types::DecimalStringType
- Defined in:
- lib/restspec/schema/types/decimal_string_type.rb
Instance Method Summary collapse
-
#example_for(attribute) ⇒ Object
Generates a example decimal wrapped in a string.
-
#valid?(attribute, value) ⇒ true, false
Checks is a value is a string and it contains a decimal number.
Methods inherited from BasicType
#initialize, #of, #to_s, #totally_valid?, #|
Constructor Details
This class inherits a constructor from Restspec::Schema::Types::BasicType
Instance Method Details
#example_for(attribute) ⇒ Object
Generates a example decimal wrapped in a string. See Restspec::Schema::Types::DecimalType#example_for for more details of the example generation.
8 9 10 |
# File 'lib/restspec/schema/types/decimal_string_type.rb', line 8 def example_for(attribute) super(attribute).to_s end |
#valid?(attribute, value) ⇒ true, false
Checks is a value is a string and it contains a decimal number
18 19 20 21 |
# File 'lib/restspec/schema/types/decimal_string_type.rb', line 18 def valid?(attribute, value) return false unless value.is_a?(String) decimal_regex.match(value).present? end |