Feb15th
CakePHP model validation
One thing I miss about Ruby on Rails is the model validation. Right out of the box CakePHP does not have great validation. I’ve been specifically looking for a good implementation of validating the uniqueness of an attribute.
After doing some research, Evan of evansagge.com has written a fantastic solution to CakePHP’s lack of model validation. I’ve implemented it and it works very nicely. Here are some of the builtin validation options:
- validateNotEmpty
- validatePattern (you can pass through any regex pattern you would like)
- validateWord - for validating that there’s only regular characters
- validateInteger
- validateNumber
- validateFloat
- validateDouble
- validateEmail
- validateUnique
- validateLength - specify a min and max
- and more…
His Validation also gives very nice methods of accessing the error messages in your templates.
Add comments
Recently
- 08.24 Setting up flash messages in Zend Framework
- 09.08 CakePHP default dateTime()
- 03.24 Extending CakePHP’s beforeFilter()
- 03.17 Rails-like Flash messages in CakePHP
- 03.08 CakePHP thumbnails with phpThumb
- 02.15 CakePHP model validation
- 02.10 CakePHP - saving dates in your model
- 09.19 Importing multiple pdf pages and documents into PDFlib - Part 2
- 09.18 Quick Link - Every CSS based layout you could want
- 09.04 Mongrel pid error fixed