EmptyStringToNull
EmptyStringToNull - Set null if value is empty string.
EmptyStringToNull only works with string
, any other type is ignored.
Basic usage
use Jawira\Sanitizer\Filters as Sanitizer;
class Article {
#[Sanitizer\EmptyStringToNull]
public ?string $category;
}
Parameters
No parameters.
Examples
Set null if value is empty string.
use Jawira\Sanitizer\Filters as Sanitizer;
class User {
#[Sanitizer\EmptyStringToNull]
public ?string $name;
}
"John" → "John"
" " → " "
"" → null
See also
Trim - Strip whitespace (or other characters) from the beginning and end of a string.