Software / code / prosody
Comparison
util/jsonschema.lua @ 11442:95f0d77175ca
util.jsonschema: Implement the "contains" keyword
And apparently I had mistaken this for an array
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Tue, 09 Mar 2021 02:35:00 +0100 |
| parent | 11441:75a280e6e046 |
| child | 11443:a526abef61e6 |
comparison
equal
deleted
inserted
replaced
| 11441:75a280e6e046 | 11442:95f0d77175ca |
|---|---|
| 203 return false | 203 return false |
| 204 end | 204 end |
| 205 end | 205 end |
| 206 end | 206 end |
| 207 | 207 |
| 208 if schema.contains then | |
| 209 local found = false | |
| 210 for i = 1, #data do | |
| 211 if validate(schema.contains, data[i]) then | |
| 212 found = true | |
| 213 break | |
| 214 end | |
| 215 end | |
| 216 if not found then | |
| 217 return false | |
| 218 end | |
| 219 end | |
| 220 | |
| 208 return true | 221 return true |
| 209 end | 222 end |
| 210 return false | 223 return false |
| 211 end | 224 end |
| 212 | 225 |