NoMethodError: undefined method []' for nil:NilClass from /Users/robert.mcginn/.rvm/gems/ruby-2.7.1/gems/csvlint-0.4.0/lib/csvlint/validate.rb:289:inset_dialect'
it appears that a dialect is required for the error not to be thrown.
If i supply an empty hash rather than nil i get a valid "Csvlint::Validator" object returned but without any errors found
@errors=[]
Initially, I wanted to test that the schema validator was working appropriately, I am expecting at least the "Time" column which is accepting a string of maxLength 1 to return an error. But, that's not working.
Any help would be appreciated.
Expected Behaviour
What should happen?
I'm expecting validator.errors.any? to be true (errors to be found)
I have a rails app where you upload a csv file. I want to use Csvlint to validate the format of the file.
In the app controller I have the following:
file_path(connect) -> the uploaded csv file, the contents are as follows:
In the lib/csv folder I have a file called degiro.csv which includes the following (i am using this for testing purposes)
When I run the following, I get the following error:
path = Rails.root.join('lib', 'csv', 'degiro.csv') schema = Csvlint::Schema.load_from_uri(path) validator = Csvlint::Validator.new(file_path(connect), nil, schema)
NoMethodError: undefined method
[]' for nil:NilClass from /Users/robert.mcginn/.rvm/gems/ruby-2.7.1/gems/csvlint-0.4.0/lib/csvlint/validate.rb:289:in
set_dialect'it appears that a dialect is required for the error not to be thrown.
If i supply an empty hash rather than nil i get a valid "Csvlint::Validator" object returned but without any errors found @errors=[]
# validator = Csvlint::Validator.new(file_path(connect), {} , schema)
Initially, I wanted to test that the schema validator was working appropriately, I am expecting at least the "Time" column which is accepting a string of maxLength 1 to return an error. But, that's not working.
Any help would be appreciated.
Expected Behaviour
I'm expecting validator.errors.any? to be true (errors to be found)
Desired Behaviour (for improvement suggestions only)
Current Behaviour (for problems)
validator.errors.any? = false
Steps to Reproduce (for problems)
As above.
Your Environment
local development environment
Rails 7.0.1 ruby "2.7.1" gem "csvlint" chrome = Version 101.0.4951.64