当前位置: 首页>>代码示例>>PHP>>正文


PHP validator::errors方法代码示例

本文整理汇总了PHP中validator::errors方法的典型用法代码示例。如果您正苦于以下问题:PHP validator::errors方法的具体用法?PHP validator::errors怎么用?PHP validator::errors使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在validator的用法示例。


在下文中一共展示了validator::errors方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: function

<?php

use ly\Csds;
use Psr\Http\Message\ServerRequestInterface as Request;
use Psr\Http\Message\ResponseInterface as Response;
use ly\Http\Validators\Csds as Validator;
$app->post('/api/csds', function (Request $request, Response $response) {
    $params = $request->getParams();
    $validator = new validator();
    $isValid = $validator->assert($params);
    if (!$isValid) {
        $json_array = [];
        foreach ($validator->errors() as $error) {
            if (!empty($error)) {
                $json_array[] = $error;
            }
        }
        $response = $this->response->withStatus(404)->withHeader('Content-type', 'application/json')->write(json_encode($json_array));
        return $response;
    }
    $csd = Csds::create($params);
    $response = $this->response->withStatus(200)->withHeader('Content-type', 'application/json')->write(json_encode(['message' => 'Csd capturado', 'id' => $csd->id]));
    return $response;
});
开发者ID:lalocespedes,项目名称:slim-3-simple-api,代码行数:24,代码来源:Create.php

示例2: function

     department::update($id, $input);
     Extend::process('department', $id);
     Notify::successs(__('departments.update'));
     return Response::redirect('admin/departments/edit/' . $id);
 });
 Route::get('admin/departments/add', function () {
     $vars['messages'] = Notify::read();
     $vars['token'] = Csrf::token();
     $vars['fields'] = Extend::fields('department');
     return View::create('departments/add', $vars)->partial('header', 'partials/header')->partial('footer', 'partials/footer');
 });
 Route::post('admin/departments/add', function () {
     $input = Input::get(array('title', 'slug', 'description'));
     $validator = new validator($input);
     $validator->check('title')->is_max(3, __('departments.title_missing'));
     if ($errors = $validator->errors()) {
         Input::flash();
         Notify::error($errors);
         return Response::redirect('admin/departments/add');
     }
     if (empty($input['slug'])) {
         $input['slug'] = $input['title'];
     }
     $input['slug'] = slug($input['slug']);
     $department = department::create($input);
     Extend::process('department', $department->id);
     Notify::success(__('departments.created'));
     return Response::redirect('admin/departments');
 });
 Route::get('admin/departments/delete/(:num)', function ($id) {
     $total = department::count();
开发者ID:pepfi,项目名称:anchor-cms,代码行数:31,代码来源:departments.php

示例3: getErrors

 public static function getErrors()
 {
     $errors = self::$errors;
     self::$errors = '';
     return $errors;
 }
开发者ID:Git-Host,项目名称:sms,代码行数:6,代码来源:validator.class.php


注:本文中的validator::errors方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。