Persianize is set of nodejs tools for validating and converting data in correct Persian.
If you have a package.json file in your directory you can require the package and run npm install
{
"name": "persianize",
"version": "2.0.0"
}Or run following command to direct usage
npm install persianizeIf you didn't use dependency management systems you can install persianize in manual way, download ZIP file and then extract it and all you need is require 'Persianize.js' file on your project and use it.
You can use both persianize validator and convert in one single object, like every node module you should import this package to your file.
var persianize = require('persianize');This object helps you to change phrases to right Persian
Convert English and Arabic numbers to right Persian numbers.
persianize.convert().number('0123456789').get(); // Output --> ۰۱۲۳۴۵۶۷۸۹Remove Arabic keyboard characters from Persian text.
persianize.convert().removeArabicChar('فارسي').get(); // Output --> فارسیDetect persian verbs and replace space with half-space
persianize.convert().halfSpace('می روی').get(); // Output --> میرویThis method will convert number, convert arabic characters to Persian and replace space with half-space.
persianize.convert().all('فارسي 1').get(); // Output --> فارسی ۱Validating Persian language inputs like Persian number, Persian alphabet...
Validate Persian Alphabet
persianize.validator().alpha('فارسی'); // Output --> TRUEValidate Persian Number
persianize.validator().number('۱۲۳'); // Output --> TRUEValidate Persian Alphabet and numbers
persianize.validator().alphaNum('۳فارسی'); //Output --> TRUEValidate Persian alphabet, numbers, space, half-space and special characters.
persianize.validator().text('۳ فارسی') //Output --> TRUEValidate Iran mobile number.
persianize.validator().mobile('09355555555') //Output --> TRUEValidate Iran crad number.
persianize.validator().cradNumber('6274129005473742') //Output --> TRUEValidate Iran phone number.
persianize.validator().phone('37236445') //Output --> TRUEValidate Iran postal code.
persianize.validator().postalCode('1619735744') //Output --> TRUEValidate Iran sheba number.
persianize.validator().sheba('IR062960000000100324200001') //Output --> TRUEValidate Iran meli code.
persianize.validator().meliCode('0013542419') //Output --> TRUE