c117367974
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?
26 lines
602 B
PHP
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);
|
|
}
|
|
}
|