Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Highlight the problem. #1

Open
wants to merge 1 commit into
base: validation
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/AppBundle/Form/UserType.php
Expand Up @@ -41,6 +41,14 @@ public function buildForm(FormBuilderInterface $builder, array $options)
]),
],
])
->add('text', TextType::class, [
'constraints' => [
new Length([
'min' => 3,
'max' => 25,
]),
],
])
)
;
}
Expand Down
5 changes: 5 additions & 0 deletions src/AppBundle/Resources/config/validation.yml
Expand Up @@ -15,3 +15,8 @@ AppBundle\Entity\Category:
min: 3
max: 25
groups: [ info ]
text:
- Optional:
- Length:
min: 3
max: 25
17 changes: 17 additions & 0 deletions src/AppBundle/Tests/Controller/CategoryTest.php
Expand Up @@ -37,6 +37,7 @@ public function getValidCategoryDataProvider()
'info' => [
'id' => 100500,
'title' => 'Some info title',
'text' => 'Some text',
],
],
],
Expand Down Expand Up @@ -70,6 +71,7 @@ public function getInvalidCategoryDataProvider()
'info' => [
'id' => 100500,
'title' => 'Some info title',
'text' => 'Some text',
],
],
'This value should not be blank.',
Expand All @@ -82,6 +84,7 @@ public function getInvalidCategoryDataProvider()
'info' => [
'id' => 100500,
'title' => 'Some info title',
'text' => 'Some text',
],
],
'This value should not be blank.',
Expand All @@ -94,6 +97,7 @@ public function getInvalidCategoryDataProvider()
'info' => [
'id' => 100500,
'title' => 'Some info title',
'text' => 'Some text',
],
],
'This value should not be blank.' . PHP_EOL . 'This value should not be blank.',
Expand All @@ -111,6 +115,19 @@ public function getInvalidCategoryDataProvider()
'This value is too short. It should have 3 characters or more.',
400,
],
'category:invalid_info:short_title_with_some_text' => [
[
'name' => 'Some category name',
'modifier' => 'Some modifier',
'info' => [
'id' => 100500,
'title' => '1',
'text' => 'Some text',
],
],
'This value is too short. It should have 3 characters or more.',
400,
],
];
}
}
17 changes: 17 additions & 0 deletions src/AppBundle/Tests/Controller/UserTest.php
Expand Up @@ -31,6 +31,7 @@ public function getValidUserDataProvider()
'info' => [
'id' => 100500,
'title' => 'Some info title',
'text' => 'Some text',
],
],
],
Expand Down Expand Up @@ -64,6 +65,7 @@ public function getInvalidUserDataProvider()
'info' => [
'id' => 100500,
'title' => 'Some info title',
'text' => 'Some text',
],
],
'This value should not be blank.',
Expand All @@ -76,6 +78,7 @@ public function getInvalidUserDataProvider()
'info' => [
'id' => 100500,
'title' => 'Some info title',
'text' => 'Some text',
],
],
'This value should not be blank.',
Expand All @@ -88,6 +91,7 @@ public function getInvalidUserDataProvider()
'info' => [
'id' => 100500,
'title' => 'Some info title',
'text' => 'Some text',
],
],
'This value should not be blank.' . PHP_EOL . 'This value should not be blank.',
Expand All @@ -105,6 +109,19 @@ public function getInvalidUserDataProvider()
'This value is too short. It should have 3 characters or more.',
400,
],
'user:invalid_info:short_title_with_some_text' => [
[
'name' => 'Some category name',
'modifier' => 'Some modifier',
'info' => [
'id' => 100500,
'title' => '1',
'text' => 'Some text',
],
],
'This value is too short. It should have 3 characters or more.',
400,
],
];
}
}