Skip to content

Commit

Permalink
afup#1482 on valide le raccourci pour valider sans espace
Browse files Browse the repository at this point in the history
  • Loading branch information
stakovicz committed Jul 25, 2024
1 parent ae9ae85 commit 84ccd61
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
7 changes: 3 additions & 4 deletions htdocs/pages/administration/site_articles.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
$forumLabelsById[$forum['id']] = $forum['titre'];
}

function checkSpaceValidation($value): bool
function checkNoSpace($value): bool
{
return !preg_match('/(\s)/', $value);
}
Expand Down Expand Up @@ -126,10 +126,9 @@ function checkSpaceValidation($value): bool
$formulaire->addRule('titre' , 'Titre manquant' , 'required');
$formulaire->addRule('contenu' , 'Contenu manquant' , 'required');
$formulaire->addRule('raccourci' , 'Raccourci manquant' , 'required');
$formulaire->addRule('raccourci' , 'Ne doit pas contenir d\'espace' , 'regex', '/(?!\s)/');

$formulaire->registerRule('checkSpace', 'callback', 'checkSpaceValidation');
$formulaire->addRule('raccourci', 'Ne doit pas contenir d\'espace', 'checkSpace', true);
$formulaire->registerRule('checkNoSpace', 'callback', 'checkNoSpace');
$formulaire->addRule('raccourci', 'Ne doit pas contenir d\'espace', 'checkNoSpace', true);


if ($formulaire->validate()) {
Expand Down
2 changes: 1 addition & 1 deletion tests/behat/features/Admin/Site/AdminSiteArticles.feature
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@ Feature: Administration - Partie Site
When I follow "Ajouter"
And I fill in "raccourci" with "un mauvais raccourci"
And I press "Ajouter"
Then the ".negative.message" element should contain "Ne doit pas contenir d'espace"
Then I should see "Ne doit pas contenir d'espace"

0 comments on commit 84ccd61

Please sign in to comment.