MCPcopy
hub / github.com/gofiber/fiber / matchConstraint

Method matchConstraint

constraint.go:201–223  ·  view source on GitHub ↗

matchConstraint validates a parameter against this constraint.

(param string)

Source from the content-addressed store, hash-verified

199
200// matchConstraint validates a parameter against this constraint.
201func (c *Constraint) matchConstraint(param string) bool {
202 handler := c.handler
203 if handler == nil {
204 handler = findConstraintHandler(c.Name, nil, nil)
205 if handler == nil {
206 handler = findConstraintHandler(resolveConstraintName(c.Name), nil, nil)
207 }
208 if handler == nil {
209 return true
210 }
211 c.handler = handler
212 if analyser, ok := handler.(ConstraintAnalyzer); ok {
213 if typed, err := analyser.Analyze(c.Data); err == nil {
214 c.typedData = typed
215 }
216 }
217 c.ID = constraintNameToID[handler.Name()]
218 }
219 if len(c.typedData) > 0 {
220 return handler.Execute(param, c.typedData)
221 }
222 return handler.Execute(param, stringArgsToAny(c.Data))
223}
224
225// --- Built-in constraint types ---
226

Calls 6

findConstraintHandlerFunction · 0.85
resolveConstraintNameFunction · 0.85
stringArgsToAnyFunction · 0.85
AnalyzeMethod · 0.65
NameMethod · 0.65
ExecuteMethod · 0.65