The documentation https://symfony.com/doc/4.4/reference/constraints/Length.html#normalizer states that
This option allows to define the PHP callable applied to the given value before checking if it is valid.
For example, you may want to pass the 'trim' string to apply the trim PHP function in order to ignore leading and trailing whitespace during validation.**
I was able to call trim as in the example, and even the static function of the class:
class PersonDto
{
/**
* @Assert\Length(min="1", max="255", allowEmptyString=false, normalizer="App\Dto\PersonDto::foo")
*/
private ?string $name = null;
public static function foo($value) {
$value = 'the text has been replaced';
return $value;
}
...
}
But for some reason the returned value does not change the value. What am I doing wrong, or how do I write a callback function into "normalizer" option