Problems

Validate User Record

MediumError Handling

Validate a user JSON: must have string name (non-empty) and numeric age 0–150. Throw ValidationError with messages name required or invalid age (check name first). Print valid or the caught error message.

Input: one JSON object. Output: valid or the message.

Your program reads from stdin and prints to stdout.

Example 1

Input: {"name":"Ada","age":36}

Output: valid

Hints

JavaScriptValidationCustom Errors