Hacker News new | ask | show | jobs
by kalleboo 4347 days ago
Example: Postal codes. Say you're transferring an address in JSON and you have a postal code field. In the UK, postal codes are strings (e.g. "BS42BG"), easy enough. Now, someone enters a US postal code (90505). Should we transfer it as a number, or a string?
1 comments

Definitely as a string. Numbers aren't things that have digits. Numbers are things you do math with.
OK, that's logical. So where do we specify this without a schema? What happens if a client sends a number instead of a string to the server? Should it accept it and convert it, or return an error?