FoalTS / foal

Full-featured Node.js framework, with no complexity. 🚀 Simple and easy to use, TypeScript-based and well-documented.
https://foalts.org/
MIT License
1.88k stars 137 forks source link

[CLI] Improve logging of script arguments validation errors #1251

Closed LoicPoullain closed 3 months ago

LoicPoullain commented 3 months ago

Issue

When running a shell script with invalid arguments, Foal does not display all the errors.

For example, with this schema and this command call, we only get the following log message:

export const schema = {
  type: 'object', 
  properties: {
    email: { type: 'string', format: 'email', maxLength: 2 },
    password: { type: 'string' },
    n: { type: 'number', maximum: 10 }
  },
  required: ['password']
};
foal run my-script email=bar n=11
Error: The command line arguments must match format "email".

Solution and steps

Script error: arguments must have required property 'password'.
Script error: the value of "email" must NOT have more than 2 characters.
Script error: the value of "email" must match format "email".
Script error: the value of "n" must be <= 10.

Checklist