<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;

class ValidatorServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        $this->app['validator']->extend('time12', function ($attribute, $value, $parameters)
        {
            if(preg_match("/(1[012]|0[0-9]):([0-5][0-9])/", $value)){
                return true;
            } elseif (preg_match("/(2[0-3]|[01][0-9]):([0-5][0-9])/", $value)){
                return true;
            }
        });
    }

    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        //
    }
}
