Module: Mint::Money::FormatterValidator Private
- Included in:
- Formatter
- Defined in:
- lib/minting/money/format/validator.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Shared validation for format templates and separator configuration.
Instance Method Summary collapse
- #validate_format!(format) ⇒ Object private
- #validate_separators!(decimal:, thousand:) ⇒ Object private
Instance Method Details
#validate_format!(format) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
9 10 11 12 13 14 |
# File 'lib/minting/money/format/validator.rb', line 9 def validate_format!(format) raise ArgumentError, 'template must not be empty' if format == {} unknown = format.keys - %i[positive negative zero] raise ArgumentError, "Unknown format parameter(s): #{unknown.inspect}. " unless unknown.empty? end |
#validate_separators!(decimal:, thousand:) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/minting/money/format/validator.rb', line 16 def validate_separators!(decimal:, thousand:) case decimal when '' then raise ArgumentError, "decimal separator must be a non-empty - #{decimal.inspect}" when /\d/ then raise ArgumentError, "decimal separator cannot be a numeral - #{decimal.inspect}" when thousand then raise ArgumentError, "decimal and thousand cannot be identical - #{decimal.inspect}" when String # :noop else raise ArgumentError, "decimal must be a String, false, or nil, got #{decimal.inspect}" end case thousand when false, nil # :noop when /\d/ then raise ArgumentError, "decimal separator cannot be a numeral - #{decimal.inspect}" when String # :noop else raise ArgumentError, "thousand must be a String, false, or nil, got #{thousand.inspect}" end end |