/** * Add your own rule's namespace. * * @param string $namespace * * @codeCoverageIgnore */ public function with(string $namespace, bool $overwrite = false) { RespectValidator::with($namespace, $overwrite); }
protected function getValidationRules() { v::with('app\\Models\\Validation\\'); return [v::attribute('name', v::notEmpty()->alpha()->length(2, 100)->UniqueDimensionUOMName()), v::attribute('symbol', v::notEmpty()->alpha()->length(2, 2)->UniqueDimensionUOMSymbol()), v::attribute('routeTransaction', v::instance('app\\Models\\RouteTransaction')), v::attribute('statusId', v::notEmpty()->int()->positive()), v::attribute('createdAt', v::notEmpty()->date()), v::attribute('expiresAt', v::notEmpty()->date())]; }
protected function getValidationRules() { v::with('app\\Models\\Validation\\'); return [v::attribute('name', v::notEmpty()->alpha()->length(2, 100)), v::attribute('symbol', v::notEmpty()->alpha()->length(2, 2)), v::attribute('statusId', v::notEmpty()->int()->positive()), v::attribute('createdAt', v::notEmpty()->date()), v::attribute('expiresAt', v::notEmpty()->date())]; }
$container['flash'] = function ($container) { return new \Slim\Flash\Messages(); }; $container['view'] = function ($container) { $view = new \Slim\Views\Twig(__DIR__ . '/../resources/views/', ['cache' => false]); $view->addExtension(new \Slim\Views\TwigExtension($container->router, $container->request->getUri())); $view->getEnvironment()->addGlobal('auth', ['check' => $container->auth->check(), 'user' => $container->auth->user()]); $view->getEnvironment()->addGlobal('flash', $container->flash); return $view; }; $container['validator'] = function ($container) { return new App\Validation\validator(); }; $container['HomeController'] = function ($container) { return new \App\Controllers\HomeController($container); }; $container['AuthController'] = function ($container) { return new \App\Controllers\Auth\AuthController($container); }; $container['PasswordController'] = function ($container) { return new \App\Controllers\Auth\PasswordController($container); }; $container['csrf'] = function ($container) { return new \Slim\Csrf\Guard(); }; $app->add(new \App\Middleware\ValidationErrorsMiddleware($container)); $app->add(new \App\Middleware\OldInputMiddleware($container)); $app->add(new \App\Middleware\CsrfViewMiddleware($container)); $app->add($container->csrf); v::with('App\\Validation\\Rules\\'); require __DIR__ . '/../app/routes.php';
protected function getValidationRules() { v::with('app\\Models\\Validation\\'); return [v::attribute('provider', v::oneOf(v::instance('app\\Models\\Provider'))), v::attribute('carrier', v::oneOf(v::instance('app\\Models\\Carrier'))), v::attribute('name', v::notEmpty()->length(3, 100)->alpha()->UniqueProviderName()), v::attribute('symbol', v::notEmpty()->length(3, 100)->UniqueProviderSymbol()), v::attribute('routeTransaction', v::instance('app\\Models\\RouteTransaction')), v::attribute('statusId', v::notEmpty()->int()->positive()), v::attribute('createdAt', v::notEmpty()->date()), v::attribute('expiresAt', v::notEmpty()->date())]; }
<?php // Respect pulled in here because of v::with() below use Respect\Validation\Validator as v; //use Jsv4\Validator as jsonv; session_start(); if (!file_exists(__DIR__ . '/settings.php')) { die("Error 500: application configuration problem."); } require __DIR__ . '/../vendor/autoload.php'; // Instantiate the app, setup the path to our custom validation rules $config = (require __DIR__ . '/settings.php'); $app = new \Slim\App($config); v::with('Glued\\Classes\\Validation\\Rules\\'); // Set up dependencies require __DIR__ . '/dependencies.php'; // Register middleware require __DIR__ . '/middleware.php'; // Register routes require __DIR__ . '/routes.php'; /* * NOTE: psr-4 autoloading is turend on in composer.json. The psr-4 entry * "Glued\\": "glued" corresponds to the application name "Glued\" (the * additional backslash is for escaping) and the relative path to the "glued" * directory. PSR-4 will autload things according to the following key: * Glued=glued, Models=glued/Models, User=glued/Models/User.php, hence the * following will work: * *$user = new \Glued\Models\User; *print_r($user); */