proposal: validate module

Skip to first unread message

Sam l'Ecuyer

Feb 24, 2012, 11:03:18 AM2/24/12
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:

allOfType(type, args)

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?

Nathan Stott

Feb 24, 2012, 1:00:13 PM2/24/12
Don't see why this needs standardization.  I would probably use it, but it doesn't need to be standardized imo.

You received this message because you are subscribed to the Google Groups "CommonJS" group.
To post to this group, send email to
To unsubscribe from this group, send email to
For more options, visit this group at

Reply all
Reply to author
0 new messages