haveapi-client 0.27.2 → 0.27.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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f19892484687b15ed8dc7c1316dd17d45bd087f156adf9cd6ad5a225dce8dedd
|
|
4
|
+
data.tar.gz: 422dea297e175322052513f595328cdf685c11e04cfe1fbcf15a014caa7c99aa
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f1cd0cb7f2278a71879e9575dc5fc71064b1bdb61cf87a65b17f3ae47f6e7ba754d8019cffefd1afeed275fea333bab67df2b7746f8fdd0e09b4ff443cd370a0
|
|
7
|
+
data.tar.gz: 24f159b459283e909da0b70568b6b10565d2f61d5016f11423ac0f612601ddd7df4480fcac8fdb48ebcf84a30100ff637bdadaa4518539fed9b98b3c45ce0bc4
|
|
@@ -4,6 +4,7 @@ module HaveAPI::Client
|
|
|
4
4
|
|
|
5
5
|
def initialize(params, desc, value)
|
|
6
6
|
@errors = []
|
|
7
|
+
@desc = desc
|
|
7
8
|
@value = coerce(value)
|
|
8
9
|
end
|
|
9
10
|
|
|
@@ -18,7 +19,19 @@ module HaveAPI::Client
|
|
|
18
19
|
protected
|
|
19
20
|
|
|
20
21
|
def coerce(v)
|
|
21
|
-
|
|
22
|
+
if v.nil?
|
|
23
|
+
return nil if @desc[:nullable]
|
|
24
|
+
|
|
25
|
+
@errors << 'cannot be null'
|
|
26
|
+
return nil
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
if v.is_a?(::String) && v.strip.empty?
|
|
30
|
+
return nil if @desc[:nullable]
|
|
31
|
+
|
|
32
|
+
@errors << 'not a valid resource id'
|
|
33
|
+
return nil
|
|
34
|
+
end
|
|
22
35
|
|
|
23
36
|
if !v.is_a?(::Integer) && /\A\d+\z/ !~ v
|
|
24
37
|
@errors << 'not a valid resource id'
|
|
@@ -32,7 +32,16 @@ module HaveAPI::Client
|
|
|
32
32
|
protected
|
|
33
33
|
|
|
34
34
|
def coerce(raw)
|
|
35
|
-
|
|
35
|
+
if raw.nil?
|
|
36
|
+
return nil if @desc[:nullable]
|
|
37
|
+
|
|
38
|
+
@errors << 'cannot be null'
|
|
39
|
+
return nil
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
if raw.is_a?(::String) && raw.strip.empty? && @desc[:nullable]
|
|
43
|
+
return nil
|
|
44
|
+
end
|
|
36
45
|
|
|
37
46
|
type = @desc[:type]
|
|
38
47
|
|