MCPcopy Create free account
hub / github.com/celer-pkg/celer / validatePortName

Method validatePortName

cmds/cmd_create.go:168–194  ·  view source on GitHub ↗

validatePortName validates port name@version format

(nameVersion string)

Source from the content-addressed store, hash-verified

166
167// validatePortName validates port name@version format
168func (c *createCmd) validatePortName(nameVersion string) error {
169 if strings.TrimSpace(nameVersion) == "" {
170 return fmt.Errorf("port name cannot be empty")
171 }
172 if !strings.Contains(nameVersion, "@") {
173 return fmt.Errorf("port must be in name@version format (e.g., opencv@4.8.0)")
174 }
175 parts := strings.Split(nameVersion, "@")
176 if len(parts) != 2 {
177 return fmt.Errorf("invalid port format, expected name@version")
178 }
179
180 name := strings.TrimSpace(parts[0])
181 version := strings.TrimSpace(parts[1])
182 if name == "" || version == "" {
183 return fmt.Errorf("invalid port format, expected name@version")
184 }
185
186 if err := c.validateInput(name, "port name", false); err != nil {
187 return err
188 }
189 if err := c.validateInput(version, "port version", false); err != nil {
190 return err
191 }
192
193 return nil
194}
195
196func (c *createCmd) completion(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
197 var suggestions []string

Callers 2

doCreateMethod · 0.95
TestCreateCmd_ValidationFunction · 0.95

Calls 1

validateInputMethod · 0.95

Tested by 1

TestCreateCmd_ValidationFunction · 0.76