Add test for email validation
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
This commit is contained in:
parent
5e49e5bd59
commit
56e0223492
|
@ -17,6 +17,6 @@ class EmailField extends TextField
|
||||||
*/
|
*/
|
||||||
public function getRegistrationRules(Form $form): array
|
public function getRegistrationRules(Form $form): array
|
||||||
{
|
{
|
||||||
return [$this->key => $this->required ? ['required', 'string', 'email'] : ['nullable', 'string']];
|
return [$this->key => $this->required ? ['required', 'string', 'email'] : ['nullable', 'email', 'string']];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -254,6 +254,18 @@ class FormRegisterActionTest extends FormTestCase
|
||||||
['vorname' => 5],
|
['vorname' => 5],
|
||||||
['vorname' => 'Vorname der Mutter muss ein String sein.']
|
['vorname' => 'Vorname der Mutter muss ein String sein.']
|
||||||
];
|
];
|
||||||
|
|
||||||
|
yield [
|
||||||
|
$this->emailField('email')->name('Mail')->required(true),
|
||||||
|
['email' => 'alaaa'],
|
||||||
|
['email' => 'Mail muss eine gültige E-Mail-Adresse sein.']
|
||||||
|
];
|
||||||
|
|
||||||
|
yield [
|
||||||
|
$this->emailField('email')->name('Mail')->required(false),
|
||||||
|
['email' => 'alaaa'],
|
||||||
|
['email' => 'Mail muss eine gültige E-Mail-Adresse sein.']
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testItValidatesGroupFieldWithParentGroupField(): void
|
public function testItValidatesGroupFieldWithParentGroupField(): void
|
||||||
|
|
|
@ -6,6 +6,7 @@ use App\Form\Fields\CheckboxesField;
|
||||||
use App\Form\Fields\CheckboxField;
|
use App\Form\Fields\CheckboxField;
|
||||||
use App\Form\Fields\DateField;
|
use App\Form\Fields\DateField;
|
||||||
use App\Form\Fields\DropdownField;
|
use App\Form\Fields\DropdownField;
|
||||||
|
use App\Form\Fields\EmailField;
|
||||||
use App\Form\Fields\GroupField;
|
use App\Form\Fields\GroupField;
|
||||||
use App\Form\Fields\NamiField;
|
use App\Form\Fields\NamiField;
|
||||||
use App\Form\Fields\RadioField;
|
use App\Form\Fields\RadioField;
|
||||||
|
@ -26,6 +27,11 @@ trait CreatesFormFields
|
||||||
return FormtemplateFieldRequest::type(TextField::class)->key($key ?? $this->randomKey());
|
return FormtemplateFieldRequest::type(TextField::class)->key($key ?? $this->randomKey());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function emailField(?string $key = null): FormtemplateFieldRequest
|
||||||
|
{
|
||||||
|
return FormtemplateFieldRequest::type(EmailField::class)->key($key ?? $this->randomKey());
|
||||||
|
}
|
||||||
|
|
||||||
protected function checkboxesField(?string $key = null): FormtemplateFieldRequest
|
protected function checkboxesField(?string $key = null): FormtemplateFieldRequest
|
||||||
{
|
{
|
||||||
return FormtemplateFieldRequest::type(CheckboxesField::class)->key($key ?? $this->randomKey());
|
return FormtemplateFieldRequest::type(CheckboxesField::class)->key($key ?? $this->randomKey());
|
||||||
|
@ -63,6 +69,6 @@ trait CreatesFormFields
|
||||||
|
|
||||||
protected function randomKey(): string
|
protected function randomKey(): string
|
||||||
{
|
{
|
||||||
return preg_replace('/[\-0-9]/', '', str()->uuid().str()->uuid());
|
return preg_replace('/[\-0-9]/', '', str()->uuid() . str()->uuid());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue