Laravel: Sanitize Request Input by using Sanitizing Middleware

2020-10-24 22:50:46 Ashoak Laravel

How to sanitize input data in declarative manner in Laravel

Laravel 5 contains a couples of middlewares. In Laravel 5.4 two new middlewares are introduced for Sanitizing inputs in requests. They are

  • TrimStrings
  • ConvertEmptyStringsToNull

Both middlewares are very usefull in order to sanitize requests input.

TrimStrings Middleware: This middleware is used to remove all white spaces of inputs of request.

ConvertEmptyStringsToNull: This middleware convert all blanks requests inputs to null.

This post is submitted by one of our members. You may submit a new post here.

Related Tricks