fn check_datatype(
    config_spec_units: &HashMap<String, Regex>,
    property_name: &PropertyName,
    property_value: &str,
    datatype: &Datatype,
) -> ValidationResult<()> {
    match datatype {
        Datatype::Bool => {
            check_datatype_scalar::<bool>(property_name, property_value, &None, &None)?;
        }
        Datatype::Integer { min, max, .. } => {
            check_datatype_scalar::<i64>(property_name, property_value, min, max)?;
        }
        Datatype::Float { min, max, .. } => {
            check_datatype_scalar::<f64>(property_name, property_value, min, max)?;
        }
        Datatype::String { min, max, unit, .. } => {
            check_datatype_string(
                config_spec_units,
                property_name,
                property_value,
                min,
                max,
                unit,
            )?;
        }
        Datatype::Array { .. } => {
            // TODO: implement logic for array type
        }
    }
    Ok(())
}
/// Check if property value fits the provided datatype
/// # Arguments
///
/// * `config_spec_units` - map with unit name and respective regular expression to evaluate the datatype
/// * `property_name` - name of the property
/// * `property_value` - property value to be validated
/// * `datatype` - property datatype containing min/max bounds, units etc.
///
Check if property value fits the provided datatype
Check if property value fits the provided datatype
fn check_datatype(
    config_spec_units: &HashMap<String, Regex>,
    property_name: &PropertyName,
    property_value: &str,
    datatype: &Datatype,
) -> ValidationResult<()> {
    match datatype {
        Datatype::Bool => {
            check_datatype_scalar::<bool>(property_name, property_value, &None, &None)?;
        }
        Datatype::Integer { min, max, .. } => {
            check_datatype_scalar::<i64>(property_name, property_value, min, max)?;
        }
        Datatype::Float { min, max, .. } => {
            check_datatype_scalar::<f64>(property_name, property_value, min, max)?;
        }
        Datatype::String { min, max, unit, .. } => {
            check_datatype_string(
                config_spec_units,
                property_name,
                property_value,
                min,
                max,
                unit,
            )?;
        }
        Datatype::Array { .. } => {
            // TODO: implement logic for array type
        }
    }
    Ok(())
}
fn check_datatype ( config_spec_units : & HashMap < String , Regex > , property_name : & PropertyName , property_value : & str , datatype : & Datatype , ) -> ValidationResult < ( ) > { match datatype { Datatype :: Bool => { check_datatype_scalar :: < bool > ( property_name , property_value , & None , & None ) ? ; } Datatype :: Integer { min , max , .. } => { check_datatype_scalar :: < i64 > ( property_name , property_value , min , max ) ? ; } Datatype :: Float { min , max , .. } => { check_datatype_scalar :: < f64 > ( property_name , property_value , min , max ) ? ; } Datatype :: String { min , max , unit , .. } => { check_datatype_string ( config_spec_units , property_name , property_value , min , max , unit , ) ? ; } Datatype :: Array { .. } => { // TODO: implement logic for array type } } Ok ( ( ) ) }
Check if property value fits the provided datatype
Check if property value fits the provided datatype
config_spec_units
&HashMap<String, Regex>
property_name
&PropertyName
property_value
&str
datatype
&Datatype