An example further to Chris' point is a recent discussion I had with
Nate - I ran into an issue where I passed an IP address through built-
in IP validation then used ip2long to convert it so I could store it
in a MySQL signed INT.  I noticed that an IP written like
255.255.255.011 would pass validation, but if you convert it with
ip2long, store it, retrieve it, convert it with long2ip, you end up
with 255.255.255.9.

Now, I could have posted a rant here saying OH NOES!! CAKE IS FAIL MY
IP VERY BAD! and then talked about what I would change in the core to
"fix" this.

What did I do instead?  I looked up popular regular expressions for
validating IP addresses and saw that they would also validate
255.255.255.011 as acceptable.  I then put some code in my beforeSave
method to modify the submitted octets to their abs() values before
using ip2long.  Problem solved.

As a final step, I politely contacted Nate, explained what I had
discovered, and asked what his thoughts were on the situation.  He
told me (basically) that validation is not about changing data that's
submitted, it's about ensuring the data is correct (not an exact
quote).

So, I learned something from my own research and sandbox work, I got
input from a developer with far more skill than me, and I don't think
I offended anyone or waste anyone's time.  Above all, I think I walked
away without looking like a moron.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to