[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [jfw] Validate, Filter, and Escape Package

Nice work Amy, but I really don't like your if else construction where the if does nothing, and the mix of strict and non-strict comparisons sometimes.
Another thing for example:

$test = filter_var($this->getFieldValue(), FILTER_SANITIZE_STRING, $this->setFlags());

if ($test == true) {
} else {
    $this->setFieldValue(filter_var($this->getFieldValue(), FILTER_SANITIZE_STRING));

filter_var returns false or the filtered value, so why check for true and do again nothing instead of checking for false
if (false === $test)
    $this->setFieldValue(filter_var($this->getFieldValue(), FILTER_SANITIZE_STRING));

Am Donnerstag, 17. April 2014 04:15:03 UTC+2 schrieb Amy Stephen:
Lots of ways to do, that's for sure.

I use an adapter for each data type (i.e., integer, or foreign key or an array).

I have a validate, filter and escape for each adapter.

There are two reasons I combined these into one package:

1. Many times, the code is the same -- often, a validate method will execute the filter method and then compare the results to the input value. If it's the same, it's valid. As a second example, filtering and "escaping" an integer is the same. Tried to keep it simple and DRY.

 2. Wanted to enable chaining. In a single call, one could validate 1) the value is an integer and 2) the value is a foreign key value. I've hooked it up to my "ORM light" so that these functions are automated on forms and during display.

Lots of ways to do it though.

Link to your code? Or, is it available publicly?

Framework source code: https://github.com/joomla/joomla-framework
Visit http://developer.joomla.org for more information about developing with Joomla!
You received this message because you are subscribed to the Google Groups "Joomla! Framework Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-framework+unsubscribe AT googlegroups.com.
Visit this group at http://groups.google.com/group/joomla-dev-framework.