Hi! I'm getting the following error when validating an object with any arbitrary members:
Validator_1.schema.object(...).anyMembers is not a function
@adonisjs/core: 5.0.0-preview-rc-1.12
node: v12.18.4
npm: 6.14.8
const { flowChart } = await request.validate({
schema: schema.create({
flowChart: schema.object().anyMembers(),
}),
});
Might be as simple as the function is missing in the Schema implementation.
Currently it states:
/**
* Object schema type
*/
function object(rules?: Rule[]) {
return {
members(schema: any) {
return getObjectType(
false,
Object.keys(schema).reduce((result, field) => {
[field] = schema[field].getTree()
return result
}, {}),
rules || []
)
},
} as ReturnType<ObjectType>
}
object.optional = function optionalObject(rules?: Rule[]) {
return {
members(schema: any) {
return getObjectType(
true,
Object.keys(schema).reduce((result, field) => {
result[field] = schema[field].getTree()
return result
}, {}),
rules || []
)
},
} as ReturnType<ObjectType['optional']>
}
It's missing the implementation of anyMembers()
Fixed in validator. https://github.com/adonisjs/validator/commit/47204efd9547424edee431c6243811f30325f4a5
You will have to wait for a couple of days more before you can use the newer release of the validator that has the fix
Most helpful comment
Fixed in validator. https://github.com/adonisjs/validator/commit/47204efd9547424edee431c6243811f30325f4a5
You will have to wait for a couple of days more before you can use the newer release of the validator that has the fix