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.
55
questions
0
votes
1answer
43 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 $...
0
votes
0answers
47 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):
...
0
votes
2answers
66 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&...
1
vote
2answers
388 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 ...
0
votes
1answer
200 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:
mymail1@mydomain.com; mymail2@mydomain.com,mymail3@mydomain.com ;mymail4@mydomain.com;
...
2
votes
1answer
236 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::...
-2
votes
1answer
32 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('alexandre@gaigalas.net'); // true
mais ...
0
votes
1answer
148 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}$/"),
'...
0
votes
1answer
260 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 ...
0
votes
1answer
642 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 ...
0
votes
0answers
174 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.
$...
1
vote
0answers
543 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 ...
1
vote
1answer
2k 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');...
0
votes
1answer
330 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')
...
0
votes
1answer
555 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 ...
0
votes
1answer
300 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 ...
0
votes
1answer
866 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.
...
3
votes
2answers
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
$...
0
votes
0answers
55 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::...
3
votes
2answers
1k 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 ...
0
votes
1answer
111 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) {
...
1
vote
1answer
368 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-...
0
votes
1answer
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 ...
1
vote
2answers
848 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:...
-1
votes
1answer
190 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 '...
0
votes
1answer
929 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) {
$...
0
votes
1answer
283 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()->...
0
votes
2answers
967 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 ...
0
votes
0answers
796 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 ...
2
votes
1answer
514 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, ...
0
votes
1answer
659 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 ...
0
votes
1answer
43 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 ...
1
vote
1answer
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 ...
0
votes
1answer
680 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 ...
0
votes
1answer
546 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 $...
2
votes
1answer
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 ...
0
votes
1answer
40 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. ...
0
votes
1answer
1k 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\...
2
votes
1answer
352 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 ...
6
votes
8answers
11k 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($...
0
votes
1answer
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 ...
4
votes
2answers
2k 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 ...
2
votes
3answers
4k 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(...
1
vote
3answers
381 views
Month validation with “Respect Validation”
I am trying to write validation rule for credit card month and I am using Respect Validation library for this.
v::string()->date('m')->validate('02');
Result is FALSE but it must be TRUE ...
0
votes
1answer
915 views
Validate PHP Array Key>Value
Having an array like [1]
$arr = array(
array(
"ignoreMe" => "123",
"checkMe" => "value",
),
array(
"ignoreMe" => "456",
...
3
votes
1answer
2k views
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 ...
1
vote
1answer
1k views
PHP respect validation fatal error Class 'Respect\Validation\Validator' not found
I downloaded Respect/validation zip file from here https://github.com/Respect/Validation/archive/master.zip
I unzipped the archive and added a php file named phpinfo.php @ /Validation-master/...
0
votes
0answers
64 views
Respect Validation and reset connection
I'm using the Respect\Validation library and I cannot get meaningful exceptions to print out apart from the first message.
This code gives me an error:
try {
$foo = \Respect\Validation\Validator:...
0
votes
1answer
342 views
idiorm with respect validation attribute method always fails
Has anyone been able to succssesfuly use the Respect Validation library with an Idiorm result object? It appears as though Respect Validation will only work on vanilla, not sure if that's the correct ...
0
votes
1answer
1k views
Respect/Validation email() don't work
I use Respect/Validation and when I use email()...the problem is:
if I validate a string: validator::email()->validate('hello@helloworld.com'); it work!
if I validate a variable: validator::email(...