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

Method validateInput

cmds/cmd_create.go:135–155  ·  view source on GitHub ↗
(value, field string, allowSpace bool)

Source from the content-addressed store, hash-verified

133}
134
135func (c *createCmd) validateInput(value, field string, allowSpace bool) error {
136 trimmed := strings.TrimSpace(value)
137 if trimmed == "" {
138 return fmt.Errorf("%s cannot be empty", field)
139 }
140
141 if strings.Contains(trimmed, "..") {
142 return fmt.Errorf("%s cannot contain '..'", field)
143 }
144
145 // Keep generated files inside workspace and avoid invalid file-name characters.
146 if strings.ContainsAny(trimmed, "<>:\"/\\|?*") {
147 return fmt.Errorf("%s contains invalid file-name characters", field)
148 }
149
150 if !allowSpace && strings.Contains(trimmed, " ") {
151 return fmt.Errorf("%s cannot contain spaces", field)
152 }
153
154 return nil
155}
156
157// validatePlatformName validates platform name format
158func (c *createCmd) validatePlatformName(name string) error {

Callers 3

validatePlatformNameMethod · 0.95
validateProjectNameMethod · 0.95
validatePortNameMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected