gradido/src/Model/Validation/GenericValidation.php
Dario Rekowski on RockPI 884c37c399 adding missing file
2020-01-17 19:03:31 +00:00

35 lines
926 B
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
namespace App\Model\Validation;
class GenericValidation
{
public static function hexKey64($value, array $context) {
if(strlen($value) != 64) return false;
if(preg_match('/^[[:xdigit:]]*$/', $value)) {
return true;
}
return false;
}
public static function alphaNumeric($value, array $context) {
//if(preg_match('/^[a-zA-Z0-9äöüÄÖÜß _;:()-]\n\r*$/', $value)) {
if(preg_match('/([<>]|&gt;|&lt;|javascript:){1,}/', $value)) {
return false;
}
return true;
}
public static function email($value, array $context) {
if(preg_match('/^[a-zA-Z0-9.!#$%&*+\/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/', $value)) {
return true;
}
return false;
}
}