Validating files


trait which provides a convenient method to validate incoming HTTP request with a variety of powerful validation rules.

To learn about Laravel's powerful validation features, let's look at a complete example of validating a form and displaying the error messages back to the user.

This section explains how to use the File Validator feature.

validating files-67validating files-19

In the case of a traditional HTTP request, a redirect response will be generated, while a JSON response will be sent for AJAX requests. Again, if the validation fails, the proper response will automatically be generated.

If the validation passes, our controller will continue executing normally.

Again, notice that we did not have to explicitly bind the error messages to the view in our Forcing A Unique Rule To Ignore A Given ID: Sometimes, you may wish to ignore a given ID during the unique check.

For example, consider an "update profile" screen that includes the user's name, e-mail address, and location.

If the values do not match, then the block is corrupt.