* Validated a number string to contain only digits. * Throws an error if invalid. */
| 56 | * Throws an error if invalid. |
| 57 | */ |
| 58 | static inline void |
| 59 | CheckValidIdentifier(StringView *identifier, const char *fieldId) |
| 60 | { |
| 61 | if (identifier == NULL || identifier->length == 0) |
| 62 | { |
| 63 | return; |
| 64 | } |
| 65 | |
| 66 | for (uint32_t i = 0; i < identifier->length; i++) |
| 67 | { |
| 68 | if (identifier->string[i] < '0' || identifier->string[i] > '9') |
| 69 | { |
| 70 | ereport(ERROR, (errcode(ERRCODE_DOCUMENTDB_BADVALUE), |
| 71 | errmsg("Invalid %s: %.*s", fieldId, identifier->length, |
| 72 | identifier->string), |
| 73 | errdetail_log("Invalid %s: %.*s", fieldId, identifier->length, |
| 74 | identifier->string))); |
| 75 | } |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | |
| 80 | /* |
no outgoing calls
no test coverage detected