-
-
Notifications
You must be signed in to change notification settings - Fork 798
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[legacy-framework] show an error if model name is invalid in blitz generate
#2802
Conversation
There was a problem hiding this 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!
Instead of using console.warn
, we should use Blitz's log
function log.error(...)
. It's already imported into this file.
Apart from that, we should check if the model name contains only valid characters instead of checking for particular invalid symbols, e.g. :
inside of the model name is only one of the invalid characters. Model names should satisfy the following expression: [A-Za-z][A-Za-z0-9_]*
.
Thanks for review, I will look into these issues. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sorry for complicating things, but we just merged a similar PR (#2813), which was also handling model names, but it only checks for reserved words.
However, there was a new function validateModelName
added, and I'm wondering if we can combine your changes into this function? What do you think about adding the check to the validateModelName
and throwing an error in a similar way?
I just looked at that PR and function and I thing you have an great idea. I'm going to work on that |
Co-authored-by: Aleksandra Sikora <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, thanks again!
blitz generate
blitz generate
blitz generate
Closes: blitz-js/legacy-framework#238
What are the changes and their implications?
Blitz-cli generate options will check if model name contains
:
. If it does, it will throw an error. Usually this happens when someone forget to pass model name e.g.blitz generate all name:string
Bug Checklist
Feature Checklist