-
Notifications
You must be signed in to change notification settings - Fork 0
/
number.go
54 lines (41 loc) · 1.32 KB
/
number.go
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
46
47
48
49
50
51
52
53
54
package polyschema
func checkNumber(parent, child JsonSchema) TypesIdentity {
var identity TypesIdentity
identity = TypesEqual
// minimum
if parent.Minimum != nil && child.Minimum != nil && *parent.Minimum != *child.Minimum {
return TypesNotEqual
}
if parent.Minimum == nil && child.Minimum != nil {
identity = TypesSubtype
}
// exclusiveMinimum
if parent.ExclusiveMinimum != nil && child.ExclusiveMinimum != nil && *parent.ExclusiveMinimum != *child.ExclusiveMinimum {
return TypesNotEqual
}
if parent.ExclusiveMinimum == nil && child.ExclusiveMinimum != nil {
identity = TypesSubtype
}
// maximum
if parent.Maximum != nil && child.Maximum != nil && *parent.Maximum != *child.Maximum {
return TypesNotEqual
}
if parent.Maximum == nil && child.Maximum != nil {
identity = TypesSubtype
}
// exclusiveMaximum
if parent.ExclusiveMaximum != nil && child.ExclusiveMaximum != nil && *parent.ExclusiveMaximum != *child.ExclusiveMaximum {
return TypesNotEqual
}
if parent.ExclusiveMaximum == nil && child.ExclusiveMaximum != nil {
identity = TypesSubtype
}
// multipleOf
if parent.MultipleOf != nil && child.MultipleOf != nil && *parent.MultipleOf != *child.MultipleOf {
return TypesNotEqual
}
if parent.MultipleOf == nil && child.MultipleOf != nil {
identity = TypesSubtype
}
return identity
}