Skip to content

validateParameters can't support multiple-type parameter #868

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
karenpeng opened this issue Aug 25, 2015 · 3 comments
Closed

validateParameters can't support multiple-type parameter #868

karenpeng opened this issue Aug 25, 2015 · 3 comments

Comments

@karenpeng
Copy link
Member

Hi, I am using validateParameters function in error_helpers.js to do type check for parameters in function.

/**
 * creates a directional light with a color and a direction
 * @method  directionalLight
 * @param  {Number|Array|String|p5.Color} v1   gray value,
 * red or hue value (depending on the current color mode),
 * or color Array, or CSS color string
 * @param  {Number}          [v2] optional: green or saturation value
 * @param  {Number}          [v3] optional: blue or brightness value
 * @param  {Number}          [a]  optional: opacity
 * @param  {Number|p5.Vector} x   x axis direction or a p5.Vector
 * @param  {Number}          [y]  optional: y axis direction
 * @param  {Number}          [z]  optional: z axis direction
 * @return {p5}
*/
p5.prototype.directionalLight = function(v1, v2, v3, a, x, y, z){//...}

This function takes a color and a direction as arguments, color could be any p5 color format and direction could be xyz or a p5.Vector

It turns out it has a problem with multiple types of the same parameter:

//situation 1
  ['Number', 'Number', 'Number', 'Number'],
 //situation 2
  ['String', 'Number', 'Number', 'Number'],
//situation 3
  ['Array', 'Number', 'Number', 'Number'],
//situation 4
  ['Object', 'Number', 'Number', 'Number']
//...

Say we have (1, 1, 1, 1) as arguments, it satisfies situation 1, however, it still reports error of situation234.

Can validateParameters support multiple-type parameter?

@lmccart
Copy link
Member

lmccart commented Aug 26, 2015

I ran into this too with another method and ended up having to comment out the whole parameter checking in that method. I wonder if given the experimental nature of this functionality, it's best to remove it for now until someone has the time to give it one more pass and get it in super good shape?

@karenpeng
Copy link
Member Author

Yeah I commented for now too. Agree with you.

@lmccart
Copy link
Member

lmccart commented Oct 4, 2015

aggregated into #971

@lmccart lmccart closed this as completed Oct 4, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants