Passing parameters using an object has become a popular method among
jQuery add-ins.  Few plugins actually validate the passed parameter
object to ensure that elements are spelled correctly.

Most plugins use the jQuery.extend method which would copy the passed
parameter { resiz: 1 } just as easily as the correctly spelled
parameter { resize: 1 }.  A validation of the object before or after
the $.extend would ensure there were no misspellings, something like:

function( arg1, arg2, oParms ) {
  oParms = $.extend( { resize: 0, height: 100, width: 100 }, oParms )
  // $.notIn is fictitious, returns true if any element of oParm is
not in oAllParms
  if ( $.notIn( oAllParms, oParms ) { some error notification here }
  // We know the parms are good so proceed here

Before inventing the wheel again, can anyone point to a clean example
of a plugin that validates object parameters?

Reply via email to