amazingproducer / 100Days

2019 Attempt at 100 Days of Coding Challenge
1 stars 0 forks source link

Input Validation - Audit Intrinsic Data #36

Closed amazingproducer closed 5 years ago

amazingproducer commented 5 years ago

Let's try a better approach at learning this stuff. In order to validate inputs, we need to audit them! Let's create a program to get as many kinds of information from an input as we can imagine (excluding pattern match checks):

amazingproducer commented 5 years ago

Generated a small set of users in JSON from https://mockaroo.com

Let's make this program take a single JSON user entry as input and return that JSON entry, replacing the value for each of its elements with a JSON object containing the original value and the results of each of the above audits. For example, inputting: {"id":2,"username":"mhouseley1"} would return: {"id":{"value":2,"empty":false,"length":1,"type":"number"},"username":{"value":"mhouseley1","empty":false,"length":10,"type":"string"}}

amazingproducer commented 5 years ago

5cf33ad nearly does the trick, but the "type" value in the newly formed object uses the string from python (str, int, etc) and not a JSON type.