mirror of
https://github.com/Respect/Validation.git
synced 2026-03-16 15:25:45 +01:00
Most changes was made by php-cs-fixer. Also removes unused `RecursiveTreeIterator` class.
22 lines
395 B
PHP
22 lines
395 B
PHP
<?php
|
|
namespace Respect\Validation\Rules;
|
|
|
|
class Slug extends AbstractRule
|
|
{
|
|
public function validate($input)
|
|
{
|
|
if (strstr($input, '--')) {
|
|
return false;
|
|
}
|
|
|
|
if (!preg_match('@^[0-9a-z\-]+$@', $input)) {
|
|
return false;
|
|
}
|
|
|
|
if (preg_match('@^-|-$@', $input)) {
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
}
|