* @brief Validate a UID string. * * UIDs must be alphanumeric plus hyphens and underscores, 1-64 characters. * The REST API UID format is "node_N" (see NodeUidMapper::GenerateUid). * * @param uid The UID to validate. * @return true if valid, false otherwise. */
| 213 | * @return true if valid, false otherwise. |
| 214 | */ |
| 215 | bool ValidateUid(const std::string& uid) |
| 216 | { |
| 217 | if (uid.empty() || uid.size() > 64) |
| 218 | return false; |
| 219 | return std::all_of(uid.begin(), uid.end(), [](char c) { |
| 220 | return std::isalnum(static_cast<unsigned char>(c)) || c == '-' || c == '_'; |
| 221 | }); |
| 222 | } |
| 223 | |
| 224 | /** |
| 225 | * @brief Validate a property key string. |
no test coverage detected