PostValueString same as `PostValue` method but it reports an error if the value with key equals to "name" does not exist.
(name string)
| 1962 | // PostValueString same as `PostValue` method but it reports |
| 1963 | // an error if the value with key equals to "name" does not exist. |
| 1964 | func (ctx *Context) PostValueString(name string) (string, error) { |
| 1965 | values, err := ctx.PostValues(name) |
| 1966 | if err != nil { |
| 1967 | return "", err |
| 1968 | } |
| 1969 | |
| 1970 | if len(values) == 0 { // just in case. |
| 1971 | return "", ErrEmptyForm |
| 1972 | } |
| 1973 | |
| 1974 | return values[len(values)-1], nil |
| 1975 | } |
| 1976 | |
| 1977 | // PostValue returns the last parsed form data from POST, PATCH, |
| 1978 | // or PUT body parameters based on a "name". |
no test coverage detected