Class: Csvlint::Field
- Inherits:
-
Object
- Object
- Csvlint::Field
- Includes:
- ErrorCollector
- Defined in:
- lib/csvlint/field.rb
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.
Attributes included from ErrorCollector
#errors, #info_messages, #warnings
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, all_errors = []) ⇒ Object
Methods included from ErrorCollector
#build_errors, #build_info_messages, #build_warnings, #reset, #valid?
Constructor Details
#initialize(name, constraints = {}, title = nil, description = nil) ⇒ Field
Returns a new instance of Field.
7 8 9 10 11 12 13 14 15 |
# File 'lib/csvlint/field.rb', line 7 def initialize(name, constraints = {}, title = nil, description = nil) @name = name @constraints = constraints || {} @uniques = Set.new @title = title @description = description @regex = nil reset end |
Instance Attribute Details
#constraints ⇒ Object (readonly)
Returns the value of attribute constraints.
5 6 7 |
# File 'lib/csvlint/field.rb', line 5 def constraints @constraints end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
5 6 7 |
# File 'lib/csvlint/field.rb', line 5 def description @description end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/csvlint/field.rb', line 5 def name @name end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
5 6 7 |
# File 'lib/csvlint/field.rb', line 5 def title @title end |
Instance Method Details
#validate_column(value, row = nil, column = nil, all_errors = []) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/csvlint/field.rb', line 17 def validate_column(value, row = nil, column = nil, all_errors = []) reset unless all_errors.any? { |error| (error.type == :invalid_regex) && (error.column == column) } validate_regex(value, row, column, all_errors) end validate_length(value, row, column) validate_values(value, row, column) parsed = validate_type(value, row, column) validate_range(parsed, row, column) if !parsed.nil? valid? end |