-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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
add the package name custom validate to take effect #276
Conversation
Thank you for your PR! |
in the meta.js , if user define a validate option in the name prompt , the validate option will be overitten , it will not work。 prompts: {
name: {
type: 'string',
required: true,
label: 'Project name',
validate: function (input) {
return input === 'custom' ? 'can not input `custom`' : true
}
}
} #73 , Add a package name validate, like this: function setValidateName (opts) {
opts.prompts.name.validate = function (name) {
var its = validateName(name)
if (!its.validForNewPackages) {
var errors = (its.errors || []).concat(its.warnings || [])
return 'Sorry, ' + errors.join(' and ') + '.'
}
return true
}
} so, the validate function I defined in meta.js will be overwritten by it |
Thanks! |
Sometimes , we need a unified format for name ,example vue-router, vue-resource and so on. I think you should keep it |
Maybe you can give a configuration item, it's value is a String or RegExp. |
Indeed,I could now see your use-cases. |
I see the #73 ,The add the validation for package name , it is really nice , but it will be overwritten the user custom validate function , so , I fix it.