CeshiValidate.php 494 B

123456789101112131415161718192021222324252627
  1. <?php
  2. namespace App\Http\Validate;
  3. use Illuminate\Http\Request;
  4. use Illuminate\Support\Facades\Validator;
  5. class CeshiValidate extends BaseValidate
  6. {
  7. public function index($data)
  8. {
  9. $validate = Validator::make($data,
  10. [
  11. "title"=>"required"
  12. ]
  13. );
  14. if($validate->fails()){
  15. //验证错误
  16. $this->setError($validate->errors()->first());
  17. return false;
  18. }
  19. return true;
  20. }
  21. }