All Projects → laravel-validation-rules → Credit Card

laravel-validation-rules / Credit Card

Licence: apache-2.0
Credit Card Validation

Projects that are alternatives of or similar to Credit Card

Validation
The power of Respect Validation on Laravel
Stars: ✭ 188 (+25.33%)
Mutual labels:  validation, validator, laravel
Laravel Zip Validator
Laravel ZIP file content validator
Stars: ✭ 120 (-20%)
Mutual labels:  validation, validator, laravel
Identity Number
Validator for Swedish personal identity numbers (personnummer). For use "standalone" or with Laravel.
Stars: ✭ 17 (-88.67%)
Mutual labels:  validation, laravel, laravel-5-package
Validation Composite
Allows uniting of several validation rules into single one for easy re-usage
Stars: ✭ 159 (+6%)
Mutual labels:  validation, validator, laravel
Validation
🔒 Laravel farsi/persian validation
Stars: ✭ 142 (-5.33%)
Mutual labels:  validation, validator, laravel
Validator
A tool to validate text inside TextInputLayout
Stars: ✭ 117 (-22%)
Mutual labels:  validation, validator
Pagination
🎁 Laravel 5 Custom Pagination Presenter
Stars: ✭ 119 (-20.67%)
Mutual labels:  laravel, laravel-5-package
L5 Swagger
OpenApi or Swagger integration to Laravel
Stars: ✭ 1,781 (+1087.33%)
Mutual labels:  laravel, laravel-5-package
Awesome Python Models
A curated list of awesome Python libraries, which implement models, schemas, serializers/deserializers, ODM's/ORM's, Active Records or similar patterns.
Stars: ✭ 124 (-17.33%)
Mutual labels:  validation, validator
Validatorjs
A data validation library in JavaScript for the browser and Node.js, inspired by Laravel's Validator.
Stars: ✭ 1,534 (+922.67%)
Mutual labels:  validation, laravel
Facebook
📨 Facebook Notifications Channel for Laravel
Stars: ✭ 120 (-20%)
Mutual labels:  laravel, laravel-5-package
L5 Very Basic Auth
Stateless HTTP basic auth for Laravel without the need for a database.
Stars: ✭ 127 (-15.33%)
Mutual labels:  laravel, laravel-5-package
Eye
Eyewitness.io package for Laravel 5 applications
Stars: ✭ 114 (-24%)
Mutual labels:  laravel, laravel-5-package
Vuejs2 Laravel53 Starter
A starter template for VueJs 2.0 with Laravel 5.4
Stars: ✭ 112 (-25.33%)
Mutual labels:  laravel, laravel-5-package
Laravel Excel
🚀 Supercharged Excel exports and imports in Laravel
Stars: ✭ 10,417 (+6844.67%)
Mutual labels:  laravel, laravel-5-package
Laravel Form Builder
Laravel Form builder for version 5+!
Stars: ✭ 1,601 (+967.33%)
Mutual labels:  laravel, laravel-5-package
Laravel Model Caching
Eloquent model-caching made easy.
Stars: ✭ 1,829 (+1119.33%)
Mutual labels:  laravel, laravel-5-package
Laravel Swagger
Auto generates the swagger documentation of a laravel project based on best practices and simple assumptions
Stars: ✭ 129 (-14%)
Mutual labels:  laravel, laravel-5-package
Apvalidators
Codeless solution for form validation in iOS!
Stars: ✭ 130 (-13.33%)
Mutual labels:  validation, validator
Laravel Single Session
This package prevents a User from being logged in more than once. It destroys the previous session when a User logs in and thereby allowing only one session per user.
Stars: ✭ 95 (-36.67%)
Mutual labels:  laravel, laravel-5-package

Laravel Validator Rules - Credit Card

This rule will validate that a given credit card number, expiration date or cvc is valid.

Installation

composer require laravel-validation-rules/credit-card

Usage

As FormRequest

<?php

namespace App\Http\Requests;

use LVR\CreditCard\CardCvc;
use LVR\CreditCard\CardNumber;
use LVR\CreditCard\CardExpirationYear;
use LVR\CreditCard\CardExpirationMonth;
use Illuminate\Foundation\Http\FormRequest;

class CreditCardRequest extends FormRequest
{
    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'card_number' => ['required', new CardNumber],
            'expiration_year' => ['required', new CardExpirationYear($this->get('expiration_month'))],
            'expiration_month' => ['required', new CardExpirationMonth($this->get('expiration_year'))],
            'cvc' => ['required', new CardCvc($this->get('card_number'))]
        ];
    }
}

Card number

From request

$request->validate(
    ['card_number' => '37873449367100'],
    ['card_number' => new LVR\CreditCard\CardNumber]
);

Directly

(new LVR\CreditCard\Cards\Visa)
    ->setCardNumber('4012888888881881')
    ->isValidCardNumber()

Card expiration

From request

// CardExpirationYear requires card expiration month
$request->validate(
    ['expiration_year' => '2017'],
    ['expiration_year' => ['required', new LVR\CreditCard\CardExpirationYear($request->get('expiration_month'))]]
);

// CardExpirationMonth requires card expiration year
$request->validate(
    ['expiration_month' => '11'],
    ['expiration_month' => ['required', new LVR\CreditCard\CardExpirationMonth($request->get('expiration_year'))]]
);

// CardExpirationDate requires date format
$request->validate(
    ['expiration_date' => '02-18'],
    ['expiration_date' => ['required', new LVR\CreditCard\CardExpirationDate('MM-YY')]]
);

Directly

LVR\CreditCard\Cards\ExpirationDateValidator(
    $expiration_year,
    $expiration_month
)->isValid();

// Or static
LVR\CreditCard\Cards\ExpirationDateValidator::validate(
    $expiration_year,
    $expiration_month
);

Card CVC

From request

// CardCvc requires card number to determine allowed cvc length
$request->validate(
    ['cvc' => '123'],
    ['cvc' => new LVR\CreditCard\CardCvc($request->get('card_number'))]
);

Directly

LVR\CreditCard\Cards\Card::isValidCvcLength($cvc);

License

This project is licensed under an Apache 2.0 license which you can find in this LICENSE.

Feedback

If you have any feedback, comments or suggestions, please feel free to open an issue within this repository!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].