Announcements
This site is in read only until July 22 as we migrate to a new platform; refer to this community post for more details.
Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Validate format of input

Hi All,

Have written an API proxy that accepts two query parameters.

1st query param is 'code'

2nd query param is 'id'

The query parameter 'id' has fixed format based on value of 'code'

code

Format for id


AT

1 block of 9 characters

BE

1 block of 10 digits


How do I check format of 'id' based on code?

Here is few concrete examples of what am trying to achieve.

/verify?code=AT&id=123{"errorCode": 1001, "errorCode": "Invalid parameter"}
/verify?code=AT&id=12311BBcdpass through
/verify?code=BE&id=12345678AA{"errorCode": 1001, "errorCode": "Invalid parameter"}
/verify?code=BE&id=1234567890pass through

There are 22 codes and each code have specific format. Most are simple format check, some are a bit complex.

What's the best way to achieve this?

Thanks in advance.

0 5 540
5 REPLIES 5