This is only for type checking parameters and results that are
single objects and
single arrays.
The idea is that extra values, to be ignored, are inside the checked collection variable.
Extra optional parameter values are not checked for correct type, they are just ignored.
As long as the correct declared type shape is not violated, any additional elective
parameters will be overlooked.
Objects specify their mandatory keys and types, whilst arrays just check the
beginning elements for types, and ignore the rest undescribed elements.
Thus checkParam_typeExtra(an_object,
{a:'string'}) means extra properties
inside the parameter_object are allowed after the string property of 'a'.
func0 = (an_object) => an_object
PRE_check_func0 = (an_object) => {
return type_czech.checkParam_typeExtra(an_object, {a:'string'})
}
func0 = type_czech.linkUp(func0, PRE_check_func0)
func0({a:'pass'}) // pass
func0({a:'pass', b:'string', c:'boolean'}) // pass
func0({fail:17}) // fail
And checkParam_typeExtra(an_array,
'number') refers to
one
number and something extra possibly. Only the first element is checked.
func1 = (an_array) => an_array
PRE_check_func1 = (an_array) => {
return type_czech.checkParam_typeExtra(an_array, 'number')
}
func1 = type_czech.linkUp(func1, PRE_check_func1)
func1([1, 'pass', 'pass', 'pass']) // pass
func1(['all-bad', 'fail', 'fail', 'fail']) // fail
Whereas checkParam_typeExtra(an_array,
['number', 'boolean']) refers to
two
things, a number and a boolean possibly followed by something extra.
func2 = (an_array) => an_array
PRE_check_func2 = (an_array) => {
the_signature = ['number', 'boolean']
return type_czech.checkParam_typeExtra(an_array, the_signature)
}
func2 = type_czech.linkUp(func2, PRE_check_func2)
func2([7, true, 'pass', 'pass', 'pass']) // pass
func2([8, 'fail', 'fail', 'fail', 'fail']) // fail