You have several options, please have a look at the docs:
- Use pattern property, and use a regular expression to enforce valid code.
- Use anyOf with two schemas. Each schema will validate integer or string type.
- If you have all country codes (very easy to get) you might enforce exact values with an enum list.