-
-
Notifications
You must be signed in to change notification settings - Fork 239
/
draft2.rb
45 lines (41 loc) · 1.62 KB
/
draft2.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
require 'json-schema/schema/validator'
module JSON
class Schema
class Draft2 < Validator
def initialize
super
@attributes = {
"type" => JSON::Schema::TypeAttribute,
"disallow" => JSON::Schema::DisallowAttribute,
"format" => JSON::Schema::FormatAttribute,
"maximum" => JSON::Schema::MaximumInclusiveAttribute,
"minimum" => JSON::Schema::MinimumInclusiveAttribute,
"minItems" => JSON::Schema::MinItemsAttribute,
"maxItems" => JSON::Schema::MaxItemsAttribute,
"uniqueItems" => JSON::Schema::UniqueItemsAttribute,
"minLength" => JSON::Schema::MinLengthAttribute,
"maxLength" => JSON::Schema::MaxLengthAttribute,
"divisibleBy" => JSON::Schema::DivisibleByAttribute,
"enum" => JSON::Schema::EnumAttribute,
"properties" => JSON::Schema::PropertiesOptionalAttribute,
"pattern" => JSON::Schema::PatternAttribute,
"additionalProperties" => JSON::Schema::AdditionalPropertiesAttribute,
"items" => JSON::Schema::ItemsAttribute,
"extends" => JSON::Schema::ExtendsAttribute
}
@formats = {
'date-time' => DateTimeFormat,
'date' => DateFormat,
'time' => TimeFormat,
'ip-address' => IP4Format,
'ipv6' => IP6Format,
'uri' => UriFormat
}
@uri = URI.parse("http://json-schema.org/draft-02/schema#")
@names = ["draft2"]
@metaschema = File.join("resources", "draft-02.json")
end
JSON::Validator.register_validator(self.new)
end
end
end