2017 © Pedro Peláez
 

library validator

Validation using the symfony components, but in the laravel style

image

pravaler/validator

Validation using the symfony components, but in the laravel style

  • Friday, July 20, 2018
  • by eltonrms.leite
  • Repository
  • 2 Watchers
  • 0 Stars
  • 21 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

Pravaler Validator Component

Create a component using Synfony validations in the style of Laravel, (*1)

Supported Symfony Versions

4.x Symfony, (*2)

Installation

Download the package, (*3)

$ composer require pravaler/validator

Using

Example:, (*4)

<?php

namespace App\Controller;

use Pravaler\Component\Validator\Validator;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;

class PostController extends Controller
{
    public function savePost(Request $request)
    {
        $data = $request->request->all();

        $validator = new Validator([
            'name' => 'required',
            'author' => 'required',
            'email' => 'required|email',
            'description' => 'required|size:1:500'
        ]);
        $validator->validate($data);
        if (!$validator->isValid()) {
            return $this->render("post/index.html.twig", [
                'errors' => $validator->getViolations()
            ]);
        }

        return $this->render("post/index.html.twig", [
            'message' => 'The post is valid!'
        ]);
    }
}

Possible Validations

Cpf

$validator = new Validator([
    'field' => 'cpf',
]);

Email

$validator = new Validator([
    'field' => 'email',
]);

Max

$validator = new Validator([
    'field' => 'max:10',
]);

Min

$validator = new Validator([
    'field' => 'min:5',
]);

Numeric

$validator = new Validator([
    'field' => 'numeric',
]);

Password Confirm

// In order for the password confirm to take effect it is necessary to have in the data the password field

$validator = new Validator([
    'field' => 'password_confirm',
]);

Required

$validator = new Validator([
    'field' => 'required',
]);

Size

$validator = new Validator([
    'field' => 'size:1:500',
]);

regex

$validator = new Validator([
    'field' => 'regex:/[1-9]{2}\9\d{8}/',
]);

License

This project is licensed under the MIT license. For more information, see the license file included in this bundle., (*5)

Based

Created based on symfony/validator, (*6)

The Versions

20/07 2018

dev-master

9999999-dev https://github.com/eltonsalles/pravaler-validator

Validation using the symfony components, but in the laravel style

  Sources   Download

MIT

The Requires

 

The Development Requires

by Elton Rodrigues
by Luiz Valentim
by Fernando Takacs

20/07 2018

1.1.2

1.1.2.0 https://github.com/eltonsalles/pravaler-validator

Validation using the symfony components, but in the laravel style

  Sources   Download

MIT

The Requires

 

The Development Requires

by Elton Rodrigues
by Luiz Valentim
by Fernando Tacks

20/07 2018

1.1.1

1.1.1.0 https://github.com/eltonsalles/pravaler-validator

Validation using the symfony components, but in the laravel style

  Sources   Download

MIT

The Requires

 

The Development Requires

by Elton Rodrigues
by Luiz Valentim
by Fernando Tacks

18/07 2018

1.1.0

1.1.0.0 https://github.com/eltonsalles/pravaler-validator

Validation using the symfony components, but in the laravel style

  Sources   Download

MIT

The Requires

 

The Development Requires

by Elton Rodrigues
by Luiz Valentim
by Fernando Tacks

16/07 2018

1.0.0

1.0.0.0 https://github.com/eltonsalles/pravaler-validator

Validation using the symfony components, but in the laravel style

  Sources   Download

MIT

The Requires

 

The Development Requires

by Elton Rodrigues
by Luiz Valentim
by Fernando Tacks