// ApplyAndValidateName applies some rules to make sure that the connector's data are setup correctly.
ApplyAndValidateName applies some rules to make sure that the connector's data are setup correctly.
// ApplyAndValidateName applies some rules to make sure that the connector ' s data are setup correctly .
func (c *CreateUpdateConnectorPayload) ApplyAndValidateName() error {
	if c.Config != nil {
		value, found := c.Config["name"]
		if found {
			configName, ok := value.(string)
			if !ok {
				return fmt.Errorf(`config["name"] is not type of string`)
			}
			if c.Name != "" && configName != c.Name {
				return fmt.Errorf(`config["name"] [%s] and name [%s] do not match`, configName, c.Name)
			}
			if c.Name == "" {
				c.Name = configName
			}
			return nil
		}
		if c.Name == "" {
			return fmt.Errorf("name is required")
		}
		c.Config["name"] = c.Name
	}
	return nil
}
func ( c * CreateUpdateConnectorPayload ) ApplyAndValidateName ( ) error { if c . Config != nil { value , found := c . Config [ " " ] if found { configName , ok := value . ( string ) if ! ok { return fmt . Errorf ( `config["name"] is not type of string` ) } if c . Name != " " && configName != c . Name { return fmt . Errorf ( `config["name"] [%s] and name [%s] do not match` , configName , c . Name ) } if c . Name == " " { c . Name = configName } return nil } if c . Name == " " { return fmt . Errorf ( " " ) } c . Config [ " " ] = c . Name } return nil }
ApplyAndValidateName applies some rules to make sure that the connector's data are setup correctly.
ApplyAndValidateName applies some rules to make sure that the connector ' s data are setup correctly .
// if not found in config, then set it from connector.Name if it's there, otherwise fire name missing error.