addNewPolicy - internal helper to validate adding new policies. Can use starts-with with an empty value ("") to allow any content within a form field.
(policyCond policyCondition)
| 400 | // addNewPolicy - internal helper to validate adding new policies. |
| 401 | // Can use starts-with with an empty value ("") to allow any content within a form field. |
| 402 | func (p *PostPolicy) addNewPolicy(policyCond policyCondition) error { |
| 403 | if policyCond.matchType == "" || policyCond.condition == "" { |
| 404 | return errInvalidArgument("Policy fields are empty.") |
| 405 | } |
| 406 | if policyCond.matchType != "starts-with" && policyCond.value == "" { |
| 407 | return errInvalidArgument("Policy value is empty.") |
| 408 | } |
| 409 | p.conditions = append(p.conditions, policyCond) |
| 410 | return nil |
| 411 | } |
| 412 | |
| 413 | // String function for printing policy in json formatted string. |
| 414 | func (p PostPolicy) String() string { |
no test coverage detected