Skip to content

Instantly share code, notes, and snippets.

@gthomas3
Created November 13, 2013 19:25
Show Gist options
  • Save gthomas3/7454829 to your computer and use it in GitHub Desktop.
Save gthomas3/7454829 to your computer and use it in GitHub Desktop.
validate
class Validate
{
private static function clean($input = array())
{
$clean = array();
foreach ($input as $key => $value) {
$clean[$key] = htmlentities(mb_convert_encoding($value, 'UTF-8', 'UTF-8'), ENT_QUOTES, 'UTF-8');
}
return $clean;
}
public static function textField($input = array())
{
$error = null;
$clean = self::clean($input);
foreach ($clean as $key => $value) {
if (empty($value)) {
$error = $key . '.empty';
}
}
return $error;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment