settings and users dialog
This commit is contained in:
@ -66,10 +66,16 @@ export class ValidationService {
|
||||
return {ok: true, error: ''};
|
||||
}
|
||||
|
||||
string(data) {
|
||||
const {ignore, error} = Joi.string().max(128).allow('').validate(data);
|
||||
string(data, option = null) {
|
||||
let validator = Joi.string().max(128).allow('');
|
||||
let errorMsg = 'must contain max 128 characters';
|
||||
if (option === 'alphanum') {
|
||||
validator = validator.alphanum();
|
||||
errorMsg = 'must contain max 128 alphanumerical characters';
|
||||
}
|
||||
const {ignore, error} = validator.validate(data);
|
||||
if (error) {
|
||||
return {ok: false, error: 'must contain max 128 characters'};
|
||||
return {ok: false, error: errorMsg};
|
||||
}
|
||||
return {ok: true, error: ''};
|
||||
}
|
||||
@ -122,6 +128,13 @@ export class ValidationService {
|
||||
return {ok: true, error: ''};
|
||||
}
|
||||
|
||||
equal(data, compare) {
|
||||
if (data !== compare) {
|
||||
return {ok: false, error: `must be equal`};
|
||||
}
|
||||
return {ok: true, error: ''};
|
||||
}
|
||||
|
||||
parameterName(data) {
|
||||
const {ignore, error} = Joi.string()
|
||||
.max(128)
|
||||
|
Reference in New Issue
Block a user