{"record":{"id":"dcdf8453c2512035","repo":"larksuite/cli","slug":"s-must-contain-at-least-d-characters","errorCode":null,"errorMessage":"%s must contain at least %d characters","messagePattern":"(.+?) must contain at least (.+?) characters","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shortcuts/common/typed_binder.go","lineNumber":420,"sourceCode":"\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"%s has invalid const: %w\", path, err)\n\t\t}\n\t\texpected, err := decodeJSONValidationValue(expectedJSON)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"%s has invalid const: %w\", path, err)\n\t\t}\n\t\tif !reflect.DeepEqual(value, expected) {\n\t\t\treturn fmt.Errorf(\"%s must equal %v\", path, constraint.Value)\n\t\t}\n\t\treturn nil\n\tcase typedStringShape:\n\t\ttext, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"%s must be a string\", path)\n\t\t}\n\t\tlength := len([]rune(text))\n\t\tif constraint.MinLength != nil && length < *constraint.MinLength {\n\t\t\treturn fmt.Errorf(\"%s must contain at least %d characters\", path, *constraint.MinLength)\n\t\t}\n\t\tif constraint.MaxLength != nil && length > *constraint.MaxLength {\n\t\t\treturn fmt.Errorf(\"%s must contain at most %d characters\", path, *constraint.MaxLength)\n\t\t}\n\t\tif len(constraint.Enum) > 0 && !slices.Contains(constraint.Enum, text) {\n\t\t\treturn fmt.Errorf(\"%s must be one of: %s\", path, strings.Join(constraint.Enum, \", \"))\n\t\t}\n\t\treturn nil\n\tcase typedBooleanShape:\n\t\tboolean, ok := value.(bool)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"%s must be a boolean\", path)\n\t\t}\n\t\tif len(constraint.Enum) > 0 && !slices.Contains(constraint.Enum, boolean) {\n\t\t\treturn fmt.Errorf(\"%s has an unsupported boolean value\", path)\n\t\t}\n\t\treturn nil\n\tcase typedIntegerShape:","sourceCodeStart":402,"sourceCodeEnd":438,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/shortcuts/common/typed_binder.go#L402-L438","documentation":"A string-shape field with a MinLength constraint received a string shorter (in runes) than the declared minimum; validation fails with the required count in the message. Thrown by validateJSONValueAgainstShape in the typedStringShape branch after the type check.","triggerScenarios":"Passing an empty or too-short string to a constrained field — e.g. name: \"\" where min is 1, or a 3-char token where min is 8. Length is measured in runes, so multibyte characters count individually.","commonSituations":"Empty-string defaults from unset config variables; truncated user input; developers sending \"-\" or \" \" placeholders to satisfy required fields when MinLength > 1.","solutions":["Supply a string at least as long as the declared minimum shown in the error.","Omit the field if it is optional and you have no value.","Check the config/env source — an unset variable often yields an empty string default.","If the schema's minimum is wrong, update the MinLength constraint."],"exampleFix":"// before\nname := os.Getenv(\"DOC_NAME\") // \"\" when unset\nparams.Set(\"name\", name)      // min 1\n\n// after\nname := os.Getenv(\"DOC_NAME\")\nif name == \"\" { return errors.New(\"DOC_NAME is required\") }\nparams.Set(\"name\", name)","handlingStrategy":"validation","validationCode":"if utf8.RuneCountInString(s) < minLen { return fmt.Errorf(\"needs at least %d characters\", minLen) }","typeGuard":"func meetsMinLength(s string, min int) bool { return utf8.RuneCountInString(s) >= min }","tryCatchPattern":"if err := binder.Set(\"name\", s); err != nil {\n    re := regexp.MustCompile(`must contain at least (\\d+)`)\n    if m := re.FindStringSubmatch(err.Error()); m != nil {\n        return fmt.Errorf(\"name needs at least %s characters (got %d)\", m[1], utf8.RuneCountInString(s))\n    }\n    return err\n}","preventionTips":["Fail fast on empty env/config strings before binding.","Remember length counts runes, not bytes, when validating multibyte text.","Never use placeholder characters to satisfy required fields."],"tags":["go","schema-validation","string-length","min-length"],"backgroundTag":"string-min-length-violated","analyzedSha":"7fd6ef3c07182257ce776cdc5a614e122d5bd4b3","analyzedAt":"2026-09-04T21:17:44.649Z","contentChangedAt":"2026-09-04T21:17:44.649Z","schemaVersion":2},"datasetVersion":"2026-09-12T02:17:10.037Z"}