Pergunta

I am working on a time regex (24 hours) in laravel, but cant get it working:

'Time' => 'regex:/^\d(2[0-3]|[01][0-9]):[0-5][0-9]:[0-5][0-9]$/'
Foi útil?

Solução

Use something like this:

$rules = array(
    'time' => array('regex:/^([01]?[0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]$/')
);

Note: When using the regex pattern, it may be necessary to specify rules in an array instead of using pipe delimiters, especially if the regular expression contains a pipe character.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top