Skip to content

Commit 5dfda4e

Browse files
committed
v.6
1 parent d42647f commit 5dfda4e

File tree

3 files changed

+83
-5
lines changed

3 files changed

+83
-5
lines changed

README.md

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,15 @@ The field under validation may have alpha-numeric characters, as well as dashes
129129
**alphaNumeric**
130130
The field under validation only contains letters and numbers.
131131

132+
**array**
133+
The field under validation must be an array.
134+
135+
**ascii**
136+
The field under validation only contains ascii characters.
137+
138+
**base64**
139+
The field under validation must be valid base64 ecoded string.
140+
132141
**between:1,9**
133142
The field under validation must be between provided values.
134143

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

150+
**creditCard**
151+
The field under validation must be valid creadit card string.
152+
141153
**dateFormat**
142154
The field under validation must match the given date format.
143155

144156
**digits**
145157
The field under validation only contains digits.
146158

147-
148159
**digitsBetween**
149160
The field under validation must be between provided digit values.
150161

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

166-
**array**
167-
The field under validation must be an array.
168-
169177
**json**
170178
The field under validation must be a valid JSON string.
171179

180+
**latLong**
181+
The field under validation must be a valid latitude-longitude coordinate.
182+
183+
172184
**max**
173185
The field under validation must be less than givern value.
174186

lib/rules/mix.js

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,72 @@ class Mix extends DateRules {
2929
}
3030
}
3131

32+
/**
33+
* will only allow ascii chars
34+
* @param field
35+
* @param value
36+
* @param message
37+
* @returns {Promise.<boolean>}
38+
*/
39+
async validateAscii(field, value, message) {
40+
if (!v.isAscii(value)) {
41+
return true;
42+
}
43+
44+
return false;
45+
46+
}
47+
48+
/**
49+
* will only allow base 64 encoded string
50+
* @param field
51+
* @param value
52+
* @param message
53+
* @returns {Promise.<boolean>}
54+
*/
55+
async validateBase64(field, value, message) {
56+
if (!v.isBase64(value)) {
57+
return true;
58+
}
59+
60+
return false;
61+
62+
}
63+
64+
/**
65+
* check if the string is a credit card.
66+
* @param field
67+
* @param value
68+
* @param message
69+
* @returns {Promise.<boolean>}
70+
*/
71+
async validateCreditCard(field, value, message) {
72+
if (!v.isCreditCard(value)) {
73+
return true;
74+
}
75+
76+
return false;
77+
78+
}
79+
80+
/**
81+
* check if the string is a valid latitude-longitude coordinate.
82+
* @param field
83+
* @param value
84+
* @param message
85+
* @returns {Promise.<boolean>}
86+
*/
87+
async validateLatLong(field, value, message) {
88+
if (!v.isLatLong(value)) {
89+
return true;
90+
}
91+
92+
return false;
93+
94+
}
95+
96+
97+
3298
/**
3399
* this will only allow alphabets
34100
* @param field

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "node-input-validator",
3-
"version": "1.0.5",
3+
"version": "1.1.0",
44
"description": "validation library",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)