Sam l'Ecuyer
unread,Feb 24, 2012, 11:03:18 AM2/24/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message as abuse
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to CommonJS
Hi Guys,
I checked the list and I'm pretty sure nobody else has suggested this,
but I'm sorry if this is a repeat.
I'd like to propose a new standard module for runtime argument
validation based on the apache commons Validate object.
'validate' would be a module much like the unit testing 'assert'
module, but would be used at runtime rather than for testing.
It would export:
isTrue(args)
isFalse(args)
notNull(args)
notEmpty(args)
allOfType(type, args)
InvalidArgumentError
All methods would test for the named condition, taking one or more
args and asserting on each. All methods would throw an
InvalidArgumentError on failure, which is an Error.
notEmpty would fail on null, an empty array, or an non-array.
allOfType would take a type as well as any number of arrays to verify
that all elements are of the passed type. It should not fail on an
empty array.
Thought or suggestions?