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

Modify validation of names and related tests #37

Merged

Conversation

Vision-2000
Copy link

@Vision-2000 Vision-2000 commented Mar 19, 2024

close #22
close #36

Name format is now as follows:
Alphabet, repeat :special character followed immediately by alphabet OR just alphabet

Special characters allowed: \ / -

@Vision-2000 Vision-2000 added type.Bug A bug priority.Low Unlikely to do labels Mar 19, 2024
@Vision-2000 Vision-2000 added this to the v1.2 milestone Mar 19, 2024
@Vision-2000 Vision-2000 self-assigned this Mar 19, 2024
Copy link

codecov bot commented Mar 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 56.37%. Comparing base (f61ce65) to head (3bf9e83).

Additional details and impacted files
@@             Coverage Diff              @@
##             master      #37      +/-   ##
============================================
- Coverage     56.42%   56.37%   -0.05%     
+ Complexity      478      477       -1     
============================================
  Files            97       97              
  Lines          2047     2047              
  Branches        236      236              
============================================
- Hits           1155     1154       -1     
  Misses          841      841              
- Partials         51       52       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Vision-2000 Vision-2000 marked this pull request as ready for review March 19, 2024 16:55
@Vision-2000 Vision-2000 modified the milestones: v1.2, v1.3 Mar 21, 2024
Comment on lines 42 to 51
// name has trailing spaces, all other attributes same -> returns false
String nameWithTrailingSpaces = VALID_NAME_BOB + " ";
editedBob = new PatientBuilder(BOB).withName(nameWithTrailingSpaces).build();
assertFalse(BOB.isSamePatient(editedBob));

Choose a reason for hiding this comment

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

why is this testcase being removed?

Copy link
Author

Choose a reason for hiding this comment

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

The new regex match string does not allow for trailing spaces. This is beacuse there is no String#trim() being called in the constructor of the Name object, and it is the responsibility of the parser to remove trailing spaces. For example if some route takes in user input " NAME " as the string and does not call String#trim(), that should not count as a valid name.

Copy link

@jeong-jaeho jeong-jaeho left a comment

Choose a reason for hiding this comment

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

LGTM except some minor details


// valid name
assertTrue(Name.isValidName("peter jack")); // alphabets only
assertTrue(Name.isValidName("12345")); // numbers only

Choose a reason for hiding this comment

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

Why is this case being removed?

Copy link
Author

Choose a reason for hiding this comment

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

Because we're disallowing numbers. If you mean that it should be moved to a negative test, I could do that

Copy link

@jeong-jaeho jeong-jaeho left a comment

Choose a reason for hiding this comment

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

LGTM.

@jeong-jaeho jeong-jaeho merged commit 84ac2a0 into AY2324S2-CS2103T-T14-2:master Apr 4, 2024
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority.Low Unlikely to do type.Bug A bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Change validation of names Bug: Adding names with / or \
3 participants