Bug Report #3018

The Validate class should have a method to simply allow a column to "pass thru"

Added by Human Internals about 4 years ago. Updated about 4 years ago.

Status:ClosedStart date:06/27/2010
Priority:NormalDue date:
Assignee:Woody Gilk% Done:

0%

Category:Core
Target version:v3.0.7
Resolution:invalid Points:

Description

If I want the Validate class to allow a column to be passed but without applying any rules, filters or callbacks on it I have to either add a dummy rule (like min_length of zero, which I used until now) or set a label for it (what I currently do) - otherwise it'll delete it.

Calling $validator->label('column_that_should_not_have_any_result', TRUE) works well, but when reading its quite unclear what the developer was trying to do (my team-mate was wondering what I was doing when he read that) and just seems wrong in general.

For readability sake, I propose an "allow" method that'll do the same thing:

public function allow($column) {
    $this->_labels[$column] = TRUE;
}

This method will only be used when a column is allowed but there are no validation rules/callbacks/filters to apply on it. Maybe "passthru" could be a better name.

History

#1 Updated by Human Internals about 4 years ago

Hrr. had a typo. meant "column_that_should_not_have_any_validation".

Also, I accidentally submitted it as a bug instead of a feature request and it seems like I can't change it back. Please change this to a feature request.

#2 Updated by Woody Gilk about 4 years ago

  • Category set to Core
  • Status changed from New to Closed
  • Assignee set to Woody Gilk
  • Target version set to v3.0.7
  • Resolution set to invalid

You can do that simply by setting a label:

$array->label('pass_through', 'Ignored');

#3 Updated by Human Internals about 4 years ago

  • Status changed from Closed to Feedback

I know, and I did say that's what I'm currently doing, but I still think there should be a different method for that, just for readability sake - it seems odd to use the label() method for that, people reading that code might get confuse about the purpose of it.

I think having a method dedicated for that purpose (even tho it internally does the same) would be a more elegant solution.

#4 Updated by Woody Gilk about 4 years ago

You could always use is_string or something like that.

#5 Updated by Woody Gilk about 4 years ago

  • Status changed from Feedback to Closed

#6 Updated by Human Internals about 4 years ago

  • Status changed from Closed to Feedback

I know I can. as I said in the description, the two choices that I currently have is either adding a dummy rule or setting a label.

Both of those options are not elegant and make the validators much less clear. I still think a method dedicated for those cases would provide a better experience when writing validators.

#7 Updated by Woody Gilk about 4 years ago

  • Status changed from Feedback to Closed

Your opinion has been taken into consideration.

Also available in: Atom PDF