Skip to content

Commit

Permalink
v.6
Browse files Browse the repository at this point in the history
  • Loading branch information
bitnbytesio committed Sep 28, 2017
1 parent d42647f commit 5dfda4e
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 5 deletions.
20 changes: 16 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,15 @@ The field under validation may have alpha-numeric characters, as well as dashes
**alphaNumeric**
The field under validation only contains letters and numbers.

**array**
The field under validation must be an array.

**ascii**
The field under validation only contains ascii characters.

**base64**
The field under validation must be valid base64 ecoded string.

**between:1,9**
The field under validation must be between provided values.

Expand All @@ -138,13 +147,15 @@ The field under validation must be 0/1, or true/false.
**contains**
The field under validation must contains provided seeds.

**creditCard**
The field under validation must be valid creadit card string.

**dateFormat**
The field under validation must match the given date format.

**digits**
The field under validation only contains digits.


**digitsBetween**
The field under validation must be between provided digit values.

Expand All @@ -163,12 +174,13 @@ The field under validation must be an integer.
**ip**
The field under validation must be an IP address.

**array**
The field under validation must be an array.

**json**
The field under validation must be a valid JSON string.

**latLong**
The field under validation must be a valid latitude-longitude coordinate.


**max**
The field under validation must be less than givern value.

Expand Down
66 changes: 66 additions & 0 deletions lib/rules/mix.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,72 @@ class Mix extends DateRules {
}
}

/**
* will only allow ascii chars
* @param field
* @param value
* @param message
* @returns {Promise.<boolean>}
*/
async validateAscii(field, value, message) {
if (!v.isAscii(value)) {
return true;
}

return false;

}

/**
* will only allow base 64 encoded string
* @param field
* @param value
* @param message
* @returns {Promise.<boolean>}
*/
async validateBase64(field, value, message) {
if (!v.isBase64(value)) {
return true;
}

return false;

}

/**
* check if the string is a credit card.
* @param field
* @param value
* @param message
* @returns {Promise.<boolean>}
*/
async validateCreditCard(field, value, message) {
if (!v.isCreditCard(value)) {
return true;
}

return false;

}

/**
* check if the string is a valid latitude-longitude coordinate.
* @param field
* @param value
* @param message
* @returns {Promise.<boolean>}
*/
async validateLatLong(field, value, message) {
if (!v.isLatLong(value)) {
return true;
}

return false;

}



/**
* this will only allow alphabets
* @param field
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "node-input-validator",
"version": "1.0.5",
"version": "1.1.0",
"description": "validation library",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 5dfda4e

Please sign in to comment.