mirror of
https://github.com/opensupports/opensupports.git
synced 2025-07-31 01:35:15 +02:00
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 Validator from 'lib-app/validations/validator';
|
||||||
|
import _ from 'lodash';
|
||||||
|
|
||||||
class LengthValidator extends Validator {
|
class LengthValidator extends Validator {
|
||||||
constructor(length, errorKey = 'INVALID_VALUE', validator = null) {
|
constructor(length, errorKey = 'INVALID_VALUE', validator = null) {
|
||||||
@ -12,8 +13,10 @@ class LengthValidator extends Validator {
|
|||||||
let div = document.createElement("div");
|
let div = document.createElement("div");
|
||||||
div.innerHTML = value;
|
div.innerHTML = value;
|
||||||
let text = div.textContent || div.innerText || "";
|
let text = div.textContent || div.innerText || "";
|
||||||
|
if(_.every(text, c => c === " ")) {
|
||||||
if (text.length < this.minlength) return this.getError(this.errorKey);
|
text = text.replace(/\s/g, '');
|
||||||
|
}
|
||||||
|
if(text.length < this.minlength) return this.getError(this.errorKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
19
client/src/lib-app/validations/space-validator.js
Normal file
19
client/src/lib-app/validations/space-validator.js
Normal file
@ -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 LengthValidator from 'lib-app/validations/length-validator';
|
||||||
import ListValidator from 'lib-app/validations/list-validator';
|
import ListValidator from 'lib-app/validations/list-validator';
|
||||||
import ImageSizeValidator from 'lib-app/validations/image-size-validator';
|
import ImageSizeValidator from 'lib-app/validations/image-size-validator';
|
||||||
|
import SpaceValidator from './space-validator';
|
||||||
|
|
||||||
let validators = {
|
let validators = {
|
||||||
'DEFAULT': new Validator(),
|
'DEFAULT': new Validator(),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user