MCPcopy Create free account
hub / github.com/astercloud/aster / validateString

Method validateString

pkg/memory/schema.go:81–93  ·  view source on GitHub ↗

validateString 验证字符串

(value string)

Source from the content-addressed store, hash-verified

79
80// validateString 验证字符串
81func (s *JSONSchema) validateString(value string) error {
82 if s.MinLength != nil && len(value) < *s.MinLength {
83 return fmt.Errorf("string length %d is less than minLength %d", len(value), *s.MinLength)
84 }
85
86 if s.MaxLength != nil && len(value) > *s.MaxLength {
87 return fmt.Errorf("string length %d exceeds maxLength %d", len(value), *s.MaxLength)
88 }
89
90 // TODO: 支持 Pattern 正则验证
91
92 return nil
93}
94
95// validateValue 验证任意类型的值
96func (s *JSONSchema) validateValue(value any) error {

Callers 1

ValidateContentMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected