isClientRecordId function

bool isClientRecordId(
  1. String model,
  2. String id
)

Whether id is a record id a client may send for model (its config name, or its snake_case prefix) on create or batch create: exactly ^<model_snake>_[0-7][0-9A-HJKMNP-TV-Z]{25}$ (04 ยง2.2), the platform's isClientRecordId. Lowercase, a wrong prefix, another length or a first character past 7 are refused.

Implementation

bool isClientRecordId(String model, String id) {
  final prefix = '${toSnakeCase(model)}_';
  return id.startsWith(prefix) &&
      _clientUlid.hasMatch(id.substring(prefix.length));
}