Created
August 5, 2016 03:16
-
-
Save ngurajeka/4da7041e335f9aaabd266c59f57cd12c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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