{"record":{"id":"f86590890923fcf4","repo":"ent/ent","slug":"value-is-greater-than-the-required-rune-length","errorCode":null,"errorMessage":"value is greater than the required rune length","messagePattern":"value is greater than the required rune length","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"schema/field/field.go","lineNumber":263,"sourceCode":"// Operation fails if the length of the string is greater than the given value.\nfunc (b *stringBuilder) MaxLen(i int) *stringBuilder {\n\tb.desc.Size = i\n\tb.desc.Validators = append(b.desc.Validators, func(v string) error {\n\t\tif len(v) > i {\n\t\t\treturn errors.New(\"value is greater than the required length\")\n\t\t}\n\t\treturn nil\n\t})\n\treturn b\n}\n\n// MaxRuneLen adds a rune length validator for this field.\n// Operation fails if the rune count of the string is greater than the given value.\nfunc (b *stringBuilder) MaxRuneLen(i int) *stringBuilder {\n\tb.desc.Size = i\n\tb.desc.Validators = append(b.desc.Validators, func(v string) error {\n\t\tif utf8.RuneCountInString(v) > i {\n\t\t\treturn errors.New(\"value is greater than the required rune length\")\n\t\t}\n\t\treturn nil\n\t})\n\treturn b\n}\n\n// Validate adds a validator for this field. Operation fails if the validation fails.\nfunc (b *stringBuilder) Validate(fn func(string) error) *stringBuilder {\n\tb.desc.Validators = append(b.desc.Validators, fn)\n\treturn b\n}\n\n// Default sets the default value of the field.\nfunc (b *stringBuilder) Default(s string) *stringBuilder {\n\tb.desc.Default = s\n\treturn b\n}\n","sourceCodeStart":245,"sourceCodeEnd":281,"githubUrl":"https://github.com/ent/ent/blob/69d5d4deb19599f129166634e09d33addcf3f2cc/schema/field/field.go#L245-L281","documentation":"Validator error registered by stringBuilder.MaxRuneLen: the string's rune (character) count exceeds the configured maximum, rejecting Create/Save at runtime. Counts Unicode runes rather than bytes, matching MaxRuneLen's character-oriented semantics.","triggerScenarios":"Thrown at schema/field/field.go:263 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Shorten the value so its character count is within the limit","Raise the MaxRuneLen bound in the schema if it is too strict","Use MaxLen instead if byte-length (storage size) is the intended constraint"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"69d5d4deb19599f129166634e09d33addcf3f2cc","analyzedAt":"2026-09-03T16:51:39.799Z","contentChangedAt":"2026-09-03T16:51:39.799Z","schemaVersion":2},"datasetVersion":"2026-09-11T00:17:11.886Z"}