/// Validates that the offer target is to a valid child or collection.
Validates that the offer target is to a valid child or collection.
Validates that the offer target is to a valid child or collection .
fn validate_offer_target(
        &mut self,
        target: &'a Option<fsys::Ref>,
        decl_type: &str,
        field_name: &str,
    ) -> Option<TargetId<'a>> {
        match target.as_ref() {
            Some(fsys::Ref::Child(child)) => {
                if self.validate_child_ref(decl_type, field_name, &child) {
                    Some(TargetId::Component(&child.name))
                } else {
                    None
                }
            }
            Some(fsys::Ref::Collection(collection)) => {
                if self.validate_collection_ref(decl_type, field_name, &collection) {
                    Some(TargetId::Collection(&collection.name))
                } else {
                    None
                }
            }
            Some(_) => {
                self.errors.push(Error::invalid_field(decl_type, field_name));
                None
            }
            None => {
                self.errors.push(Error::missing_field(decl_type, field_name));
                None
            }
        }
    }
fn validate_offer_target ( & mut self , target : & ' a Option < fsys :: Ref > , decl_type : & str , field_name : & str , ) -> Option < TargetId < ' a > > { match target . as_ref ( ) { Some ( fsys :: Ref :: Child ( child ) ) => { if self . validate_child_ref ( decl_type , field_name , & child ) { Some ( TargetId :: Component ( & child . name ) ) } else { None } } Some ( fsys :: Ref :: Collection ( collection ) ) => { if self . validate_collection_ref ( decl_type , field_name , & collection ) { Some ( TargetId :: Collection ( & collection . name ) ) } else { None } } Some ( _ ) => { self . errors . push ( Error :: invalid_field ( decl_type , field_name ) ) ; None } None => { self . errors . push ( Error :: missing_field ( decl_type , field_name ) ) ; None } } }
Validates that the offer target is to a valid child or collection.
Validates that the offer target is to a valid child or collection .
&mut self
target
&'a Option<fsys::Ref>
decl_type
&str
field_name
&str