'How I can make validation to the Name attribute to ensure it is not empty on js?

I need make validation to the Name attribute. May be need validation that it's not number? My code:

class Book {
    get name(){
        return this._name;
    }

    set name(value){
        if (value.length === 0){
            console.log("name is too short")      
        }

        this._name = value;
    } 
}

But not working. What wrong?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source