szurubooru/src/FormData/RegistrationFormData.php
Marcin Kurczewski c117367974 Added IValidatable; moved validation to FormData
I still struggle to find out how to deal with arguments like
$userNameOrEmail. Should I trim() them in controllers, or in service?
If I do it in service, shouldn't all of such validation belong in there?
2014-10-18 18:48:19 +02:00

26 lines
602 B
PHP

<?php
namespace Szurubooru\FormData;
class RegistrationFormData implements \Szurubooru\IValidatable
{
public $userName;
public $password;
public $email;
public function __construct($inputReader = null)
{
if ($inputReader !== null)
{
$this->userName = trim($inputReader->userName);
$this->password = $inputReader->password;
$this->email = trim($inputReader->email);
}
}
public function validate(\Szurubooru\Validator $validator)
{
$validator->validateUserName($this->userName);
$validator->validatePassword($this->password);
$validator->validateEmail($this->email);
}
}