This is only for empty 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 emptiness, 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 empty description, whilst arrays just check the
beginning elements for being valueless, and ignore the rest undescribed elements.
Thus checkParam_emptyExtra(an_object,
{a:'EMPTY-ERROR'}) means extra properties
inside the parameter_object are ignored after the number property of 'a'.
func0 = (an_object) => an_object
PRE_check_func0 = (an_object) => {
return type_czech.checkParam_emptyExtra(an_object, {a:'EMPTY-ERROR'})
}
func0 = type_czech.linkUp(func0, PRE_check_func0)
func0({a:11, extra:'string'}) //pass
func0({a:'pass'}, 'ok-also') // pass
func0({a:''}) //fail - empty
func0({b:'bad-key'}) //fail - not 'a' key
And checkParam_emptyExtra(an_array,
'EMPTY-ERROR') refers to
one
number and something extra possibly.
func1 = (an_array) => an_array
PRE_check_func1 = (an_array) => {
return type_czech.checkParam_emptyExtra(an_array, 'EMPTY-ERROR')
}
func1 = type_czech.linkUp(func1, PRE_check_func1)
func1([1, '', '', '', 'pass']) // pass
func1(1, '') // pass
func1(['', 'fail', 'fail', 'fail']) // fail
func1('', 'fail') // fail
Whereas checkParam_emptyExtra(an_array,
['EMPTY-ERROR', 'EMPTY-ERROR']) refers to
two
entities that should not be empty, possibly followed by something extra.
func2 = (an_array) => an_array
PRE_check_func2 = (an_array) => {
the_signature = ['EMPTY-ERROR', 'EMPTY-ERROR']
return type_czech.checkParam_emptyExtra(an_array, the_signature)
}
func2 = type_czech.linkUp(func2, PRE_check_func2)
func2([7, true, '', '', '', 'pass']) // pass
func2([{}, '', 'fail', 'fail', 'fail']) // fail
func2(['fail-one-element']) // fail