Opened 13 years ago

Closed 13 years ago

Last modified 12 years ago

#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});

Change History (2)

comment:1 Changed 13 years ago by skinner

Resolution: fixed
Status: newclosed

fixed in rev 4680

comment:2 Changed 12 years ago by (none)

Milestone: 0.4

Milestone 0.4 deleted

Note: See TracTickets for help on using tickets.