fix validation for full tables
This commit is contained in:
parent
fd59059101
commit
48917659ca
2 changed files with 23 additions and 4 deletions
|
@ -1,4 +1,4 @@
|
|||
TestConfigSchemaValidator = {}
|
||||
TestSchemaValidator = {}
|
||||
|
||||
local config = require('config')
|
||||
|
||||
|
@ -25,7 +25,7 @@ function pprint(t, ident)
|
|||
end
|
||||
end
|
||||
|
||||
function TestConfigSchemaValidator:testBasicFields()
|
||||
function TestSchemaValidator:testBasicFields()
|
||||
local errors = config.validateSchema({a={type='string'}}, {a='test'})
|
||||
lu.assertIs(len(errors), 0)
|
||||
local errors = config.validateSchema({a={type='number'}}, {a=123})
|
||||
|
@ -34,10 +34,29 @@ function TestConfigSchemaValidator:testBasicFields()
|
|||
lu.assertIs(len(errors), 1)
|
||||
end
|
||||
|
||||
function TestConfigSchemaValidator:testList()
|
||||
function TestSchemaValidator:testList()
|
||||
local errors = config.validateSchema({a={type='list', schema={type='number'}}}, {a={1,2,3}})
|
||||
lu.assertIs(len(errors), 0)
|
||||
|
||||
local errors = config.validateSchema({a={type='list', schema={type='number'}}}, {a={1,2,3,'asd'}})
|
||||
lu.assertIs(len(errors), 1)
|
||||
end
|
||||
|
||||
function TestSchemaValidator:testTable()
|
||||
local errors = config.validateSchema(
|
||||
{
|
||||
a={
|
||||
type='table',
|
||||
schema={
|
||||
b={
|
||||
type='number'
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{a=
|
||||
{b=2}
|
||||
}
|
||||
)
|
||||
lu.assertIs(len(errors), 0)
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue