Skip to content

Conversation

@EmadBeltaje
Copy link
Contributor

Hello, so i have been using dcli with my dart CLI apps and i faced this limitation where i can't show my own error message so i figured out, why not to add it, it would be amazing to tell user what went wrong in any way i like, so in this pull request i did that and now we can use ask function this way to show our own custom error message.

String name = ask( 'Enter your name', required: true, validator: Ask.regExp(r'^[a-zA-Z\s_]+$'), // name must be alphabetic customErrorMessage: 'Please enter a valid name!', ); // if input was not alphabetic for ex: 1999 it will show our custom error message // instead of showing default message -> Input does not match: ^[a-zA-Z\s_]+$
  • Add new parameter called customErrorMessage to ask function 🚀
  • Write test code for the new feature 🧪
@EmadBeltaje EmadBeltaje changed the title Add custom error message for ask() function Add custom error message parameter for ask() function Aug 6, 2024
Copy link
Collaborator

@bsutton bsutton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the contribution!
I add a few comments and requested a few fixes - otherwise I'm happy to merge.

I suspect that you are not using the standard dart indentation.
Can you please reformat with 'dart format'.

- add the custom validation message to the required validator - add document for custom error message parameter - make the custom error message optional - update test code
@EmadBeltaje
Copy link
Contributor Author

thank you for the feedback, i made all the needed changes hope now everything is good 😁

@EmadBeltaje EmadBeltaje requested a review from bsutton August 7, 2024 15:03
@bsutton bsutton merged commit 972548b into onepub-dev:master Aug 7, 2024
@bsutton
Copy link
Collaborator

bsutton commented Aug 8, 2024

dcli 6.0 has been released with this pr included.

Greatly appreciate your work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants