Implements: blueprint openid-oauth2-admin.backend-api-endpoints-administration
[smarcet] - #5035 - Api Endpoints Administration upgrade from laravel 4.0.* to 4.1.* ** please remove your vendor folder and composer.lock and re run php composer.phar install Change-Id: Idc23e084235de4f7258d1e769228e4eba44c69f0
This commit is contained in:
50
app/validators/CustomValidator.php
Normal file
50
app/validators/CustomValidator.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
use Illuminate\Validation\Validator;
|
||||
use Symfony\Component\Translation\TranslatorInterface;
|
||||
|
||||
class CustomValidator extends Validator {
|
||||
|
||||
protected $implicitRules = array('Required', 'RequiredWith', 'RequiredWithout', 'RequiredIf', 'Accepted', 'RequiredWithoutField');
|
||||
|
||||
public function __construct(TranslatorInterface $translator, $data, $rules, $messages = array())
|
||||
{
|
||||
parent::__construct($translator, $data, $rules, $messages);
|
||||
$this->isImplicit('fail');
|
||||
}
|
||||
|
||||
public function validateBoolean($attribute, $value, $parameters)
|
||||
{
|
||||
return strtoupper(trim($value))==='TRUE' || strtoupper(trim($value))==='FALSE' || strtoupper(trim($value))==='1' || strtoupper(trim($value))==='0' ;
|
||||
}
|
||||
|
||||
public function validateText($attribute, $value, $parameters)
|
||||
{
|
||||
$value = trim($value);
|
||||
return preg_match("/^[a-zA-Z0-9\s\-\.\,]+$/", $value) == 1;
|
||||
}
|
||||
|
||||
public function validateHttpmethod($attribute, $value, $parameters){
|
||||
$value = strtoupper(trim($value));
|
||||
//'GET', 'HEAD','POST','PUT','DELETE','TRACE','CONNECT','OPTIONS'
|
||||
$allowed_http_verbs = array(
|
||||
'GET'=>'GET',
|
||||
'HEAD'=>'HEAD',
|
||||
'POST'=>'POST',
|
||||
'PUT'=>'PUT',
|
||||
'DELETE'=>'DELETE',
|
||||
'TRACE'=>'TRACE',
|
||||
'CONNECT'=>'CONNECT',
|
||||
'OPTIONS'=>'OPTIONS',
|
||||
);
|
||||
|
||||
return array_key_exists($value,$allowed_http_verbs);
|
||||
}
|
||||
|
||||
public function validateRoute($attribute, $value, $parameters){
|
||||
return true;
|
||||
}
|
||||
|
||||
public function validateHost($attribute, $value, $parameters){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user