Skip to content

Commit

Permalink
add validator for empty repo name
Browse files Browse the repository at this point in the history
  • Loading branch information
AlphaBeta1906 committed Jan 30, 2022
1 parent 3506dbe commit aea94fb
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion pyGinit/inquirer.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
from prompt_toolkit.validation import Validator, ValidationError
from .gitignoreList import gitignore

class InputValidator(Validator):
def validate(self,document):
if not document.text:
raise ValidationError(
message="Repo name must not empty",
cursor_position=len(document.text)) # Move cursor to end

licenses = [
"None",
"MIT",
Expand All @@ -10,7 +18,12 @@
]

questions = [
{"type": "input", "name": "repo_name", "message": "Enter the name of your repo : "},
{
"type": "input",
"name": "repo_name",
"message": "Enter the name of your repo : ",
"validate": InputValidator
},
{
"type": "input",
"name": "description",
Expand Down

0 comments on commit aea94fb

Please sign in to comment.