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.

Filter by
Sorted by
Tagged with
0 votes
0 answers
12 views

Respect validator optional and assert

The "NestedValidationException" does not work in this form. Is there a solution for this? try { $validator = new Rules\Optional(new Rules\Digit()); $validator->assert($data); ...
Tibi's user avatar
  • 163
0 votes
0 answers
71 views

Validate request data via Respect/validation

I'm using Slim PHP Framework and I need to validate POST request payload and I'm using this PHP package Respect-Validation. The idea that I have array ob objects and I need to validate the data inside ...
Bebo's user avatar
  • 7
0 votes
1 answer
276 views

Validate JSON Request with Respect/Validation

I have a JSON request which exactly follow the rules, but the result keeps failing. Let's say I have a request like this: { "name" : "Angela White", "dateOfBirth" : &...
aew09's user avatar
  • 1
0 votes
1 answer
287 views

Respect/Validation - Add more rules if some condition is met

I try to find the proper logic to add some more rules on a previous rules set (that was already defined) if some condition is met. $form_validation_rules = v::key('password_current', v::length(6)) -&...
punctweb's user avatar
0 votes
1 answer
125 views

respect validation translation issue

I have been using respect validation 1.1 and I used below code for translating messages. foreach ($rules as $field => $rule) { try { $localeField = $translator->trans($field); ...
Miky's user avatar
  • 11
0 votes
0 answers
278 views

Dependent parameters with Respect\Validation

I'm making input validation in my controllers using Respect\Validation library. I have two parameters that are optional but dependent, if the "a" parameter is present then I also need the &...
Xiidref's user avatar
  • 1,466
0 votes
1 answer
376 views

Validating array of relative arrays(maps) with Respect/Validation?

I'm trying to validate to following json: { "variants": [ { "variant_code": "1", "price": 12, "discount&...
Francesc Arolas's user avatar
1 vote
1 answer
946 views

Respect\Validation with slim4

I'm trying to follow this tutorial for add post params validation: https://odan.github.io/2020/10/08/slim4-respect-validation.html I add a lib, and use it: private function validateProperty(array $...
Phyron's user avatar
  • 613
0 votes
0 answers
272 views

PHP Respect Validation password confirmation

I used slim 3 framework with davidepastore/slim-validation to validate my data. davidepastore/slim-validation itself uses Respect validation rules. I used validation in middleware (in router file): ...
Milito's user avatar
  • 1
0 votes
2 answers
172 views

How to access a json child in php respect validation?

I'm trying to validate the following json file but I can't find the way to access the "Address" child, how should I do it? Everything goes fine until it tries to access the "address&...
Fran's user avatar
  • 51
1 vote
2 answers
861 views

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 ...
Kristjan O.'s user avatar
0 votes
1 answer
383 views

How to validate a email list using Respect Validation

I'm using Respect Validation classes and I want to validate a list of email separated by , or ; and spaces like: [email protected]; [email protected],[email protected] ;[email protected]; ...
Tobia's user avatar
  • 9,305
2 votes
1 answer
495 views

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 = Validator::attribute('nombre',Validator::...
JoseCarlosPB's user avatar
-2 votes
1 answer
60 views

Respect Validation Rule email() Validates an email address ne fonctionne pas

j'utilise la librairie respect\validation pour checker l'email() https://respect-validation.readthedocs.io/en/latest/rules/Email/ v::email()->validate('[email protected]'); // true mais ...
Dyyyy's user avatar
  • 17
0 votes
1 answer
430 views

How to add Respect Validation on child Object which is Optional

In Slim3 framework's Respect Validation, I am trying to add validation on child object. $childObjValidationArr = array( 'param1' => v::regex("/^[A-Za-z0-9]{1}[A-Za-z0-9.$#-@]{1,19}$/"), '...
Anup B's user avatar
  • 87
0 votes
1 answer
568 views

Respect Validating optional input array for specific fields

I have a registration input that can be used by a consumer or a fleet consumer. Depending on what they are, depends on if they send extra details about their fleet or not. A regular consumer will just ...
Phil's user avatar
  • 83
0 votes
1 answer
2k views

Respect validation not able to validate array items

I am using respect built in validation from this source in my php application "https://respect-validation.readthedocs.io/en/1.1/rules/Each/". I am passing data via ajax call to php application code ...
Nida Amin's user avatar
  • 745
0 votes
1 answer
399 views

Unable to catch exception from assert method using Respect Validation

I'm using Respect Validation to attempt to validate data sent via a POST request. In doing so I discovered an issue where an exception in the Respect Validation library is not being caught. $...
BugHunterUK's user avatar
  • 8,446
1 vote
0 answers
856 views

Password validation with Respect Validation

I've currently got a regular expression set up for validating my passwords: /^(?=.*[A-Z])(?=.*[a-z])(?=.*\d)(?=.*\W).{6,}$/ This checks for at least 1 uppercase and lowercase character, 1 digit, 1 ...
no.'s user avatar
  • 2,356
4 votes
1 answer
7k views

PHPStan throws undefined static method when using custom rules in Respect/Validation

I'm using Respect/Validation class and I have custom rule CustomRule() which works fine: use Respect\Validation\Validator as v; // ... 'email' => v::CustomRule()->email()->setName('email');...
IMB's user avatar
  • 15.4k
0 votes
1 answer
554 views

Multiple rules/error messages inside a custom rule in Respect\Validation?

Say you have a custom rule like this: <?php class CheckFoo extends \Respect\Validation\Rules\AbstractRule { public function validate($input) { if ($input == 'foo') ...
IMB's user avatar
  • 15.4k
0 votes
1 answer
880 views

File/Image validation in slim framework Request validation

I wanted to validate the uploaded image with following parameters like size should not be greater than 100KB, file can be of types [jpg,png,gif]. Please help me to write validation rules for this in ...
Saurabh Sharma's user avatar
0 votes
1 answer
586 views

Respect Validation: What's the right validation rule when a form has several fields with the same name?

I have a form that has only fields: question choice Choice is an array because a question has more than answers and the user can add as many as I need. I just need to validate that these aren't ...
ffuentes's user avatar
  • 1,102
0 votes
1 answer
1k views

Translating or writing custom messages on Respect/Validation

I'm using Respect to validate some forms in a project but this project is in Spanish and I don't understand how messages work after spending a long time reading the documentation and even its code. ...
ffuentes's user avatar
  • 1,102
3 votes
2 answers
1k views

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 $...
user avatar
0 votes
0 answers
72 views

Respect Validation - Usage Not & One Of

The user enters his/her business name. Every this is allowed except special characters. Instead of a white list I would want to main a blacklist. Here's my piece of code 'nameofbusiness' => v::...
Indark's user avatar
  • 322
3 votes
2 answers
2k views

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 ...
RockOnGom's user avatar
  • 3,933
0 votes
1 answer
162 views

Dynamically assign validation parameters in Respect Validations

My initial question was how to do dynamic chaining of Respect validations. My implementation was like following, $validator = v::notEmpty(); foreach ($validations as $validation) { ...
Yasiru Nilan's user avatar
1 vote
1 answer
833 views

snyk dependencies download issue

I am trying to install the dependencies of respec project of w3c and I am getting this error npm WARN prepublish-on-install As of npm@5, `prepublish` scripts are deprecated. npm WARN prepublish-on-...
Ayush Mahajan's user avatar
0 votes
1 answer
1k views

How to custom error messages

Hi everyone and thanks for your help. I'll like to custom error messages for validation and eventually to create different version for each language, it's possible ? Here my code in his actually ...
Rifton007's user avatar
  • 291
1 vote
2 answers
1k views

Respect Validation for two fields

I need to validate form data with Respect. At least one of these fields must have a value: $vfname and $vlname. After some trial and error, I found that I can concatenate and test with notEmpty(): v:...
WillardSolutions's user avatar
-1 votes
1 answer
245 views

Respect validation for Select

I'm using Respect validation for my PHP form. It works fine for all elements but not sure which validation rule to use for the country select element. The default value (when the select box displays '...
cesarcarlos's user avatar
  • 1,303
0 votes
1 answer
1k views

How to change the default message in Respect Validation?

I use Respect Validation for password matches on a Slim app: class PasswordController extends Controller { ; ; public function postChangePassword($request, $response) { $...
blsn's user avatar
  • 1,083
0 votes
1 answer
489 views

Respect\Validation - validate string if not empty, otherwise return true

I'm using Respect\Validation for validate fields. Some of my fields are not mandatory, as the phone number, but if they are not empty they must be validated. Following my current code: v::Phone()->...
Bob's user avatar
  • 159
0 votes
2 answers
1k views

Slim Application Error: Respect\Validation\Validator

I get this error when trying to Validate my OrderForm.php. If someone followed Codecourse Shopping Cart Tutorial you may know why I get this error. Here is my code in some of my files that I think is ...
Jonathan Thunberg's user avatar
1 vote
0 answers
873 views

Validate JSON array with Respect Validation

I have the following JSON: { "articles":[ {"amount": 3, "vat": 19}, {"amount": 2, "vat": 7} ] } I want to validate that articles is an array and has the keys amount as a ...
Florian Sauerwein's user avatar
2 votes
1 answer
805 views

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, ...
Averias's user avatar
  • 941
0 votes
1 answer
857 views

Respect\Validation\Validator - using an array while catching errors

I am attempting to catch errors utilizing the Respect\Validation\Validator opensource PHP class. I used their example to create an array of checks. Although that seems to work ok, I then attempted ...
Shackrock's user avatar
  • 4,621
0 votes
1 answer
79 views

Php Respect\Validation libary exceptions shows errors but validate method returns true

im using https://github.com/Respect/Validation for validation. the package looked verry good so now i wanted to try it. I wanted to add some validation rules to a (decoded) jtw token, wich is a php ...
Reza's user avatar
  • 880
1 vote
1 answer
1k views

How to validate $_FILES using Respect Validation library

I'm using Respect Validation to attempt to validate a file upload. The problem I'm having is the validation always fails, even though the correct image has been uploaded. Here's my code: public ...
BugHunterUK's user avatar
  • 8,446
0 votes
1 answer
785 views

Respect validation custom rule errors on exception

I made an custom rule that checks if the given value equals the password of the user. It works but when i give an wrong password it doesn't display my custom exception message. instead it has an fatal ...
Bart Kalkman's user avatar
1 vote
1 answer
793 views

Respect Validation - Returning a single error

I'm using Respect Validation. Is it possible to return a single error instead of a bag of errors? Current I can get the first error using the following: public function checkUsername(Request $...
BugHunterUK's user avatar
  • 8,446
2 votes
1 answer
3k views

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 ...
pmayer's user avatar
  • 341
0 votes
1 answer
44 views

PHP Respect Validation Pull Request Fails Travis, Why?

I have updated the grammar in PHP's Respect Validation, but the Travis CI fails each time, even though I have only deleted a few chars using the Github editor, then submitted changes as Pull Request. ...
Ian N's user avatar
  • 55
0 votes
1 answer
2k views

Class validator not found in respect validation Lib

I'm new in composer but I could get vendor, composer.lock and composer.json from cmd then I paste them to my project without Validation_Master folder. My project Path: C:\wamp64\www\php Projects\...
pedram64's user avatar
2 votes
1 answer
439 views

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 ...
Einsamer's user avatar
  • 1,069
6 votes
8 answers
13k views

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($...
DarkSpirit's user avatar
0 votes
1 answer
1k views

Slim3 right way to set errors and check is user logged in

I'm a new user of Slim framework, I've a simple Slim 3 application, with sign in and sign up validation. But I'm not really sure if this is the right/best way to set errors and check if user is logged ...
Yassine Addi's user avatar
5 votes
2 answers
3k views

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 ...
deflox's user avatar
  • 103
2 votes
3 answers
5k views

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(...
Majid Abdolhosseini's user avatar