|
|
@@ -1,11 +1,19 @@
|
|
1
|
1
|
import Joi from 'joi'
|
|
2
|
|
-import domains from './tlds-alpha-by-domain.js'
|
|
|
2
|
+import domains from './tlds-alpha-by-domain.js'
|
|
3
|
3
|
|
|
4
|
4
|
const answerValidator = {
|
|
5
|
5
|
name: Joi.string().required(),
|
|
6
|
|
- email: Joi.string().email({ minDomainSegments: 2, tlds: { allow: domains }}),
|
|
7
|
|
- // TODO: Refine password regex to have more secure requirements
|
|
8
|
|
- password: Joi.string().min(10).max(30).pattern(new RegExp('[a-zA-Z0-9]+')),
|
|
|
6
|
+ email: Joi.string().email({
|
|
|
7
|
+ minDomainSegments: 2,
|
|
|
8
|
+ tlds: { allow: domains },
|
|
|
9
|
+ }),
|
|
|
10
|
+ // TODO: password validation is a moving target with regex,
|
|
|
11
|
+ // consider using a more robust library?
|
|
|
12
|
+ password: Joi.string()
|
|
|
13
|
+ .min(14)
|
|
|
14
|
+ .max(30)
|
|
|
15
|
+ .pattern(
|
|
|
16
|
+ new RegExp('^(?=.*[!@#$%^&*()_+\\-=[\\]{};\':"\\\\|,.<>\\/?])(?=.*[!@#$%^&*()_+\\-=[\\]{};\':"\\\\|,.<>\\/?])[a-zA-Z0-9!@#$%^&*()_+\\-=[\\]{};\':"\\\\|,.<>\\/?]{10,}$')),
|
|
9
|
17
|
// TODO: Change if going international (only works in usa)
|
|
10
|
18
|
zipcode: Joi.string().min(5).max(5).pattern(new RegExp('^[0-9]{5}$')),
|
|
11
|
19
|
seeking: Joi.string(),
|