show blank title/content error FE
This commit is contained in:
parent
ca63c3d08b
commit
af0071dec2
|
@ -1,4 +1,5 @@
|
|||
import Validator from 'lib-app/validations/validator';
|
||||
import _ from 'lodash';
|
||||
|
||||
class LengthValidator extends Validator {
|
||||
constructor(length, errorKey = 'INVALID_VALUE', validator = null) {
|
||||
|
@ -12,8 +13,10 @@ class LengthValidator extends Validator {
|
|||
let div = document.createElement("div");
|
||||
div.innerHTML = value;
|
||||
let text = div.textContent || div.innerText || "";
|
||||
|
||||
if (text.length < this.minlength) return this.getError(this.errorKey);
|
||||
if(_.every(text, c => c === " ")) {
|
||||
text = text.replace(/\s/g, '');
|
||||
}
|
||||
if(text.length < this.minlength) return this.getError(this.errorKey);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
import Validator from 'lib-app/validations/validator';
|
||||
|
||||
class SpaceValidator extends Validator {
|
||||
constructor(errorKey = 'INVALID_VALUE', validator = null) {
|
||||
super(validator);
|
||||
|
||||
this.errorKey = errorKey;
|
||||
}
|
||||
|
||||
validate(value = '', form = {}) {
|
||||
let div = document.createElement("div");
|
||||
div.innerHTML = value;
|
||||
let text = div.textContent || div.innerText || "";
|
||||
|
||||
if (text.replace(/\s/g, '').length < 1) return this.getError(this.errorKey);
|
||||
}
|
||||
}
|
||||
|
||||
export default SpaceValidator;
|
|
@ -4,6 +4,7 @@ import RepeatPasswordValidator from 'lib-app/validations/repeat-password-validat
|
|||
import LengthValidator from 'lib-app/validations/length-validator';
|
||||
import ListValidator from 'lib-app/validations/list-validator';
|
||||
import ImageSizeValidator from 'lib-app/validations/image-size-validator';
|
||||
import SpaceValidator from './space-validator';
|
||||
|
||||
let validators = {
|
||||
'DEFAULT': new Validator(),
|
||||
|
|
Loading…
Reference in New Issue