Backend API to validate card template / field names before saving

I contribute to AnkiDroid. While fixing card-type rename bugs, we keep
finding small edge cases where AnkiDroid’s own name checks don’t match
what the backend does on save. Rather than keep patching the client, the
AnkiDroid maintainers suggested asking whether these checks could live in
the backend:

Is your feature request related to a problem? Please describe.

When a notetype is saved, Notetype::prepare_for_update normalizes names:

  • NFC-normalizes all names
  • CardTemplate::fix_name strips "; rejects empty or quote-only names
  • NoteField::fix_name strips : { } ", trims, and strips leading # / ^
  • ensure_names_unique appends + to case-insensitive duplicates

No API exposes these rules without saving, so a client that wants to show
“Name already exists” has to copy them, and the copies drift. Example:
in AnkiDroid, renaming Card 2 to "Card 1" (with quotes) gets past the
client-side duplicate check, and the backend then saves it as Card 1+.

This rarely affects real users. The concern is that every client-side
patch adds code that can drift again.

Anki Desktop’s rename dialog doesn’t check for duplicates either, so a
duplicate name there is also saved with + and no warning.

Describe the solution you’d like

A read-only RPC in NotetypesService that runs the existing checks and
returns the result without saving. For example:

rpc CheckNotetypeNames(Notetype) returns (CheckNotetypeNamesResponse);

It would return the normalized names and any problems (duplicate, empty,
quotes only). The save path could call the same function, so the two can’t
get out of step.

Drawback: one more RPC to maintain. It could start as an unstable API if
you’d rather not commit to it yet.

Describe alternatives you’ve considered

  1. Keep the checks in each client. This is what AnkiDroid does now, and
    it keeps drifting.
  2. Smaller per-name helpers, for example
    NormalizeCardTemplateName(String) -> String, with the client still
    comparing for duplicates.
  3. Do nothing. That’s reasonable given the low impact, but then clients
    will keep patching around these cases.

Is this something you’d accept? If so, which shape do you prefer, and
should it be unstable or official? I’m happy to write the PR