Created
November 14, 2016 20:39
-
-
Save cuonghuynh/24f237a711fc0f9515c8409e20979353 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 | |
namespace App\Validators; | |
use App\Support\AbstractValidator; | |
class CreateItemDataValidator extends AbstractValidator | |
{ | |
/** | |
* handle checking data is valid | |
* @return boolean | |
*/ | |
public function isValid($data) | |
{ | |
$validator = $this->validator($data); | |
if ($validator->fails()) { | |
$this->errors = $validator->errors(); | |
return false; | |
} | |
return true; | |
} | |
/** | |
* create data validator | |
* @param array $data | |
* @return mixed | |
*/ | |
public function validator($data) | |
{ | |
return \Validator::make($data, [ | |
'title' => 'required|string|max:255', | |
'description' => 'string', | |
'link' => 'string|max:255', | |
'channel_id' => 'integer|min:0|exsits:channels,id', | |
'category_id' => 'integer|min:0|exsits:categories,id', | |
'publish_date' => 'required|date_format:"Y-m-s H:i:s"', | |
]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment