Skip to content

Instantly share code, notes, and snippets.

@ngurajeka
Created August 5, 2016 03:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ngurajeka/4da7041e335f9aaabd266c59f57cd12c to your computer and use it in GitHub Desktop.
Save ngurajeka/4da7041e335f9aaabd266c59f57cd12c to your computer and use it in GitHub Desktop.
<?php
function setupValidation()
{
$fields = array();
$fields[] = array(
"type" => "presenceOf",
"field" => "username"
);
$fields[] = array(
"type" => "presenceOf",
"field" => "password"
);
}
function buildValidation(array $fields)
{
foreach ($fields as $field) {
switch ($field["type"]) {
case "presenceOf":
setupPresenceOf($field);
break;
case "date":
setupDate($field);
break;
case "dateTime":
setupDateTime($field);
break;
}
}
}
function setupPresenceOf(array $field)
{
// do whatever you wanted
}
function setupDate(array $field)
{
// do whatever you wanted
}
function setupDateTime(array $field)
{
// do whatever you wanted
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment