# Way to check String is a valid account

**URL:** <https://talk.jelurida.com/t/way-to-check-string-is-a-valid-account/329>\
**Category:** Developers\
**Created:** [7 May 2021 17:56 UTC](https://talk.jelurida.com/t/way-to-check-string-is-a-valid-account/329 "2021-05-07T17:56:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Malnemark](https://talk.jelurida.com/letter_avatar_proxy/v4/letter/m/0ea827/32.png) [@Malnemark](https://talk.jelurida.com/u/Malnemark)\
**Post date:** [7 May 2021 17:56 UTC](https://talk.jelurida.com/t/way-to-check-string-is-a-valid-account/329/1 "2021-05-07T17:56:14Z")

</div>

Hi devs, I am looking for the best way to assert that a message content is an ardor account RS.

```
int version = attachment.getInt("version.PrunablePlainMessage");
if (version == 1){
    JO messageObj = attachment.getJo("message");
    String specialAccount = messageObj.getString("specialAccount");
    // here, I want to make sure that specialAccount is a proper accountRs
}
```

---

<div class="post-metadata">

**Author:** ![petko.petkov](https://talk.jelurida.com/letter_avatar_proxy/v4/letter/p/eb8c5e/32.png) [@petko.petkov](https://talk.jelurida.com/u/petko.petkov)\
**Post date:** [8 May 2021 06:58 UTC](https://talk.jelurida.com/t/way-to-check-string-is-a-valid-account/329/2 "2021-05-08T06:58:42Z")

</div>

Hi,

Maybe use the `nxt.util.ReedSolomon.decode` method and check if the result is encoded to the same string - see `Convert.rsDecode`. You need to remove the account prefix from your string and convert it to UPPERCASE.

---

<div class="post-metadata">

**Author:** ![sergi](https://talk.jelurida.com/user_avatar/talk.jelurida.com/sergi/32/21_2.png) [@sergi](https://talk.jelurida.com/u/sergi)\
**Post date:** [8 May 2021 07:50 UTC](https://talk.jelurida.com/t/way-to-check-string-is-a-valid-account/329/3 "2021-05-08T07:50:11Z")

</div>

An Ardor RS account is just an encoding of a 64 bit integer using Reed Solomon to add some checksum data. Using the tools above will check that encoding to make sure it's well formed. But that only means the encoding is correct and you get a 64 bit integer.

If you want to check, in addition, if that 64 bit unsigned integer account id is [announced](https://ardordocs.jelurida.com/Faq#How_to_announce_my_public_key) on the blockchain you can use the `GetAccount` API call and pass the RS or integer to the `account` parameter. You will get an error for unannounced accounts and the public key for announced accounts. As a bonus, if you send the RS string there it will also report a malformed Reed Solomon encoding. So you get both checks in a single call.

---

<div class="post-metadata">

**Author:** ![Malnemark](https://talk.jelurida.com/letter_avatar_proxy/v4/letter/m/0ea827/32.png) [@Malnemark](https://talk.jelurida.com/u/Malnemark)\
**Post date:** [8 May 2021 10:20 UTC](https://talk.jelurida.com/t/way-to-check-string-is-a-valid-account/329/4 "2021-05-08T10:20:10Z")

</div>

Hi both, thanks for your responses! I did use the RsConvertCall as in the following and it seems to work. If the message contained an invalid account, the RsConvert call would return an errorcode instead.

```auto
int version = attachment.getInt("version.PrunablePlainMessage");
if (version == 1){
 JO messageObj = attachment.getJo("message");
 String specialAccount = messageObj.getString("specialAccount");
 JO response = RsConvertCall.create().account(specialAccount).call();

 if(response.getString("accountRS").equals(specialAccount)){
     // String is a valid account.
     // do something...
 }

```
