fn check_role(
    property_name: &PropertyName,
    roles: &Option<Vec<Role>>,
    config_role: Option<&str>,
) -> ValidationResult<()> {
    if roles.is_none() {
        return Err(Error::PropertySpecRoleNotProvided {
            name: property_name.clone(),
        });
    }

    if config_role.is_none() {
        return Err(Error::PropertySpecRoleNotProvidedByUser {
            name: property_name.clone(),
        });
    }

    if let (Some(roles), Some(user_role)) = (roles, config_role) {
        for role in roles {
            if role.name == user_role {
                return Ok(());
            }
        }
    }

    Err(Error::PropertySpecRoleNotFound {
        name: property_name.clone(),
        role: config_role.unwrap().to_string(),
    })
}
/// Check if property role is available
///
/// # Arguments
///
/// * `property_name` - name of the property
/// * `roles` - roles provided in the property spec
/// * `config_role` - role provided by the user
///
Check if property role is available
Check if property role is available
fn check_role(
    property_name: &PropertyName,
    roles: &Option<Vec<Role>>,
    config_role: Option<&str>,
) -> ValidationResult<()> {
    if roles.is_none() {
        return Err(Error::PropertySpecRoleNotProvided {
            name: property_name.clone(),
        });
    }
    if config_role.is_none() {
        return Err(Error::PropertySpecRoleNotProvidedByUser {
            name: property_name.clone(),
        });
    }
    if let (Some(roles), Some(user_role)) = (roles, config_role) {
        for role in roles {
            if role.name == user_role {
                return Ok(());
            }
        }
    }
    Err(Error::PropertySpecRoleNotFound {
        name: property_name.clone(),
        role: config_role.unwrap().to_string(),
    })
}
fn check_role ( property_name : & PropertyName , roles : & Option < Vec < Role > > , config_role : Option < & str > , ) -> ValidationResult < ( ) > { if roles . is_none ( ) { return Err ( Error :: PropertySpecRoleNotProvided { name : property_name . clone ( ) , } ) ; } if config_role . is_none ( ) { return Err ( Error :: PropertySpecRoleNotProvidedByUser { name : property_name . clone ( ) , } ) ; } if let ( Some ( roles ) , Some ( user_role ) ) = ( roles , config_role ) { for role in roles { if role . name == user_role { return Ok ( ( ) ) ; } } } Err ( Error :: PropertySpecRoleNotFound { name : property_name . clone ( ) , role : config_role . unwrap ( ) . to_string ( ) , } ) }
Check if property role is available
Check if property role is available
property_name
&PropertyName
roles
&Option<Vec<Role>>
config_role
Option<&str>