assert
assert copied to clipboard
allow null/non-null type checking
I should be able to require that a value is exactly the type I specify, and expect it to throw if given null.
var val = null;
assert.type(val, assert.string);
That assertion passes in the current implementation. It would be nice be able to indicate that a value is nullable: assert.type(val, assert.string, true);
Or if we wanted to extend the language to support this: assert.type(?val, assert.string); or non-nullable: assert.type(!val, assert.string);.