Feature: Accept array values during APIG schema validation for alternates.
Closed this issue · 1 comments
riotrah commented
Currently Vandium is using Joi (via joi json) for schema validation. I've defined all of my schema validations centrally in a model schemas file with each model defined as raw objects so that they can be parsed by both OG Joi and also Vandium as APIG event validation schemas.
Joi supports schema values as arrays, representing a shorthand for .alternates().
I propose we allow Vandium to also accept arrays of Joi schemas.
API:
api()
.get( {
queryStringParameters: {
param: [ Vandium.types.string, Vandum.types.number ]
},
},
() => {} );
Implementation Details
from:
else if( utils.isObject( value ) && value.isJoi ) {
to:
else if(
( utils.isObject( value ) && value.isJoi )
|| ( Array.isArray(value)
&& value.every( item => utils.isObject( value ) && value.isJoi ) )
) {
Of course, something less ugly could be conceived too.
richardhyatt commented
Will implement