openc_json_schema_formats 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/openc_json_schema_formats.rb +3 -6
- data/lib/openc_json_schema_formats/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7fdf76879a396b56f15d53be48980a27f4ae6fcf
|
|
4
|
+
data.tar.gz: 7d872ca47c66e891c07e697349cd8f6887e6df5d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 15714a49089d2033fc40cc3e71568ef8603ba07bb176045781f22b1d2a4729237630d792d0a613c01b2a0321269573cb0d3be8c81653d7d9820981d8e4478725
|
|
7
|
+
data.tar.gz: b5aa4caf384315cdb0cb04b7c0571fdc464f9b1fddecf34de814d4e1624dd67cb94a7b896bbbcd00f6c77b9b108aea2098fdfdcdd67fadcd7bdbe296a7a637fb
|
|
@@ -3,6 +3,8 @@ require "json_validation"
|
|
|
3
3
|
require "uri"
|
|
4
4
|
|
|
5
5
|
module OpencJsonSchemaFormats
|
|
6
|
+
# From https://mathiasbynens.be/demo/url-regex
|
|
7
|
+
URI_REGEX = Regexp.new("^(https?|ftp)://[^\s/$.?#].[^\s]*$", Regexp::IGNORECASE)
|
|
6
8
|
class DateFormatValidator
|
|
7
9
|
def validate(record)
|
|
8
10
|
Date.strptime(record, '%Y-%m-%d')
|
|
@@ -31,12 +33,7 @@ module OpencJsonSchemaFormats
|
|
|
31
33
|
# Actually, this only checks http and https formats, so isn't
|
|
32
34
|
# really for URIs
|
|
33
35
|
def validate(record)
|
|
34
|
-
|
|
35
|
-
uri = URI.parse(record)
|
|
36
|
-
uri.kind_of?(URI::HTTP) || uri.kind_of?(URI::HTTPS)
|
|
37
|
-
rescue URI::InvalidURIError
|
|
38
|
-
false
|
|
39
|
-
end
|
|
36
|
+
record =~ URI_REGEX
|
|
40
37
|
end
|
|
41
38
|
end
|
|
42
39
|
end
|