symfony プロジェクトで MinLength バリデーターを使用しようとしています。
これが私がそれを使用している方法です:
use Symfony\Component\Validator\Constraints\MinLength;
class RegisterNewUser
{
protected $password;
public static function loadValidatorMetadata(ClassMetadata $metadata)
{
if( isset( $metadata->properties["password"] ) )
unset($metadata->properties["password"]);
$password_blank = new NotBlank();
$password_min = new MinLength(5);
$password_blank->message = "The password should not be blank";
$password_min->message = "The password is too short. It should have {{ limit }} characters or more";
$metadata->addPropertyConstraint('password', $password_blank);
$metadata->addPropertyConstraint('password', $password_min );
}
}
私が得ているエラーメッセージは次のとおりです。
FatalErrorException: エラー: クラス 'Symfony\Component\Validator\Constraints\MinLength' が見つかりません...