Questions tagged [respect-validation]

A validation engine created for PHP, by Alexandre Gomes Gaigalas ( Copyright (c) 2009-2015). PHP 5.4+ or HHVM 3.3+ are required for using it.

The creators call it "The most awesome validation engine ever created for PHP."

  • Fluent/Chained builders like:

    v::numeric()->positive()->between(1, 256)->validate($myNumber) 
    
  • Informative, awesome exceptions;

  • More than 30 fully tested validators.

Source:http://documentup.com/Respect/Validation/#

57 questions
22
votes
8 answers

Why my autoload.php of composer doesn't work?

I have a project, I use Composer and i import many thing by it... i require the autoload.php in my index (the root of project) and istead Slim, Mongo, Twig work very well. But when I call a class of Respect/Validation it doens't work; if I simply…
Matteo Calò
  • 351
  • 1
  • 2
  • 14
8
votes
1 answer

Respect validation multiple custom error messages

How do I have multiple custom errors messages with Respect Validation. I have some input that I want to validate against multiple validators. And I want a custom error message for each validation. This is what I tried: try { …
Petah
  • 42,792
  • 26
  • 149
  • 203
6
votes
8 answers

Unreasonable Errors on PHP Slim 3 Middleware

I am trying to use the ValidationErrorsMiddleware.php class as a middleware, so I added the following code to my bootstrap/app.php: $app->add(new App\Middleware\ValidationErrorsMiddleware($container)); I got the following errors after the above…
DarkSpirit
  • 197
  • 1
  • 2
  • 6
4
votes
2 answers

Using Respect/Validation in another language

I want to use the Respect/Validation library in PHP. I know how to use it but currently I'm using it in a project in German language and of course, I also want the error messages in German. For language translation, there is a section in the…
deflox
  • 93
  • 3
  • 8
3
votes
2 answers

How can i validate file upload using Respect\Validation library?

I use Slim 3 Framework on my project, and i have a form with 3 inputs : 'file', 'name', 'firstname'. Assuming that $request has the data inputs of my form, to get the uploaded file, i use this code $files = $request->getUploadedFiles(); if…
user9161685
3
votes
2 answers

Respect Validation Optional Key

Sometimes users can send some missing key/value pairs. So in that situation I need to validate optional keys if they exists. User biography is an optional field. If user leaves it empty I don't want it to be posted. v::key('biography',…
RockOnGom
  • 3,343
  • 5
  • 31
  • 51
3
votes
1 answer

How can I add a custom Validator to Respect's Validation library

The awesome Respect Validation library comes with lots of built-in validators, like string(), alpha(), et cetera. I want to add self-defined validators to the library, eg., I want to be able to do this: Validator::myCustomValidator()->assert( $input…
Wilbo Baggins
  • 2,592
  • 2
  • 24
  • 37
3
votes
1 answer

Respect validation find messages for specific key

How can I get a custom message for a specific key of my validation? For example this: try { Respect\Validation\Validator::create() ->key('foo', v::length(20)) ->key('bar', v::max(5)) ->assert([ 'foo' =>…
Petah
  • 42,792
  • 26
  • 149
  • 203
3
votes
2 answers

How to get Validation Error Messages from Respect\Validation?

I have been using Respect Validation for form Validation $app->post('/', function () use ($app) { $validator = v::key('name', v::string()->notEmpty()) ->key('email', v::email()->notEmpty()) …
Teej
  • 12,352
  • 9
  • 68
  • 92
2
votes
1 answer

Respect Validation php slim custom messages

I've read the docs and I wonder if its possible to make custom messages based on rules AND attribute, for example I have the following code $casoValidator = …
JoseCarlosPB
  • 785
  • 2
  • 10
  • 24
2
votes
1 answer

Respect/validation: Mandatory keys inside a keySet, how can I get a missing key name in error messages?

I'm using Respect/Validation and I created the following rules to validate and associative array: Validator::keySet( Validator::key( // mandatory, if included type: string, values: not null, not empty 'name', …
Averias
  • 751
  • 10
  • 19
2
votes
1 answer

Validating sub-arrays with Respect/Validation?

I've used Respect/Validation successfully for my general concern. But now I'm validating some form Input where the user can check multiple checkboxes and the data is send with an array. The form looks something like this:
pmayer
  • 341
  • 2
  • 13
2
votes
1 answer

Get name of error attributes from Respect/Validation

I'm using Respect validation library and when I try to validate my input date: v::key('email', v::notEmpty()->Email()->setName('email')) It returns the right message like: "email must be valid email" But I cannot retrieve name of the attribute…
Einsamer
  • 892
  • 2
  • 12
  • 31
2
votes
3 answers

php respect validation just validate if not empty

I'm using php respect validation. https://github.com/Respect/Validation class UserValidator implements iValidator { public function validate($object) { $userValidator = v::attribute('email', v::email()) …
mhndev
  • 1,563
  • 2
  • 22
  • 43
1
vote
2 answers

Respect\Validation custom Rule with PDO?

I am learning Slim Framework v4 and decided to use Respect\Validation to validate inputted data and have hit a snag where I do not know how to inject the PDO into my custom rule I created. The idea is to validate some inputs against the database if…
Kristjan O.
  • 583
  • 1
  • 4
  • 24
1
2 3 4