Class: JapanShippingCSV::Ehiden::FieldSpec
- Inherits:
-
Struct
- Object
- Struct
- JapanShippingCSV::Ehiden::FieldSpec
- Defined in:
- lib/japan_shipping_csv/ehiden.rb
Instance Attribute Summary collapse
-
#default_value ⇒ Object
Returns the value of attribute default_value.
-
#description ⇒ Object
Returns the value of attribute description.
-
#header ⇒ Object
Returns the value of attribute header.
-
#is_required ⇒ Object
Returns the value of attribute is_required.
-
#max_length ⇒ Object
Returns the value of attribute max_length.
-
#valid_encodings ⇒ Object
Returns the value of attribute valid_encodings.
-
#valid_values ⇒ Object
Returns the value of attribute valid_values.
Instance Method Summary collapse
Instance Attribute Details
#default_value ⇒ Object
Returns the value of attribute default_value
5 6 7 |
# File 'lib/japan_shipping_csv/ehiden.rb', line 5 def default_value @default_value end |
#description ⇒ Object
Returns the value of attribute description
5 6 7 |
# File 'lib/japan_shipping_csv/ehiden.rb', line 5 def description @description end |
#header ⇒ Object
Returns the value of attribute header
5 6 7 |
# File 'lib/japan_shipping_csv/ehiden.rb', line 5 def header @header end |
#is_required ⇒ Object
Returns the value of attribute is_required
5 6 7 |
# File 'lib/japan_shipping_csv/ehiden.rb', line 5 def is_required @is_required end |
#max_length ⇒ Object
Returns the value of attribute max_length
5 6 7 |
# File 'lib/japan_shipping_csv/ehiden.rb', line 5 def max_length @max_length end |
#valid_encodings ⇒ Object
Returns the value of attribute valid_encodings
5 6 7 |
# File 'lib/japan_shipping_csv/ehiden.rb', line 5 def valid_encodings @valid_encodings end |
#valid_values ⇒ Object
Returns the value of attribute valid_values
5 6 7 |
# File 'lib/japan_shipping_csv/ehiden.rb', line 5 def valid_values @valid_values end |
Instance Method Details
#encoding_errors(value) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/japan_shipping_csv/ehiden.rb', line 6 def encoding_errors(value) if !is_required && (value.nil? || value.empty?) return [] end if is_required && (value.nil? || value.empty?) return ["value is required"] end results = [] if !valid_values.nil? && !valid_values.include?(value) results << "must be one of #{valid_values.join(", ")}" end if value.length > max_length results << "is longer than #{max_length} characters" end if valid_encodings # TODO # go through each character in the value, and veriy that it matches the valid encodings if !Encoding::is_valid_string(value, valid_encodings) results << "contains invalid character" end end results end |