@@ -56,13 +56,17 @@ Validators are just functions. It will be executed for each property, and return
5656 - [ Custom function] ( #custom-function )
5757 - [ Date] ( #date )
5858 - [ Model] ( #model )
59+ - [ Email] ( #email )
60+ - [ Regex] ( #regex )
5961
6062## Type
6163If the data has not the specifed type, validation will fail, and that field will not be added to final validated data.
6264
65+ It uses typeof, so arrays will be considered valid objects. Also, there is a type "array", wich ensures data is an array.
66+
6367``` javascript
6468{
65- type: String // Check if data has a JS type (uses typeof)
69+ type: String // Check if data has a JS type
6670}
6771```
6872
@@ -118,7 +122,7 @@ Check if data is a JavaScript Date. Just need to set a boolean `date` parameter,
118122
119123` ` ` javascript
120124{
121- data : Boolean // Check if data is a JS Date
125+ date : Boolean // Check if data is a JS Date
122126}
123127` ` `
124128> _Remember that JavaScript dates has type ` Object ` _
@@ -168,6 +172,48 @@ var batman = geopoint.modelate(myGeopoint);
168172console .log (batman);
169173` ` `
170174
175+ ## Email
176+ Check if data is an email. Might be just a boolean, or an object to check domains:
177+
178+ ` ` ` javascript
179+ {
180+ email: Boolean // Check if data is an email
181+ }
182+ ` ` `
183+
184+ Also, to check domains:
185+ ` ` ` javascript
186+ {
187+ email: {
188+ domain: ' gmail.com'
189+ }
190+ }
191+ ` ` `
192+
193+ Or, to enable more than one valid domains:
194+ ` ` ` javascript
195+ {
196+ email: {
197+ domain: [' gmail.com' , ' google.com' ]
198+ }
199+ }
200+ ` ` `
201+
202+ ## Regex
203+ Test a regular expression over the data.
204+ ` ` ` javascript
205+ {
206+ regex: Regex // Check if data is regex valid
207+ }
208+ ` ` `
209+ An example might be:
210+ ` ` ` javascript
211+ {
212+ regex: / [a] /
213+ }
214+ ` ` `
215+ This will validate ` asd` but not ` sdf`
216+
171217# Tests
172218
173219I'm currently adding tests to this code. I'm using Jasmine, and saving tests in ` / spec` folder.
0 commit comments