To check length use below:
if(stringToCheck.length < 4 || stringToCheck.length > 12){
//throw error
}
To not allow small letters a-z use below:
const regex = /[a-z]/;
if(regex2.test(stringToCheck)){
//if a-z is entered throw error
//this will allow A-Z, 0-9, '-'....
//throw error
}
To must contain at least one digit use below:
const regex = /\d/;
if(!regex2.test(stringToCheck)){
//if no digit is entered throw error
//throw error
}