validateName rejects empty names and names containing whitespace. JSON itself permits arbitrary key strings, but whitespace would make the provider unusable from the shell flag parser.
(name string)
| 181 | // itself permits arbitrary key strings, but whitespace would make the |
| 182 | // provider unusable from the shell flag parser. |
| 183 | func validateName(name string) error { |
| 184 | if name == "" { |
| 185 | return fmt.Errorf("empty name: %w", ErrInvalidName) |
| 186 | } |
| 187 | for _, r := range name { |
| 188 | if r == ' ' || r == '\t' || r == '\n' || r == '\r' { |
| 189 | return fmt.Errorf("name %q contains whitespace: %w", name, ErrInvalidName) |
| 190 | } |
| 191 | } |
| 192 | return nil |
| 193 | } |
| 194 | |
| 195 | // applyListPatch combines current with patch according to patch.Op. |
| 196 | // The function preserves input order and de-duplicates results so a |