GithubHelp home page GithubHelp logo

validation's Introduction

kennedytedesco/validation

The power of Respect Validation on Laravel.

Build Status Total Downloads Latest Stable Version License

Version Compatibility

Laravel kennedytedesco/validation
9.x composer require kennedytedesco/validation:^9.0
8.x composer require kennedytedesco/validation:^8.0
7.x composer require kennedytedesco/validation:^7.0
6.x composer require kennedytedesco/validation:^6.0
5.8.x composer require kennedytedesco/validation:^5.0
5.7.x composer require kennedytedesco/validation:^5.0
5.6.x composer require kennedytedesco/validation:^5.0
5.5.x composer require kennedytedesco/validation:^5.0

Installation

composer require kennedytedesco/validation:^9.0

Supported rules (with examples)

$rules = [
    'cpf'               => ['cpf',],
    'cnpj'              => ['cnpj',],
    'cnh'               => ['cnh',],
    'minimumAge'        => ['minimumAge:20',],
    'callback'          => ['callback:is_int',],
    'charset'           => ['charset:ASCII',],
    'consonant'         => ['consonant',],
    'vowel'             => ['vowel',],
    'alnum'             => ['alnum:-',],
    'digit'             => ['digit',],
    'alpha'             => ['alpha',],
    'containsArray'     => ['contains:banana',],
    'contains'          => ['contains:banana',],
    'countryCode'       => ['countryCode',],
    'creditCard'        => ['digit', 'creditCard',],
    'domain'            => ['domain',],
    'directory'         => ['directory',],
    'fileExists'        => ['fileExists',],
    'isFile'            => ['file',],
    'endsWith'          => ['endsWith:banana',],
    'equals'            => ['equals:banana',],
    'even'              => ['even',],
    'floatVal'          => ['floatVal',],
    'float'             => ['floatVal',],
    'graph'             => ['graph',],
    'instance'          => ['instance:DateTime',],
    'int'               => ['int',],
    'json'              => ['json',],
    'leapDate'          => ['leapDate:Y-m-d',],
    'leapYear'          => ['leapYear',],
    'arrayVal'          => ['arrayVal',],
    'Arr'               => ['arrayVal',],
    'lowercase'         => ['lowercase',],
    'macAddress'        => ['macAddress',],
    'multiple'          => ['multiple:3',],
    'negative'          => ['negative',],
    'noWhitespace'      => ['noWhitespace',],
    'nullValue'         => ['nullValue',],
    'numeric'           => ['numeric',],
    'objectType'        => ['objectType',],
    'odd'               => ['odd',],
    'perfectSquare'     => ['perfectSquare',],
    'positive'          => ['positive',],
    'primeNumber'       => ['primeNumber',],
    'punct'             => ['punct',],
    'readable'          => ['readable',],
    'regex'             => ['regex:/5/',],
    'roman'             => ['roman',],
    'slug'              => ['slug',],
    'space'             => ['space:b',],
    'tld'               => ['tld',],
    'uppercase'         => ['uppercase',],
    'version'           => ['version',],
    'xdigit'            => ['xdigit',],
    'writable'          => ['writable',],
    'alwaysValid'       => ['alwaysValid',],
    'boolType'          => ['boolType',],
    'youtube'           => ['videoUrl:youtube',],
    'vimeo'             => ['videoUrl:vimeo',],
    'video1'            => ['videoUrl',],
    'video2'            => ['videoUrl',],
];

$data = [
    'cpf'               => '22205417118',
    'cnpj'              => '68518321000116',
    'cnh'               => '02650306461',
    'callback'          => 20,
    'charset'           => 'acucar',
    'consonant'         => 'dcfg',
    'vowel'             => 'aeiou',
    'alnum'             => 'banana-123 ',
    'digit'             => '120129  21212',
    'alpha'             => 'banana',
    'containsArray'     => ['www', 'banana', 'jfk', 'http',],
    'contains'          => 'www banana jfk http',
    'countryCode'       => 'BR',
    'creditCard'        => '5555666677778884',
    'domain'            => 'google.com.br',
    'directory'         => __DIR__,
    'fileExists'        => __FILE__,
    'file'              => __FILE__,
    'endsWith'          => 'pera banana',
    'equals'            => 'banana',
    'even'              => 8,
    'floatVal'          => 9.8,
    'graph'             => 'LKM@#$%4;',
    'instance'          => new \Datetime(),
    'int'               => 9,
    'json'              => '{"file":"laravel.php"}',
    'leapDate'          => '1988-02-29',
    'leapYear'          => '1988',
    'arrayVal'          => ['Brazil',],
    'lowercase'         => 'brazil',
    'macAddress'        => '00:11:22:33:44:55',
    'multiple'          => '9',
    'negative'          => '-10',
    'noWhitespace'      => 'laravelBrazil',
    'nullValue'         => null,
    'numeric'           => '179.9',
    'objectType'        => new \stdClass(),
    'odd'               => 3,
    'perfectSquare'     => 25,
    'positive'          => 1,
    'primeNumber'       => 7,
    'punct'             => '&,.;[]',
    'readable'          => __FILE__,
    'regex'             => '5',
    'roman'             => 'VI',
    'slug'              => 'laravel-brazil',
    'space'             => '              b      ',
    'tld'               => 'com',
    'uppercase'         => 'BRAZIL',
    'version'           => '1.0.0',
    'xdigit'            => 'abc123',
    'writable'          => __FILE__,
    'alwaysValid'       => '@#$_',
    'boolType'          => \is_int(2),
    'youtube'           => 'http://youtu.be/l2gLWaGatFA',
    'vimeo'             => 'http://vimeo.com/33677985',
    'video1'            => 'https://youtu.be/l2gLWaGatFA',
    'video2'            => 'https://vimeo.com/33677985',
];

