I’m creating an authentication system that uses Slim 3 PHP on the back-end and Angular on the front-end. So far I’ve managed to have it so a user can fill out a form on the frontend and send a post …
Tag: validation
Laravel | Special validation of a lot of data
Validation of a data (1 – 10000 possible rows) So to give some context I am creating a web based mapping interface to map other data formats to our format. Problem Taking an array of data and an array …
How beautifully to stop object property validation on the first error in Symfony?
I have the following code: class User { /** * @AssertType(type=”string”) * @AssertNotBlank() * @AssertEmail() * @AssertLength(max=255) */ public $email; } This object is filled from an API call. When validation takes place and property is filled with array value instead of string then NotBlank, Em…
Laravel validation always returns 200 OK from API
I want to separate my validator with my controller, but API always responds with a 200 OK in Postman. Request validation: class PostRequest extends FormRequest { use Types; public function …
$_FILES key used for building a PSR-7 uploaded files list
The short version: When a user uploads a file using a form, an array is saved in the global variable $_FILES. For example, when using: the global …
Laravel unique validation on multiple columns
I have 2 columns in table servers. I have columns ip and hostname. I have validation: This working only for column ip. But how to do that it would work and for column hostname? I want validate data.ip with columns ip and hostname. Because can be duplicates in columns ip and hostname, when user write ip. Answe…
Make Laravel’s notIn validation rule case insensitive
I am storing an array of strings in my database (db column type is JSON). There is a form that allows users to add a value to this array. I want to make sure there are no duplicates in this array. The notIn validation rule appears be the simplest solution to prevent duplicates but it is case sensitive. So whe…
Laravel: How to use the ignore rule in Form Request Validation
Laravel has a ‘unique’ rule with an ‘except’ clause. From the validation documentation, it takes this form: My application has a ‘shop’ entity. When the user updates the shop’s profile, I have a Form Request, with a validation rule configured as follows: (The primary …
Custom error message for Laravel validation rule: Dimensions
I’m trying to validate an image upload that looks like the following: when the selected image too small then laravel shows error: I think that message is not saying specifically that in which dimension the image small, eg: width or height. I’m expecting error message like: The Admin Image width ca…
Laravel validate at least one item in a form array
I have a form with a series of numbers in an array: I would like to validate that there is at least one of those input fields that has a value. I tried the following in my OrderCreateRequest, yet the test is passing: Am I missing something? Answer I think you need a custom validation rule like the following b…