Created
December 12, 2018 21:26
-
-
Save vudaltsov/e83853cc00e2ff1d2d8090b5441fecee to your computer and use it in GitHub Desktop.
Domain constraints for Symfony Validator: ArticleDto
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Symfony\Component\Validator\Constraints as Assert; | |
final class ArticleDto | |
{ | |
/** | |
* @Assert\NotNull() | |
* @Assert\Type("string") | |
* @Assert\Length(min=5, max=50) | |
* @Assert\Regex("/^[a-z0-9-]$/", message="Slug must be composed of lowercase latin letters, digits and dashes.") | |
* | |
* @var null|string | |
*/ | |
public $slug; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think the regex needs a
*
so that it can match more than 1 character:"/^[a-z0-9-]*$/"