Giter Site home page Giter Site logo

li3_validation's Introduction

Lithium Persian Validation

Lithium Persian Validation provides validation for Persian alphabet, number and etc.

License

Lithium Persian Validation is open-sourced software licensed under the BSD license

Install

Clone it from Github and put it inside your libraries folder:

$ git clone https://github.com/alihesari/li3_validation.git

Via Composer

composer require alihesari/li3_validation

Config

Add the following line in your config/bootstrap/libraries.php:

Libraries::add('li3_validation');

Usage

You can access to validation rules by passing the rules key according blew following table:

Rules Descriptions
persianAlpha Persian alphabet
persianNum Persian numbers
persianAlphaNum Persian alphabet and numbers
alphaSpace Accept Persian, English and ... alphabet, space character
iranMobile Iran mobile numbers
iranPhone Iran phone numbers
cardNumber Payment card numbers
shebaNum Iran Sheba numbers
melliCode Iran melli code
iranPostalCode Iran postal code
persianAddress Accept Persian, English and ... alphabet, Persian and English numbers and some special characters
unSignedNum Checked variable is unsigned numbers
noPersian Doesn't accept Persian alphabet and numbers

Example usage:

Persian Alpha

Accept Persian language alphabet according to standard Persian, this is the way you can use this validation rule:

Validator::rule('persianAlpha', 'متن فارسی');
//output: true

Persian numbers

Validate Persian standard numbers (۰۱۲۳۴۵۶۷۸۹):

Validator::rule('persianNum', '۰۱۲۳۴۵۶۷۸۹');
//output: true

Persian Alpha Num

Validate Persian alpha num:

Validator::rule('persianAlphaNum', 'فارسی۱۲۳۴۵۶۷۸۹');
//output: true

Iran mobile phone

Validate Iran mobile phones (irancel, rightel, hamrah-e-aval, ...):

Validator::rule('iranMobile', '09356820085');
//output: true

Payment card number

Validate Iran payment card numbers:

Validator::rule('shebaNum', '6274129005473742');
//output: true

Sheba number

Validate Iran bank sheba numbers:

Validator::rule('shebaNum', 'IR062960000000100324200001');
//output: true

Iran national code

Validate Iran national code (melli-code):

Validator::rule('shebaNum', '3240175800');
//output: true

Iran postal code

Validate Iran postal code:

Validator::rule('shebaNum', '167197-35744');
//output: true


Validator::rule('shebaNum', '16719735744');
//output: true

Persian Address

Validate persian alphabet, number and some special characters:

Validator::rule('persianAddress', 'ایران، تهران - پردیس');
//output: true


Validator::rule('persianAddress', 'Iran / Tehran / pardis / 16');
//output: true


Validator::rule('persianAddress', 'Iran, Tehran & pardis');
//output: false

UnSigned number

validate number to be unsigned:

Validator::rule('unSignedNum', '110');
//output: true


Validator::rule('unSignedNum', '-110');
//output: false


Validator::rule('unSignedNum', '8.5');
//output: false

No persian

validate string that is not contain persian alphabet and number:

Validator::rule('noPersian', 'Ali Hesari');
//output: true


Validator::rule('noPersian', 'Ali علی');
//output: false


Validator::rule('noPersian', '110');
//output: true


Validator::rule('noPersian', '110علی');
//output: false


Validator::rule('noPersian', '۱۱۰');
//output: false

li3_validation's People

Contributors

alihesari avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.