You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Internally, many of our data types are represented as strings, but we can perform some form of validation on these strings.
For example, a 'game id' normally looks like '2018021000', there are a few rules for what type of value this can actually be, since the first 4 characters are the season, the next 2 are the game type, and the next 4 are the game number.
Rather than use functions to validate all of our values, we can make custom classes like GameID that will do all this error checking for us. This will make it easy to add exceptions, black lists, whitelists etc.. since this can be done at the class instance level and the changes will automatically propagate through the entire program.
The text was updated successfully, but these errors were encountered:
I recommend adding a Types module and start defining our internal Types, like GameID in this module. Then you can import Types wherever needed to perform the validation.
Internally, many of our data types are represented as strings, but we can perform some form of validation on these strings.
For example, a 'game id' normally looks like '2018021000', there are a few rules for what type of value this can actually be, since the first 4 characters are the season, the next 2 are the game type, and the next 4 are the game number.
Rather than use functions to validate all of our values, we can make custom classes like GameID that will do all this error checking for us. This will make it easy to add exceptions, black lists, whitelists etc.. since this can be done at the class instance level and the changes will automatically propagate through the entire program.
The text was updated successfully, but these errors were encountered: