#898 closed enhancement (fixed)
dojo.lang -- isOfType() and assertType() -- better API for "optional" values
Reported by: | skinner | Owned by: | anonymous |
---|---|---|---|
Priority: | lowest | Milestone: | |
Component: | General | Version: | 0.3 |
Keywords: | Cc: | ||
Blocked By: | Blocking: |
Description
In srclangassert.js and srclang ype.js, consider changing the call signature for how the caller indicates that the value is "optional" in the functions dojo.lang.isOfType() and dojo.lang.assertType().
Current examples:
dojo.lang.isOfType(new Date(), Date); // returns true dojo.lang.isOfType(null, Date); // returns false dojo.lang.isOfType(new Date(), [Date, "optional"] ); // returns true dojo.lang.isOfType(null, [Date, "optional"] ); // returns true dojo.lang.assertType("foo", [String, "optional"]); dojo.lang.assertType(null, [String, "optional"]);
Proposed new API:
dojo.lang.isOfType(new Date(), Date); // returns true dojo.lang.isOfType(null, Date); // returns false dojo.lang.isOfType(new Date(), Date, {optional: true} ); // returns true dojo.lang.isOfType(null, Date, {optional: true} ); // returns true dojo.lang.assertType("foo", String, {optional: true}); dojo.lang.assertType(null, String, {optional: true});
Note: See
TracTickets for help on using
tickets.
fixed in rev 4680