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

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





On Wednesday, April 16, 2014 10:16:15 PM UTC-5, Sven Versteegen wrote:
Nice work Amy, but I really don't like your if else construction where the if does nothing,

Yes, I think I'm the only PHP developer who is old enough to have been trained on using "positive" logic.

Definitely would "fix" that for Joomla.
 
and the mix of strict and non-strict comparisons sometimes.

You are right -- I am not completely clear on this.  If you have interest in helping on this, I would welcome the PRs.


 
Another thing for example:

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

if ($test == true) {

This should be === (I'll walk thru this)
 
} 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));
}

Can you link to this adapter, please?

Thanks for the great feedback!

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.