csvlint 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/push.yml +4 -4
- data/.ruby-version +1 -1
- data/.standard_todo.yml +4 -0
- data/README.md +1 -1
- data/csvlint.gemspec +3 -2
- data/lib/csvlint/csvw/column.rb +20 -20
- data/lib/csvlint/csvw/property_checker.rb +38 -38
- data/lib/csvlint/field.rb +1 -1
- data/lib/csvlint/validate.rb +5 -5
- data/lib/csvlint/version.rb +1 -1
- metadata +21 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 193f51b0a401784dbd7b5ee452dd7fffd7d7f6ced9ce9b26adce88a3f6f3f9a8
|
4
|
+
data.tar.gz: a2035c66cd7dae7f02716fee65ba08ff061e18afbda28c580f43c7a0722e2745
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c33ab4a38325228df9e4e8d6f05ca7a264d4b15ddbe9ebe924062a0697695862d870170863f972699ee382c1577a759dc8fdebe64f449f43d8ca5b243dab853e
|
7
|
+
data.tar.gz: 0dd17429279ab82528edaabe469295df051c54a752dc2d30b17956a394a169459fb9c6808d9003c4cb1830e51e4e469f479272356862e28bbcfd86d94ebd7e71
|
data/.github/workflows/push.yml
CHANGED
@@ -9,10 +9,10 @@ jobs:
|
|
9
9
|
runs-on: ubuntu-latest
|
10
10
|
strategy:
|
11
11
|
matrix:
|
12
|
-
ruby-version: ['2.5', '2.6', '2.7', '3.0', '3.1', '3.2']
|
12
|
+
ruby-version: ['2.5', '2.6', '2.7', '3.0', '3.1', '3.2', '3.3']
|
13
13
|
fail-fast: false
|
14
14
|
steps:
|
15
|
-
- uses: actions/checkout@
|
15
|
+
- uses: actions/checkout@v4
|
16
16
|
- uses: ruby/setup-ruby@v1
|
17
17
|
with:
|
18
18
|
bundler-cache: true
|
@@ -24,11 +24,11 @@ jobs:
|
|
24
24
|
lint:
|
25
25
|
runs-on: ubuntu-latest
|
26
26
|
steps:
|
27
|
-
- uses: actions/checkout@
|
27
|
+
- uses: actions/checkout@v4
|
28
28
|
- uses: ruby/setup-ruby@v1
|
29
29
|
with:
|
30
30
|
bundler-cache: true
|
31
|
-
ruby-version: "3.
|
31
|
+
ruby-version: "3.3"
|
32
32
|
- name: Install dependencies
|
33
33
|
run: bundle install
|
34
34
|
- name: Run the tests
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.
|
1
|
+
3.3.0
|
data/.standard_todo.yml
CHANGED
data/README.md
CHANGED
data/csvlint.gemspec
CHANGED
@@ -16,11 +16,12 @@ Gem::Specification.new do |spec|
|
|
16
16
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
17
|
spec.require_paths = ["lib"]
|
18
18
|
|
19
|
-
spec.required_ruby_version = [">= 2.5", "< 3.
|
19
|
+
spec.required_ruby_version = [">= 2.5", "< 3.4"]
|
20
20
|
|
21
|
+
spec.add_dependency "csv"
|
21
22
|
spec.add_dependency "rainbow"
|
22
23
|
spec.add_dependency "open_uri_redirections"
|
23
|
-
spec.add_dependency "activesupport"
|
24
|
+
spec.add_dependency "activesupport", "< 7.1.0"
|
24
25
|
spec.add_dependency "addressable"
|
25
26
|
spec.add_dependency "typhoeus"
|
26
27
|
spec.add_dependency "escape_utils"
|
data/lib/csvlint/csvw/column.rb
CHANGED
@@ -126,14 +126,14 @@ module Csvlint
|
|
126
126
|
format = Csvlint::Csvw::DateFormat.new(nil, type) if format.nil?
|
127
127
|
v = format.parse(value)
|
128
128
|
return nil, warning if v.nil?
|
129
|
-
|
129
|
+
[v, nil]
|
130
130
|
}
|
131
131
|
end
|
132
132
|
|
133
133
|
def create_regexp_based_parser(regexp, warning)
|
134
134
|
lambda { |value, format|
|
135
135
|
return nil, warning unless value&.match?(regexp)
|
136
|
-
|
136
|
+
[value, nil]
|
137
137
|
}
|
138
138
|
end
|
139
139
|
|
@@ -256,14 +256,14 @@ module Csvlint
|
|
256
256
|
"http://www.w3.org/2001/XMLSchema#time" => NO_ADDITIONAL_VALIDATION
|
257
257
|
}
|
258
258
|
|
259
|
-
TRIM_VALUE = lambda { |value, format|
|
260
|
-
ALL_VALUES_VALID = lambda { |value, format|
|
259
|
+
TRIM_VALUE = lambda { |value, format| [value.strip, nil] }
|
260
|
+
ALL_VALUES_VALID = lambda { |value, format| [value, nil] }
|
261
261
|
|
262
262
|
NUMERIC_PARSER = lambda { |value, format, integer = false|
|
263
263
|
format = Csvlint::Csvw::NumberFormat.new(nil, nil, ".", integer) if format.nil?
|
264
264
|
v = format.parse(value)
|
265
265
|
return nil, :invalid_number if v.nil?
|
266
|
-
|
266
|
+
[v, nil]
|
267
267
|
}
|
268
268
|
|
269
269
|
DATATYPE_PARSER = {
|
@@ -281,7 +281,7 @@ module Csvlint
|
|
281
281
|
return true, nil if value == format[0]
|
282
282
|
return false, nil if value == format[1]
|
283
283
|
end
|
284
|
-
|
284
|
+
[value, :invalid_boolean]
|
285
285
|
},
|
286
286
|
"http://www.w3.org/2001/XMLSchema#date" =>
|
287
287
|
create_date_parser("http://www.w3.org/2001/XMLSchema#date", :invalid_date),
|
@@ -291,85 +291,85 @@ module Csvlint
|
|
291
291
|
create_date_parser("http://www.w3.org/2001/XMLSchema#dateTimeStamp", :invalid_date_time_stamp),
|
292
292
|
"http://www.w3.org/2001/XMLSchema#decimal" => lambda { |value, format|
|
293
293
|
return nil, :invalid_decimal if /(E|e|^(NaN|INF|-INF)$)/.match?(value)
|
294
|
-
|
294
|
+
NUMERIC_PARSER.call(value, format)
|
295
295
|
},
|
296
296
|
"http://www.w3.org/2001/XMLSchema#integer" => lambda { |value, format|
|
297
297
|
v, w = NUMERIC_PARSER.call(value, format, true)
|
298
298
|
return v, :invalid_integer unless w.nil?
|
299
299
|
return nil, :invalid_integer unless v.is_a? Integer
|
300
|
-
|
300
|
+
[v, w]
|
301
301
|
},
|
302
302
|
"http://www.w3.org/2001/XMLSchema#long" => lambda { |value, format|
|
303
303
|
v, w = DATATYPE_PARSER["http://www.w3.org/2001/XMLSchema#integer"].call(value, format)
|
304
304
|
return v, :invalid_long unless w.nil?
|
305
305
|
return nil, :invalid_long unless v <= 9223372036854775807 && v >= -9223372036854775808
|
306
|
-
|
306
|
+
[v, w]
|
307
307
|
},
|
308
308
|
"http://www.w3.org/2001/XMLSchema#int" => lambda { |value, format|
|
309
309
|
v, w = DATATYPE_PARSER["http://www.w3.org/2001/XMLSchema#integer"].call(value, format)
|
310
310
|
return v, :invalid_int unless w.nil?
|
311
311
|
return nil, :invalid_int unless v <= 2147483647 && v >= -2147483648
|
312
|
-
|
312
|
+
[v, w]
|
313
313
|
},
|
314
314
|
"http://www.w3.org/2001/XMLSchema#short" => lambda { |value, format|
|
315
315
|
v, w = DATATYPE_PARSER["http://www.w3.org/2001/XMLSchema#integer"].call(value, format)
|
316
316
|
return v, :invalid_short unless w.nil?
|
317
317
|
return nil, :invalid_short unless v <= 32767 && v >= -32768
|
318
|
-
|
318
|
+
[v, w]
|
319
319
|
},
|
320
320
|
"http://www.w3.org/2001/XMLSchema#byte" => lambda { |value, format|
|
321
321
|
v, w = DATATYPE_PARSER["http://www.w3.org/2001/XMLSchema#integer"].call(value, format)
|
322
322
|
return v, :invalid_byte unless w.nil?
|
323
323
|
return nil, :invalid_byte unless v <= 127 && v >= -128
|
324
|
-
|
324
|
+
[v, w]
|
325
325
|
},
|
326
326
|
"http://www.w3.org/2001/XMLSchema#nonNegativeInteger" => lambda { |value, format|
|
327
327
|
v, w = DATATYPE_PARSER["http://www.w3.org/2001/XMLSchema#integer"].call(value, format)
|
328
328
|
return v, :invalid_nonNegativeInteger unless w.nil?
|
329
329
|
return nil, :invalid_nonNegativeInteger unless v >= 0
|
330
|
-
|
330
|
+
[v, w]
|
331
331
|
},
|
332
332
|
"http://www.w3.org/2001/XMLSchema#positiveInteger" => lambda { |value, format|
|
333
333
|
v, w = DATATYPE_PARSER["http://www.w3.org/2001/XMLSchema#integer"].call(value, format)
|
334
334
|
return v, :invalid_positiveInteger unless w.nil?
|
335
335
|
return nil, :invalid_positiveInteger unless v > 0
|
336
|
-
|
336
|
+
[v, w]
|
337
337
|
},
|
338
338
|
"http://www.w3.org/2001/XMLSchema#unsignedLong" => lambda { |value, format|
|
339
339
|
v, w = DATATYPE_PARSER["http://www.w3.org/2001/XMLSchema#nonNegativeInteger"].call(value, format)
|
340
340
|
return v, :invalid_unsignedLong unless w.nil?
|
341
341
|
return nil, :invalid_unsignedLong unless v <= 18446744073709551615
|
342
|
-
|
342
|
+
[v, w]
|
343
343
|
},
|
344
344
|
"http://www.w3.org/2001/XMLSchema#unsignedInt" => lambda { |value, format|
|
345
345
|
v, w = DATATYPE_PARSER["http://www.w3.org/2001/XMLSchema#nonNegativeInteger"].call(value, format)
|
346
346
|
return v, :invalid_unsignedInt unless w.nil?
|
347
347
|
return nil, :invalid_unsignedInt unless v <= 4294967295
|
348
|
-
|
348
|
+
[v, w]
|
349
349
|
},
|
350
350
|
"http://www.w3.org/2001/XMLSchema#unsignedShort" => lambda { |value, format|
|
351
351
|
v, w = DATATYPE_PARSER["http://www.w3.org/2001/XMLSchema#nonNegativeInteger"].call(value, format)
|
352
352
|
return v, :invalid_unsignedShort unless w.nil?
|
353
353
|
return nil, :invalid_unsignedShort unless v <= 65535
|
354
|
-
|
354
|
+
[v, w]
|
355
355
|
},
|
356
356
|
"http://www.w3.org/2001/XMLSchema#unsignedByte" => lambda { |value, format|
|
357
357
|
v, w = DATATYPE_PARSER["http://www.w3.org/2001/XMLSchema#nonNegativeInteger"].call(value, format)
|
358
358
|
return v, :invalid_unsignedByte unless w.nil?
|
359
359
|
return nil, :invalid_unsignedByte unless v <= 255
|
360
|
-
|
360
|
+
[v, w]
|
361
361
|
},
|
362
362
|
"http://www.w3.org/2001/XMLSchema#nonPositiveInteger" => lambda { |value, format|
|
363
363
|
v, w = DATATYPE_PARSER["http://www.w3.org/2001/XMLSchema#integer"].call(value, format)
|
364
364
|
return v, :invalid_nonPositiveInteger unless w.nil?
|
365
365
|
return nil, :invalid_nonPositiveInteger unless v <= 0
|
366
|
-
|
366
|
+
[v, w]
|
367
367
|
},
|
368
368
|
"http://www.w3.org/2001/XMLSchema#negativeInteger" => lambda { |value, format|
|
369
369
|
v, w = DATATYPE_PARSER["http://www.w3.org/2001/XMLSchema#integer"].call(value, format)
|
370
370
|
return v, :invalid_negativeInteger unless w.nil?
|
371
371
|
return nil, :invalid_negativeInteger unless v < 0
|
372
|
-
|
372
|
+
[v, w]
|
373
373
|
},
|
374
374
|
"http://www.w3.org/2001/XMLSchema#double" => NUMERIC_PARSER,
|
375
375
|
# regular expressions here taken from XML Schema datatypes spec
|
@@ -60,7 +60,7 @@ module Csvlint
|
|
60
60
|
raise Csvlint::Csvw::MetadataError.new, "common property with @value has properties other than @language or @type" unless value.except("@type").except("@language").except("@value").empty?
|
61
61
|
when "@language"
|
62
62
|
raise Csvlint::Csvw::MetadataError.new, "common property with @language lacks a @value" unless value["@value"]
|
63
|
-
raise Csvlint::Csvw::MetadataError.new, "common property has invalid @language (#{v})"
|
63
|
+
raise Csvlint::Csvw::MetadataError.new, "common property has invalid @language (#{v})" if !((v.is_a? String) && (v =~ BCP47_LANGUAGE_REGEXP)) || !v.nil?
|
64
64
|
else
|
65
65
|
if p[0] == "@"
|
66
66
|
raise Csvlint::Csvw::MetadataError.new, "common property has property other than @id, @type, @value or @language beginning with @ (#{p})"
|
@@ -99,7 +99,7 @@ module Csvlint
|
|
99
99
|
v = format.parse(value[property])
|
100
100
|
if v.nil?
|
101
101
|
value.delete(property)
|
102
|
-
return [":invalid_#{property}"
|
102
|
+
return [:":invalid_#{property}"]
|
103
103
|
else
|
104
104
|
value[property] = v
|
105
105
|
return []
|
@@ -116,35 +116,35 @@ module Csvlint
|
|
116
116
|
def array_property(type)
|
117
117
|
lambda { |value, base_url, lang|
|
118
118
|
return value, nil, type if value.instance_of? Array
|
119
|
-
|
119
|
+
[false, :invalid_value, type]
|
120
120
|
}
|
121
121
|
end
|
122
122
|
|
123
123
|
def boolean_property(type)
|
124
124
|
lambda { |value, base_url, lang|
|
125
125
|
return value, nil, type if value == true || value == false
|
126
|
-
|
126
|
+
[false, :invalid_value, type]
|
127
127
|
}
|
128
128
|
end
|
129
129
|
|
130
130
|
def string_property(type)
|
131
131
|
lambda { |value, base_url, lang|
|
132
132
|
return value, nil, type if value.instance_of? String
|
133
|
-
|
133
|
+
["", :invalid_value, type]
|
134
134
|
}
|
135
135
|
end
|
136
136
|
|
137
137
|
def uri_template_property(type)
|
138
138
|
lambda { |value, base_url, lang|
|
139
139
|
return URITemplate.new(value), nil, type if value.instance_of? String
|
140
|
-
|
140
|
+
[URITemplate.new(""), :invalid_value, type]
|
141
141
|
}
|
142
142
|
end
|
143
143
|
|
144
144
|
def numeric_property(type)
|
145
145
|
lambda { |value, base_url, lang|
|
146
146
|
return value, nil, type if value.is_a?(Integer) && value >= 0
|
147
|
-
|
147
|
+
[nil, :invalid_value, type]
|
148
148
|
}
|
149
149
|
end
|
150
150
|
|
@@ -152,14 +152,14 @@ module Csvlint
|
|
152
152
|
lambda { |value, base_url, lang|
|
153
153
|
raise Csvlint::Csvw::MetadataError.new, "URL #{value} starts with _:" if /^_:/.match?(value.to_s)
|
154
154
|
return (base_url.nil? ? URI(value) : URI.join(base_url, value)), nil, type if value.instance_of? String
|
155
|
-
|
155
|
+
[base_url, :invalid_value, type]
|
156
156
|
}
|
157
157
|
end
|
158
158
|
|
159
159
|
def language_property(type)
|
160
160
|
lambda { |value, base_url, lang|
|
161
161
|
return value, nil, type if BCP47_REGEXP.match?(value)
|
162
|
-
|
162
|
+
[nil, :invalid_value, type]
|
163
163
|
}
|
164
164
|
end
|
165
165
|
|
@@ -167,7 +167,7 @@ module Csvlint
|
|
167
167
|
lambda { |value, base_url, lang|
|
168
168
|
warnings = []
|
169
169
|
if value.instance_of? String
|
170
|
-
|
170
|
+
[{lang => [value]}, nil, type]
|
171
171
|
elsif value.instance_of? Array
|
172
172
|
valid_titles = []
|
173
173
|
value.each do |title|
|
@@ -177,7 +177,7 @@ module Csvlint
|
|
177
177
|
warnings << :invalid_value
|
178
178
|
end
|
179
179
|
end
|
180
|
-
|
180
|
+
[{lang => valid_titles}, warnings, type]
|
181
181
|
elsif value.instance_of? Hash
|
182
182
|
value = value.clone
|
183
183
|
value.each do |l, v|
|
@@ -197,16 +197,16 @@ module Csvlint
|
|
197
197
|
end
|
198
198
|
end
|
199
199
|
warnings << :invalid_value if value.empty?
|
200
|
-
|
200
|
+
[value, warnings, type]
|
201
201
|
else
|
202
|
-
|
202
|
+
[{}, :invalid_value, type]
|
203
203
|
end
|
204
204
|
}
|
205
205
|
end
|
206
206
|
|
207
207
|
def column_reference_property(type)
|
208
208
|
lambda { |value, base_url, lang|
|
209
|
-
|
209
|
+
[Array(value), nil, type]
|
210
210
|
}
|
211
211
|
end
|
212
212
|
end
|
@@ -226,7 +226,7 @@ module Csvlint
|
|
226
226
|
values << v
|
227
227
|
warnings += w
|
228
228
|
end
|
229
|
-
|
229
|
+
[values, warnings, :common]
|
230
230
|
},
|
231
231
|
"suppressOutput" => boolean_property(:common),
|
232
232
|
"dialect" => lambda { |value, base_url, lang|
|
@@ -249,16 +249,16 @@ module Csvlint
|
|
249
249
|
end
|
250
250
|
end
|
251
251
|
end
|
252
|
-
|
252
|
+
[value, warnings, :common]
|
253
253
|
else
|
254
|
-
|
254
|
+
[{}, :invalid_value, :common]
|
255
255
|
end
|
256
256
|
},
|
257
257
|
# inherited properties
|
258
258
|
"null" => lambda { |value, base_url, lang|
|
259
259
|
case value
|
260
260
|
when String
|
261
|
-
|
261
|
+
[[value], nil, :inherited]
|
262
262
|
when Array
|
263
263
|
values = []
|
264
264
|
warnings = []
|
@@ -269,15 +269,15 @@ module Csvlint
|
|
269
269
|
warnings << :invalid_value
|
270
270
|
end
|
271
271
|
end
|
272
|
-
|
272
|
+
[values, warnings, :inherited]
|
273
273
|
else
|
274
|
-
|
274
|
+
[[""], :invalid_value, :inherited]
|
275
275
|
end
|
276
276
|
},
|
277
277
|
"default" => string_property(:inherited),
|
278
278
|
"separator" => lambda { |value, base_url, lang|
|
279
279
|
return value, nil, :inherited if value.instance_of?(String) || value.nil?
|
280
|
-
|
280
|
+
[nil, :invalid_value, :inherited]
|
281
281
|
},
|
282
282
|
"lang" => language_property(:inherited),
|
283
283
|
"datatype" => lambda { |value, base_url, lang|
|
@@ -387,7 +387,7 @@ module Csvlint
|
|
387
387
|
end
|
388
388
|
end
|
389
389
|
end
|
390
|
-
|
390
|
+
[value, warnings, :inherited]
|
391
391
|
},
|
392
392
|
"required" => boolean_property(:inherited),
|
393
393
|
"ordered" => boolean_property(:inherited),
|
@@ -397,14 +397,14 @@ module Csvlint
|
|
397
397
|
"textDirection" => lambda { |value, base_url, lang|
|
398
398
|
value = value.to_sym
|
399
399
|
return value, nil, :inherited if [:ltr, :rtl, :auto, :inherit].include? value
|
400
|
-
|
400
|
+
[:inherit, :invalid_value, :inherited]
|
401
401
|
},
|
402
402
|
# column level properties
|
403
403
|
"virtual" => boolean_property(:column),
|
404
404
|
"titles" => natural_language_property(:column),
|
405
405
|
"name" => lambda { |value, base_url, lang|
|
406
406
|
return value, nil, :column if value.instance_of?(String) && value =~ NAME_REGEXP
|
407
|
-
|
407
|
+
[nil, :invalid_value, :column]
|
408
408
|
},
|
409
409
|
# table level properties
|
410
410
|
"transformations" => lambda { |value, base_url, lang|
|
@@ -423,7 +423,7 @@ module Csvlint
|
|
423
423
|
elsif p == "titles"
|
424
424
|
else
|
425
425
|
v, warning, type = check_property(p, v, base_url, lang)
|
426
|
-
|
426
|
+
if type != :transformation && !(warning.nil? || warning.empty?)
|
427
427
|
value.delete(p)
|
428
428
|
warnings << :invalid_property unless type == :transformation
|
429
429
|
warnings += Array(warning)
|
@@ -438,12 +438,12 @@ module Csvlint
|
|
438
438
|
else
|
439
439
|
warnings << :invalid_value
|
440
440
|
end
|
441
|
-
|
441
|
+
[transformations, warnings, :table]
|
442
442
|
},
|
443
443
|
"tableDirection" => lambda { |value, base_url, lang|
|
444
444
|
value = value.to_sym
|
445
445
|
return value, nil, :table if [:ltr, :rtl, :auto].include? value
|
446
|
-
|
446
|
+
[:auto, :invalid_value, :table]
|
447
447
|
},
|
448
448
|
"tableSchema" => lambda { |value, base_url, lang|
|
449
449
|
schema_base_url = base_url
|
@@ -483,7 +483,7 @@ module Csvlint
|
|
483
483
|
end
|
484
484
|
end
|
485
485
|
end
|
486
|
-
|
486
|
+
[schema, warnings, :table]
|
487
487
|
},
|
488
488
|
"url" => link_property(:table),
|
489
489
|
# dialect properties
|
@@ -492,7 +492,7 @@ module Csvlint
|
|
492
492
|
"doubleQuote" => boolean_property(:dialect),
|
493
493
|
"encoding" => lambda { |value, base_url, lang|
|
494
494
|
return value, nil, :dialect if VALID_ENCODINGS.include? value
|
495
|
-
|
495
|
+
[nil, :invalid_value, :dialect]
|
496
496
|
},
|
497
497
|
"header" => boolean_property(:dialect),
|
498
498
|
"headerRowCount" => numeric_property(:dialect),
|
@@ -508,10 +508,10 @@ module Csvlint
|
|
508
508
|
value = :start if value == "start"
|
509
509
|
value = :end if value == "end"
|
510
510
|
return value, nil, :dialect if [:true, :false, :start, :end].include? value
|
511
|
-
|
511
|
+
[true, :invalid_value, :dialect]
|
512
512
|
},
|
513
513
|
# schema properties
|
514
|
-
"columns" => lambda { |value, base_url, lang|
|
514
|
+
"columns" => lambda { |value, base_url, lang| [value, nil, :schema] },
|
515
515
|
"primaryKey" => column_reference_property(:schema),
|
516
516
|
"foreignKeys" => lambda { |value, base_url, lang|
|
517
517
|
foreign_keys = []
|
@@ -540,13 +540,13 @@ module Csvlint
|
|
540
540
|
else
|
541
541
|
warnings << :invalid_value
|
542
542
|
end
|
543
|
-
|
543
|
+
[foreign_keys, warnings, :schema]
|
544
544
|
},
|
545
545
|
"rowTitles" => column_reference_property(:schema),
|
546
546
|
# transformation properties
|
547
|
-
"targetFormat" => lambda { |value, base_url, lang|
|
548
|
-
"scriptFormat" => lambda { |value, base_url, lang|
|
549
|
-
"source" => lambda { |value, base_url, lang|
|
547
|
+
"targetFormat" => lambda { |value, base_url, lang| [value, nil, :transformation] },
|
548
|
+
"scriptFormat" => lambda { |value, base_url, lang| [value, nil, :transformation] },
|
549
|
+
"source" => lambda { |value, base_url, lang| [value, nil, :transformation] },
|
550
550
|
# foreignKey properties
|
551
551
|
"columnReference" => column_reference_property(:foreign_key),
|
552
552
|
"reference" => lambda { |value, base_url, lang|
|
@@ -572,15 +572,15 @@ module Csvlint
|
|
572
572
|
raise Csvlint::Csvw::MetadataError.new("foreignKey.reference.columnReference"), "foreignKey reference columnReference is missing" unless value["columnReference"]
|
573
573
|
raise Csvlint::Csvw::MetadataError.new("foreignKey.reference"), "foreignKey reference does not have either resource or schemaReference" unless value["resource"] || value["schemaReference"]
|
574
574
|
raise Csvlint::Csvw::MetadataError.new("foreignKey.reference"), "foreignKey reference has both resource and schemaReference" if value["resource"] && value["schemaReference"]
|
575
|
-
|
575
|
+
[value, warnings, :foreign_key]
|
576
576
|
else
|
577
577
|
raise Csvlint::Csvw::MetadataError.new("foreignKey.reference"), "foreignKey reference is not an object"
|
578
578
|
end
|
579
579
|
},
|
580
580
|
# foreignKey reference properties
|
581
|
-
"resource" => lambda { |value, base_url, lang|
|
581
|
+
"resource" => lambda { |value, base_url, lang| [value, nil, :foreign_key_reference] },
|
582
582
|
"schemaReference" => lambda { |value, base_url, lang|
|
583
|
-
|
583
|
+
[URI.join(base_url, value).to_s, nil, :foreign_key_reference]
|
584
584
|
}
|
585
585
|
}
|
586
586
|
|
data/lib/csvlint/field.rb
CHANGED
@@ -16,7 +16,7 @@ module Csvlint
|
|
16
16
|
|
17
17
|
def validate_column(value, row = nil, column = nil, all_errors = [])
|
18
18
|
reset
|
19
|
-
unless all_errors.any? { |error| (
|
19
|
+
unless all_errors.any? { |error| (error.type == :invalid_regex) && (error.column == column) }
|
20
20
|
validate_regex(value, row, column, all_errors)
|
21
21
|
end
|
22
22
|
validate_length(value, row, column)
|
data/lib/csvlint/validate.rb
CHANGED
@@ -590,14 +590,14 @@ module Csvlint
|
|
590
590
|
numeric: /\A[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?\z/,
|
591
591
|
uri: /\Ahttps?:/,
|
592
592
|
date_db: /\A\d{4,}-\d\d-\d\d\z/, # "12345-01-01"
|
593
|
-
date_long: /\A(?:#{Date::MONTHNAMES.join(
|
594
|
-
date_rfc822: /\A[ \d]\d (?:#{Date::ABBR_MONTHNAMES.join(
|
595
|
-
date_short: /\A[ \d]\d (?:#{Date::ABBR_MONTHNAMES.join(
|
593
|
+
date_long: /\A(?:#{Date::MONTHNAMES.join("|")}) [ \d]\d, \d{4,}\z/, # "January 1, 12345"
|
594
|
+
date_rfc822: /\A[ \d]\d (?:#{Date::ABBR_MONTHNAMES.join("|")}) \d{4,}\z/, # " 1 Jan 12345"
|
595
|
+
date_short: /\A[ \d]\d (?:#{Date::ABBR_MONTHNAMES.join("|")})\z/, # "1 Jan"
|
596
596
|
dateTime_db: /\A\d{4,}-\d\d-\d\d \d\d:\d\d:\d\d\z/, # "12345-01-01 00:00:00"
|
597
597
|
dateTime_hms: /\A\d\d:\d\d:\d\d\z/, # "00:00:00"
|
598
598
|
dateTime_iso8601: /\A\d{4,}-\d\d-\d\dT\d\d:\d\d:\d\dZ\z/, # "12345-01-01T00:00:00Z"
|
599
|
-
dateTime_long: /\A(?:#{Date::MONTHNAMES.join(
|
600
|
-
dateTime_short: /\A\d\d (?:#{Date::ABBR_MONTHNAMES.join(
|
599
|
+
dateTime_long: /\A(?:#{Date::MONTHNAMES.join("|")}) \d\d, \d{4,} \d\d:\d\d\z/, # "January 01, 12345 00:00"
|
600
|
+
dateTime_short: /\A\d\d (?:#{Date::ABBR_MONTHNAMES.join("|")}) \d\d:\d\d\z/, # "01 Jan 00:00"
|
601
601
|
dateTime_time: /\A\d\d:\d\d\z/ # "00:00"
|
602
602
|
}.freeze
|
603
603
|
|
data/lib/csvlint/version.rb
CHANGED
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: csvlint
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- pezholio
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-01-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: csv
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
@@ -25,7 +25,7 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: rainbow
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: open_uri_redirections
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: activesupport
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "<"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 7.1.0
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "<"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 7.1.0
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: addressable
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -513,14 +527,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
513
527
|
version: '2.5'
|
514
528
|
- - "<"
|
515
529
|
- !ruby/object:Gem::Version
|
516
|
-
version: '3.
|
530
|
+
version: '3.4'
|
517
531
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
518
532
|
requirements:
|
519
533
|
- - ">="
|
520
534
|
- !ruby/object:Gem::Version
|
521
535
|
version: '0'
|
522
536
|
requirements: []
|
523
|
-
rubygems_version: 3.
|
537
|
+
rubygems_version: 3.5.3
|
524
538
|
signing_key:
|
525
539
|
specification_version: 4
|
526
540
|
summary: CSV Validator
|