$validator = \Validator::make($data, $rules);

if ($validator->passes()) {
    // Do something
}

For more validation rules

See all available rules here:

https://respect-validation.readthedocs.io/en/1.1/list-of-rules/

Repository of Respect Validation:

https://github.com/Respect/Validation

validation's People

Contributors

henriquemoody avatar icetee avatar kennedytedesco avatar phabloraylan avatar ricardogobbosouza avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

validation's Issues

composer update "Your requirements could not be resolved to an installable set of packages."

Hi,

when I try to install via composer update I get the following error-messages:

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for kennedytedesco/validation dev-master -> satisfiable by kennedytedesco/validation[dev-master].
    - kennedytedesco/validation dev-master requires respect/validation dev-develop -> no matching package found.

Potential causes:
 - A typo in the package name
 - The package is not available in a stable-enough version according to your minimum-stability setting
   see <https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion> for more details.

Read <http://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.

Great would be an update to.

"illuminate/support": "4.1.*",
"illuminate/validation": "4.1.*"

regards

Can each() be supported?

Being able to apply a set of rules to each element when the input to validate is an array, would be very useful. This would be a kind of nesting of validation rules, and I'm not sure how that would work with Laravel, since you would be talking more control of the flow of the validation rules and not just providing simple yes/no responses to single rules.

But I do need to ask ;-)

Any example would be for a multi-select list of countries. The countries field is submitted as an array, with each selected country an element of the array. Each of those submitted countries must be a valid country and not some injected value that an end-user hacker may be posting.

Extended validation triggered as fail even returning true

Hi,

I have some of my validation that use Validator::extend().
I debugged the extended Validator and resulted it return true as it pass the validation.
But using this package, it triggered ->passes() as fail and return message shown my extended validator
message.

I suspect its happen because some conflict with the package.
When I change back the ValidationServiceProvider back to Laravel, the validation pass.

Using Laravel Validation ServiceProvider
image

Using this package Validation ServiceProvider
image

Laravel 6 Support?

Hello, today Laravel 6 LTS was released, will it be supported/updated for this version? Thank you

Validator::extend => Última versão retornando sempre false

Cheguei nessa issue #10

@KennedyTedesco estou com o mesmo problema na última versão usando o Laravel 6. O que pode ser, teria algum jeito de contornar isso? O que fiz foi testar com ele instalado e depois removi, parece que realmente está havendo algum conflito. Já estou a algum tempo em cima disso e não consegui evoluir =/

Fiz esse código para testar e sempre retorna false com o seu pacote instalado. Não sei se foi mudado alguma coisa durante as versões...

Validator::extend('video_url', function($attribute, $url, $parameters) {
    return true;
});

Parece que quando usado o Validator::extend o código é ignorado.

Custom Attributes support

Hi,

Can you add custom attributes ?
Currently the constructor and service provider missing the last parameters for extending Laravel Validator.

Thanks

domain validation return invalid on valid domain

Hi,

I am using the domain validation rules and it return invalid for .store and probably many more weird TLD domain. I check Respect validation and it return false too, I need to disable the tld check to make it return true. But how do I add the parameters using this package ?

Laravel 7

Olá Kennedy,

Você vai adicionar suporte para o Laravel 7?

Mensagem quando cpf esta errado

Quando vou exibir a mensagem de erro para o cpf ou cnpj é exibido dessa forma:
validation.cpf

Tentei criar uma regra no arquivo validation.php para informar a mensagem correta mas não consegui, existe alguma forma de criar uma mensagem de validação melhor? como devo criar la no custom?

problem with codeception

Hello,

I'm using this awesome library and I find it very very useful. However I have an issue with the library and codeception. Codeception seems stupid and it can't find the validators for the custom rules. An example of an error is:

BadMethodCallException: Method [validateCharset] does not exist.

In the laravel app I don't have this problem anyway, so I think that is codeception the problem indeed.

I was wondering if anybody here had the same issue and how it's possible to fix it. Thanks in advance

Fix illuminate/support and validation versions for L4

Hello @KennedyTedesco ,

Your package allows the users to install version 1 on Laravel 5, the composer assumes version 1 when run:

composer require kennedytedesco/validation

(without the correct version)

You need to fix that:
https://github.com/KennedyTedesco/Validation/blob/v1.2.0/composer.json

 "require-dev": {
        "illuminate/support": ">=4.0.0",
        "illuminate/validation": ">=4.0.0"
    },   

to

 "require-dev": {
        "illuminate/support": "4.*",
        "illuminate/validation": "4.*"
    },   

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.