Skip to content

Commit

Permalink
feat: add ConvertEmptyStringsToNull and TrimStrings middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
albertcht committed Aug 27, 2024
1 parent ac7eb71 commit 1ff991a
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/Http/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ class Kernel extends HttpKernel
* @var array<int, class-string|string>
*/
protected array $middleware = [
// \App\Http\Middleware\TrimStrings::class
// \App\Http\Middleware\ConvertEmptyStringsToNull::class
];

/**
Expand Down
19 changes: 19 additions & 0 deletions app/Http/Middleware/ConvertEmptyStringsToNull.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

declare(strict_types=1);

namespace App\Http\Middleware;

use SwooleTW\Hyperf\Foundation\Http\Middleware\ConvertEmptyStringsToNull as Middleware;

class ConvertEmptyStringsToNull extends Middleware
{
/**
* The names of the attributes that should not be transformed to null.
*
* @var array<int, string>
*/
protected array $except = [
//
];
}
19 changes: 19 additions & 0 deletions app/Http/Middleware/TrimStrings.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

declare(strict_types=1);

namespace App\Http\Middleware;

use SwooleTW\Hyperf\Foundation\Http\Middleware\TrimStrings as Middleware;

class TrimStrings extends Middleware
{
/**
* The names of the attributes that should not be trimmed.
*
* @var array<int, string>
*/
protected array $except = [
//
];
}

0 comments on commit 1ff991a

Please sign in to comment.