for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace App\Validation;
use App\Message\UserMessage;
/**
* User Validation.
*/
abstract class UserValidation extends BaseValidation
{
* Validate and sanitize input data when create new user.
*
* @param array $input
* @return string
* @throws \Exception
public static function validateInputOnCreateUser($input)
if (!isset($input['name'])) {
throw new \Exception(UserMessage::USER_NAME_REQUIRED, 400);
}
$name = self::validateName($input['name']);
$email = null;
if (isset($input['email'])) {
$email = self::validateEmail($input['email']);
return ['name' => $name, 'email' => $email];
* Validate and sanitize input data when update a user.
* @param object $user
public static function validateInputOnUpdateUser($input, $user)
if (!isset($input['name']) && !isset($input['email'])) {
throw new \Exception(UserMessage::USER_INFO_REQUIRED, 400);
$name = $user->name;
if (isset($input['name'])) {
$email = $user->email;