public function isValid($key = null) {
        if (isset($key)) {
            return empty($this->errors[$key]);
        }
        else {
            return empty($this->errors);
        }
    }
public function isValid($key = null) {
        if (isset($key)) {
            return empty($this->errors[$key]);
        }
        else {
            return empty($this->errors);
        }
    }
public function isValid ( $ key = null ) { if ( isset ( $ key ) ) { return empty ( $ this -> errors [ $ key ] ) ; } else { return empty ( $ this -> errors ) ; } }
Returns true if the state does not contain errors; otherwise, false.

@param string $key If the key is specified, only the specified key will be checked for errors.

@return bool
Returns true if the state does not contain errors ; otherwise false .