openc_json_schema_formats 0.1.1 → 0.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cb93fabf19ab19297d56db70ee012f199feadfa3
4
- data.tar.gz: 8499c95e4cf186bc4ecf5858bebf5d8464d86863
3
+ metadata.gz: 9da9f4cf62f3ecce0f1fbb2bd258f4ddd0335def
4
+ data.tar.gz: 9af2019a94ea7244d1cc40054365574464d645ce
5
5
  SHA512:
6
- metadata.gz: 49dfed2e61af8624e9a5e700cd01047313542ce702c2b9df33655dab314c52781f902f0e24369f7b8069af867062d95bb45ef0d982fd25ebcbd1a7c961d0598a
7
- data.tar.gz: 7683621f2c131403f4e45500ab5f90c44207d827813b327b70db2db443d4ecb6d199c891f6193c2e2ad66dd0273b7a43275f11d4bf1512ded9801f85d1858581
6
+ metadata.gz: ccf132d8b8e7ade4feb598bc9416ab11a20bc409cd61a6c300cc1ffaaec01b42390af4ff295311f2f2ac639780bae35b60a8399df210dc3dc0fafc28177f11c3
7
+ data.tar.gz: 63a99eb6d3203f3580e37886eaf498084f27bb5c86cf3e9fb74a976c9223b86993279164f1254c572392adc276e9deed1ebce37663d6bad0a71e18de1bc8afcf
@@ -12,6 +12,15 @@ module OpencJsonSchemaFormats
12
12
  end
13
13
  end
14
14
 
15
+ class DateTimeFormatValidator
16
+ def validate(record)
17
+ Date.parse(record)
18
+ true
19
+ rescue ArgumentError
20
+ false
21
+ end
22
+ end
23
+
15
24
  class NonBlankValidator
16
25
  def validate(record)
17
26
  !(record.is_a?(String) && record.strip == '')
@@ -35,6 +44,9 @@ end
35
44
  JsonValidation.add_format_validator(
36
45
  'date', OpencJsonSchemaFormats::DateFormatValidator)
37
46
 
47
+ JsonValidation.add_format_validator(
48
+ 'date-time', OpencJsonSchemaFormats::DateFormatValidator)
49
+
38
50
  JsonValidation.add_format_validator(
39
51
  'non-blank', OpencJsonSchemaFormats::NonBlankValidator)
40
52
 
@@ -1,3 +1,3 @@
1
1
  module OpencJsonSchemaFormats
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openc_json_schema_formats
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Seb Bacon