MCPcopy Index your code
hub / github.com/coder/coder / createVariableValidator

Function createVariableValidator

cli/templatepush.go:673–685  ·  view source on GitHub ↗
(variable codersdk.TemplateVersionVariable)

Source from the content-addressed store, hash-verified

671}
672
673func createVariableValidator(variable codersdk.TemplateVersionVariable) func(string) error {
674 return func(s string) error {
675 if variable.Required && s == "" && variable.DefaultValue == "" {
676 return xerrors.New("value is required")
677 }
678 if variable.Type == "number" && s != "" {
679 if _, err := strconv.ParseFloat(s, 64); err != nil {
680 return xerrors.Errorf("must be a valid number, got: %q", s)
681 }
682 }
683 return nil
684 }
685}

Callers 2

promptForNumberVariableFunction · 0.85
promptForStringVariableFunction · 0.85

Calls 2

NewMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected