dslh 0.4.2 → 0.4.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/dslh.rb +13 -0
- data/lib/dslh/version.rb +1 -1
- data/spec/dslh_spec.rb +22 -22
- 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: ba8a8dcc743beceda02fefe5c864909276880831
|
4
|
+
data.tar.gz: 60551002e3cc93d2d0e1a5ccc620a9ee722019ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 839419e273e655b10f0df3ba24470fdc16461e2605549d1f805a8a0b723e58c6db6f193815ee7d2f13b2d1f5bc57c000a0c2ab97c2f800efd85c5b4de5ad421f
|
7
|
+
data.tar.gz: 03421bff73686c0d7d6e176f28295d1727333bf031965ae4454f57ed2fe3218e279c52f8bccd3718b3c9d175622c423ce866dc424aeb6b88c14cbf9e7bfdf811
|
data/lib/dslh.rb
CHANGED
@@ -145,6 +145,19 @@ class Dslh
|
|
145
145
|
end
|
146
146
|
|
147
147
|
errors = validator.validate(new_retval)
|
148
|
+
|
149
|
+
errors.each do |e|
|
150
|
+
path = e.path.split('/', 4)[1..-1]
|
151
|
+
root_key = path.shift
|
152
|
+
_id = path.shift.to_i
|
153
|
+
|
154
|
+
if _id_orig = new_retval.fetch(root_key, {})[_id]
|
155
|
+
_id = _id_orig['_id'] || _id
|
156
|
+
end
|
157
|
+
|
158
|
+
path = '/' + ([root_key, _id] + path).join('/')
|
159
|
+
e.path.replace(path)
|
160
|
+
end
|
148
161
|
else
|
149
162
|
errors = validator.validate(retval)
|
150
163
|
end
|
data/lib/dslh/version.rb
CHANGED
data/spec/dslh_spec.rb
CHANGED
@@ -3098,38 +3098,38 @@ mapping:
|
|
3098
3098
|
sequence:
|
3099
3099
|
- type: map
|
3100
3100
|
mapping:
|
3101
|
-
|
3102
|
-
|
3103
|
-
|
3104
|
-
|
3105
|
-
|
3106
|
-
|
3107
|
-
|
3108
|
-
|
3101
|
+
"_id":
|
3102
|
+
type: str
|
3103
|
+
required: yes
|
3104
|
+
"code":
|
3105
|
+
type: int
|
3106
|
+
required: yes
|
3107
|
+
"email":
|
3108
|
+
type: str
|
3109
3109
|
"employees2":
|
3110
3110
|
type: seq
|
3111
3111
|
sequence:
|
3112
3112
|
- type: map
|
3113
3113
|
mapping:
|
3114
|
-
|
3115
|
-
|
3116
|
-
|
3117
|
-
|
3118
|
-
|
3119
|
-
|
3120
|
-
|
3121
|
-
|
3114
|
+
"_id":
|
3115
|
+
type: str
|
3116
|
+
required: yes
|
3117
|
+
"code":
|
3118
|
+
type: int
|
3119
|
+
required: yes
|
3120
|
+
"email":
|
3121
|
+
type: str
|
3122
3122
|
EOS
|
3123
3123
|
end
|
3124
3124
|
|
3125
3125
|
let(:expected_errmsg) do
|
3126
3126
|
<<-EOS.chomp
|
3127
|
-
[/employees/
|
3128
|
-
[/employees/
|
3129
|
-
[/employees2/
|
3130
|
-
[/employees2/
|
3131
|
-
[/employees2/
|
3132
|
-
[/employees3] key 'employees3:' is undefined.
|
3127
|
+
[/employees/123/_id] '123': not a string.
|
3128
|
+
[/employees/bar/email] '100': not a string.
|
3129
|
+
[/employees2/foo2] key 'code:' is required.
|
3130
|
+
[/employees2/foo2/code1] key 'code1:' is undefined.
|
3131
|
+
[/employees2/foo2/email1] key 'email1:' is undefined.
|
3132
|
+
[/employees3/bar2] key 'employees3:' is undefined.
|
3133
3133
|
EOS
|
3134
3134
|
end
|
3135
3135
|
|