Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

SitePoint PHP Blog:
Validating your data with Respect Validation
Jul 20, 2015 @ 15:49:26

The SitePoint PHP blog has posted a tutorial showing you how to validate your data with Respect (well, their validation library) and ensure the data you're getting is exactly what you're expecting.

Validation is an important aspect of every application’s interaction with data. Instead of reinventing the wheel every time, the community collaborated on some useful packages like Symfony, Laravel, Zend, etc. In this article, we’re going to introduce a lesser known package called Respect Validation, which provides some nice new features.

He starts by mentioning some of the other popular validation packages used widely in the PHP community including the Symfony Validator and Laravel's Illuminate package. For each of these he shows code validating an email address, each with their own slight differences. Using this same example he shows how to implement it in the Respect library, first making use of their custom "email" validator class then via custom chained rules. He also shows how to set custom error messages and provides a more "real world" example with a simple Laravel application. His application takes in user data including username, password and credit card information and uses Respect's library to validate it via a full set of rules. He ends the post with a quick look at creating your own custom rule classes and how to "cross pollinate" them with Zend or Symfony validators.

tagged: respect validation library tutorial laravel example custom errormessage

Link: http://www.sitepoint.com/validating-your-data-with-respect-validation/

php|architect:
More powerful Validation from Respect
Mar 09, 2011 @ 14:50:12

On the php|architect blog today John Mertic looks at a validation library that's been created to filter and handle user input for your application without too much effort on your part - Validation from a group called Respect.

It's simply called Validation, and it is a very simple and straightforward PHP 5.3 based validation library. The goal for them is to make validation easy and painless, using clever constructs like chaining and enabling developers to create reuseable components.

He shows a sample of how it all works by creating a validator that checks to be sure a given value is numeric. He also shows how you can chain the validation methods to create more complicated rules and even check for a set of value types (ex. numbers 1-10 or the string "NO"). You can find the code for Validate on their github repository.

tagged: validation user input github respect tutorial

Link:

Community News:
Ada Lovelace Day 2009
Mar 24, 2009 @ 12:50:00

Today is "Ada Lovelace Day" - a day set aside to be an international day of blogging dedicated to spotlighting those women in science and technology fields that you feel have gone above and beyond and should be recognized for it. Here's more from the official site:

Women's contributions often go unacknowledged, their innovations seldom mentioned, their faces rarely recognized. We want you to tell the world about these unsung heroines. [...] If women need female role models, let's come together to highlight the women in technology that we look up to. Let's create new role models and make sure that whenever the question "Who are the leading women in tech?" is asked, that we all have a list of candidates on the tips of our tongues.

Members of the PHP community have already started making their blog posts (and tweets) about the day - here's a list:

tagged: ald09 adalovelaceday adalovelace community respect spotlight

Link:


Trending Topics: