settings and users dialog

This commit is contained in:
VLE2FE
2020-07-29 13:14:29 +02:00
parent 55248e25ef
commit 4876ba3c0c
26 changed files with 479 additions and 41 deletions

View File

@ -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)