Skip to content
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

Checking validity of names #55

Merged
merged 13 commits into from Jan 21, 2021
Merged

Checking validity of names #55

merged 13 commits into from Jan 21, 2021

Conversation

ggabriel96
Copy link
Owner

@ggabriel96 ggabriel96 commented Jan 20, 2021

  • added is_alphabetic, which checks that a character is within a-z or A-Z
  • added is_numeric, which checks that a character is within 0-9
  • added is_valid_name, which checks if a string:
    • is non-empty
    • first character is_alphabetic
    • last character is_alphabetic, or is_numeric if its length is > 1
    • all characters are alphabetic or numeric or - or _
  • added is_valid_abbrev, which checks if a string is empty or is one character and it is_alphabetic or is_numeric

With that, added checks for validity of names of arguments and programs with is_valid_name and argument abbreviations with is_valid_abbrev. The check for empty argument name is separate to have a clearer message. Didn't think the same was necessary for programs.

Something "unrelated" that I've done is centralize the validations on Arg in the validate_arg function, so the factory functions construct an Arg, call validate_arg with it, and then return it.

Also added some unit tests to check that is_valid_name and is_valid_abbrev are somewhat correct. This is sorta provisional, since these functions require automated generation of input.

@ggabriel96 ggabriel96 added the enhancement New feature or request label Jan 20, 2021
@ggabriel96 ggabriel96 self-assigned this Jan 20, 2021
@ggabriel96 ggabriel96 added this to In progress in Roadmap to 1.0 via automation Jan 20, 2021
@ggabriel96 ggabriel96 merged commit 516e9ed into main Jan 21, 2021
Roadmap to 1.0 automation moved this from In progress to Done Jan 21, 2021
@ggabriel96 ggabriel96 deleted the check-name branch January 21, 2021 02:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Development

Successfully merging this pull request may close these issues.

None yet

1 participant