Class: Csvlint::Field
- Inherits:
-
Object
- Object
- Csvlint::Field
- Includes:
- ErrorCollector, Types
- Defined in:
- lib/csvlint/field.rb
Constant Summary
Constants included from Types
Types::SIMPLE_FORMATS, Types::TYPE_VALIDATIONS
Constants included from ErrorCollector
ErrorCollector::MESSAGE_LEVELS
Instance Attribute Summary collapse
-
#constraints ⇒ Object
readonly
Returns the value of attribute constraints.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
-
#initialize(name, constraints = {}, title = nil, description = nil) ⇒ Field
constructor
A new instance of Field.
- #validate_column(value, row = nil, column = nil) ⇒ Object
Methods included from Types
Methods included from ErrorCollector
#build_message, #reset, #valid?
Constructor Details
#initialize(name, constraints = {}, title = nil, description = nil) ⇒ Field
9 10 11 12 13 14 15 16 |
# File 'lib/csvlint/field.rb', line 9 def initialize(name, constraints={}, title=nil, description=nil) @name = name @constraints = constraints || {} @uniques = Set.new @title = title @description = description reset end |
Instance Attribute Details
#constraints ⇒ Object (readonly)
Returns the value of attribute constraints.
7 8 9 |
# File 'lib/csvlint/field.rb', line 7 def constraints @constraints end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
7 8 9 |
# File 'lib/csvlint/field.rb', line 7 def description @description end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/csvlint/field.rb', line 7 def name @name end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
7 8 9 |
# File 'lib/csvlint/field.rb', line 7 def title @title end |
Instance Method Details
#validate_column(value, row = nil, column = nil) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/csvlint/field.rb', line 18 def validate_column(value, row=nil, column=nil) reset validate_length(value, row, column) validate_values(value, row, column) parsed = validate_type(value, row, column) validate_range(parsed, row, column) if parsed != nil return valid? end |