proposal: validate module

25 views
Skip to first unread message

Sam l'Ecuyer

unread,
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:

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?

Nathan Stott

unread,
Feb 24, 2012, 1:00:13 PM2/24/12
to comm...@googlegroups.com
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 comm...@googlegroups.com.
To unsubscribe from this group, send email to commonjs+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/commonjs?hl=en.


Reply all
Reply to author
Forward
0 new messages