const validator = {
    validateTypeOf: (value, property, type) => {
        if (typeof value !== type) {
            toastr.error(property + ' is not of type ' + type);
            throw new Error(property + ' is not of type ' + type);
        }
    },
    validateIfEmptyString: (value, property) => {
        if (value === '') {
            toastr.error(property + ' is Empty');
            throw new Error(property + ' is Empty');
        }
    },
    validateIfUndefinedOrNull: (value, property) => {
        if (typeof value === 'undefined' || value === null) {
            toastr.error(property + ' is undefined or null');
            throw new Error(property + ' is undefined or null');
        }
    },
    validateEmail: (email) => {
        let regex = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
        if (!regex.test(email)) {
            toastr.error('Invalid Email');
            throw new Error('Invalid Email');
        }
    },
    validatePhone: (phone) => {
        let regex = /^\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$/;
        if (!regex.test(phone)) {
            toastr.error('Invalid Phone');
            throw new Error('Invalid Phone');
        }
    },
    validatePassword: (password) => {
        let regex = /^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{8,}$/;
        if (!regex.test(password)) {
            toastr.error('Password has to be Minimum 8 characters at least 1 Alphabet and 1 Number');
            throw new Error('Password has to be Minimum 8 characters at least 1 Alphabet and 1 Number');
        }
    },
    validateUsername: (username) => {
        let regex = /^[A-Za-z0-9_-]*[A-Za-z0-9][A-Za-z0-9_-]*$/;
        if (!regex.test(username)) {
            toastr.error('Username contain invalid symbols');
            throw new Error('Username contain invalid symbols');
        }
    }
};

export { validator };
@@ -1756,17 +1756,20 @@
 -z0-9_-%5D
-*
+%7B3,%7D
 $/;%0A    
@@ -1840,96 +1840,150 @@
 ame 
-contain invalid symbols');%0A            throw new Error('Username contain invalid symbols
+must be at least 4 symbols and all should be valid');%0A            throw new Error('Username must be at least 4 symbols and all should be valid
 ');%0A

fix username regex validation - now it must be at least 4 symbols