persian-mongoose
persian localization and validation for mongoose schemas
for persian validation we use persianize as validators.
Installation
npm install persian-mongoose
Persian Validation
A set of validation for persian and Iran usages
Function | Description |
---|---|
isMobile | check if string is following iran's mobile number formats |
isCardNumber | check if string is a real iran bank card number |
isPhone | check if string is iran's phone number format |
isPostalCode | check if string following iran's postal code's format |
isSheba | check if string is real sheba number |
isMelliCode | check if string is real melli code |
Example :
var mySchema = phone_number : type : String validate: validator: persianMongooseisMobile msg: 'phone number is incorrect' ;
Convertors
removeArabicChars
This converts arabic alphabet characters to persian characters
Example (convert arabic chars to persian) :
//Input : فارسي -> Ouput : فارسی Schema;
Complete Usage
var mySchema = name: type: String; mySchema; var myModel = mongoose; var newName = name : 'علي' ; newName;// will save { name : 'علی' }