lynnlin/date-time-validator

Validate the date time in laravel controller
12 2
Install
composer require lynnlin/date-time-validator
Latest Version:1.0.2
PHP:>=5.5.9
License:MIT
Last Updated:Aug 9, 2016
Links: GitHub  ·  Packagist
Maintainer: lynnlin

date-time-validator

Build Status codecov.io Packagist license

Description

Add a new validation rule during to validate whether the given date time is in a specific period which is 6 months by default.

Installation

Install the package via composer.

composer require lynnlin/date-time-validator

Add the service provider into config/app.php.

'providers' => [
	...
	DateTimeValidator\ValidatorServiceProvider::class,
	...
]

Usage

use Illuminate\Support\Facades\Validator;

// check 20160123 whether it is in 6 months ago from today
Validator::make(
    ['startAt' => '20160123'],
    ['startAt' => 'during']
);

// check 20150123 whether it is in 1 year ago from today since endAt is not given in the first argument
Validator::make(
    ['startAt' => '20150123'],
    ['startAt' => 'during:endAt,1Y', 'endAt' => 'string']
);

// check 20150123 whether it is in 1 day from 20150124
Validator::make(
    ['startAt' => '20150123', 'endAt' => '20150124'],
    ['startAt' => 'during:endAt,1d', 'endAt' => 'string']
);

// check 20150123 whether it is in 1 week from 20150124
Validator::make(
    ['startAt' => '20150123', 'endAt' => '20150124'],
    ['startAt' => 'during:endAt,1w', 'endAt' => 'string']
);

Related Packages

rap2hpoutre/laravel-credit-card-validator

Laravel credit card validator

133,125 21
tylercd100/laravel-validator-phone

Validate that a phone number is in the correct format

4,377 3
tylercd100/laravel-validator-color

Validate that a certain value is a valid CSS color string in Laravel 5

81,569 15
ellisio/laravel-phone

A phone validator for Laravel using the free Twilio phone lookup service.

29,983 11
proengsoft/laravel-jsvalidation

Validate forms transparently with Javascript reusing your Laravel Validation Rul...

2,454,996 1,140