valuesFromForm returns a function that extracts values from the form field.
(name string, limit uint)
| 233 | |
| 234 | // valuesFromForm returns a function that extracts values from the form field. |
| 235 | func valuesFromForm(name string, limit uint) ValuesExtractor { |
| 236 | if limit == 0 { |
| 237 | limit = 1 |
| 238 | } |
| 239 | return func(c *echo.Context) ([]string, ExtractorSource, error) { |
| 240 | if c.Request().Form == nil { |
| 241 | _, _ = c.MultipartForm() // we want to trigger c.request.ParseMultipartForm(c.formParseMaxMemory) |
| 242 | } |
| 243 | values := c.Request().Form[name] |
| 244 | if len(values) == 0 { |
| 245 | return nil, ExtractorSourceForm, errFormExtractorValueMissing |
| 246 | } |
| 247 | if len(values) > int(limit)-1 { |
| 248 | values = values[:limit] |
| 249 | } |
| 250 | result := append([]string{}, values...) |
| 251 | return result, ExtractorSourceForm, nil |
| 252 | } |
| 253 | } |
searching dependent graphs…