|
|
|
@ -11,7 +11,7 @@ use IQBall\Core\Http\HttpResponse;
|
|
|
|
|
use IQBall\Core\Model\TeamModel;
|
|
|
|
|
use IQBall\Core\Validation\FieldValidationFail;
|
|
|
|
|
use IQBall\Core\Validation\ValidationFail;
|
|
|
|
|
use IQBall\Core\Validation\Validators;
|
|
|
|
|
use IQBall\Core\Validation\DefaultValidators;
|
|
|
|
|
|
|
|
|
|
class TeamController {
|
|
|
|
|
private TeamModel $model;
|
|
|
|
@ -48,10 +48,10 @@ class TeamController {
|
|
|
|
|
public function submitTeam(array $request, SessionHandle $session): HttpResponse {
|
|
|
|
|
$failures = [];
|
|
|
|
|
$request = HttpRequest::from($request, $failures, [
|
|
|
|
|
"name" => [Validators::lenBetween(1, 32), Validators::nameWithSpaces()],
|
|
|
|
|
"main_color" => [Validators::hexColor()],
|
|
|
|
|
"second_color" => [Validators::hexColor()],
|
|
|
|
|
"picture" => [Validators::isURL()],
|
|
|
|
|
"name" => [DefaultValidators::lenBetween(1, 32), DefaultValidators::nameWithSpaces()],
|
|
|
|
|
"main_color" => [DefaultValidators::hexColor()],
|
|
|
|
|
"second_color" => [DefaultValidators::hexColor()],
|
|
|
|
|
"picture" => [DefaultValidators::isURL()],
|
|
|
|
|
]);
|
|
|
|
|
if (!empty($failures)) {
|
|
|
|
|
$badFields = [];
|
|
|
|
@ -84,7 +84,7 @@ class TeamController {
|
|
|
|
|
public function listTeamByName(array $request, SessionHandle $session): HttpResponse {
|
|
|
|
|
$errors = [];
|
|
|
|
|
$request = HttpRequest::from($request, $errors, [
|
|
|
|
|
"name" => [Validators::lenBetween(1, 32), Validators::nameWithSpaces()],
|
|
|
|
|
"name" => [DefaultValidators::lenBetween(1, 32), DefaultValidators::nameWithSpaces()],
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
if (!empty($errors) && $errors[0] instanceof FieldValidationFail) {
|
|
|
|
@ -166,7 +166,7 @@ class TeamController {
|
|
|
|
|
], HttpCodes::FORBIDDEN);
|
|
|
|
|
}
|
|
|
|
|
$request = HttpRequest::from($request, $errors, [
|
|
|
|
|
"email" => [Validators::email(), Validators::lenBetween(5, 256)],
|
|
|
|
|
"email" => [DefaultValidators::email(), DefaultValidators::lenBetween(5, 256)],
|
|
|
|
|
]);
|
|
|
|
|
if(!empty($errors)) {
|
|
|
|
|
return ViewHttpResponse::twig('add_member.html.twig', ['badEmail' => true,'idTeam' => $idTeam]);
|
|
|
|
@ -226,10 +226,10 @@ class TeamController {
|
|
|
|
|
}
|
|
|
|
|
$failures = [];
|
|
|
|
|
$request = HttpRequest::from($request, $failures, [
|
|
|
|
|
"name" => [Validators::lenBetween(1, 32), Validators::nameWithSpaces()],
|
|
|
|
|
"main_color" => [Validators::hexColor()],
|
|
|
|
|
"second_color" => [Validators::hexColor()],
|
|
|
|
|
"picture" => [Validators::isURL()],
|
|
|
|
|
"name" => [DefaultValidators::lenBetween(1, 32), DefaultValidators::nameWithSpaces()],
|
|
|
|
|
"main_color" => [DefaultValidators::hexColor()],
|
|
|
|
|
"second_color" => [DefaultValidators::hexColor()],
|
|
|
|
|
"picture" => [DefaultValidators::isURL()],
|
|
|
|
|
]);
|
|
|
|
|
if (!empty($failures)) {
|
|
|
|
|
$badFields = [];
|
|
|
|
|