0

I know we have a couple of options on the Apex side, but I would like to do that verification without calling the server, is there another option direct on the LWC side?

FYI: I used to use the Id class valueOf(toID) and verify if the return is not an exception.

Elivelton Walter
  • 530
  • 2
  • 14

1 Answers1

2

Even if the ID is a valid ID, you would have no way of knowing if it's a valid ID without calling Apex or a query. This old answer goes into the format of an Id; the basic idea is that you can check for a 15 character string of only letters and numbers, and an optional three-character ending that encodes the uppercase-ness of the first 15 characters. Beyond that, calling the server is required to see if the ID is valid for the current user.

sfdcfox
  • 489,769
  • 21
  • 458
  • 806