def METHOD_NAME(cls, cred):
    """validate the credentials
    """
    if isinstance(cred, str):
        dev_cred_file = Path(cred)
        if not dev_cred_file.is_file():
            raise ValueError(
                f'The credential file {cred} does not exists')
        try:
            with open(dev_cred_file, 'r') as f:
                credentials = yaml.safe_load(f.read())
        except yaml.YAMLError:
            raise ValueError(
                'The credential file is not a valid yaml file'
            )
        if not credentials:
            raise ValueError(
                'The credential file is empty'
            )
        if not isinstance(credentials, list):
            raise ValueError(
                'The credentials file must contain all device '
                'credential divided in namespaces'
            )
    elif isinstance(cred, list):
        credentials = cred
    valid_creds = []
    for c in credentials:
        if not isinstance(c, dict):
            raise ValueError(
                'Namespaces credentials must be a dictionary')
        valid_creds.append(CredFileNamespaceModel(**c))
    return valid_creds