-
Notifications
You must be signed in to change notification settings - Fork 64
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
ProfilesComponent: Add field validation for custom profiles #623
ProfilesComponent: Add field validation for custom profiles #623
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.
Just a few comments from my side! Please have a look at the bug where the None
option is slected!
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.
Just a single comment here!
Other than that, thanks for the good work! 💯
src/app/auth/profiles/json-parse-error-dialog/json-parse-error-dialog.component.html
Outdated
Show resolved
Hide resolved
Co-authored-by: Low Jun Kai, Sean <42912708+seanlowjk@users.noreply.github.com>
Codecov Report
@@ Coverage Diff @@
## master #623 +/- ##
==========================================
+ Coverage 67.71% 67.80% +0.08%
==========================================
Files 73 75 +2
Lines 2187 2196 +9
Branches 201 202 +1
==========================================
+ Hits 1481 1489 +8
Misses 664 664
- Partials 42 43 +1
Continue to review full report at Codecov.
|
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.
The PR is on the right track, but a bit of refactoring can be done to make this more testable.
Let's :
- Move the
Profile
interface, as well as theprofileSchema
into a newprofile.model.ts
module - Export a
isValidProfile
method from this module. This method will use the schema internally - Use
isValidProfile
in the ProfilesComponent - Add some tests for
isValidProfile
…ATcher into assert-profiles.json-fields
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.
Great job with this! 👍 I like how you used the Schema interface in creating a clean way to validate our profiles.json
. Just some minor discussion points.
src/app/core/models/profile.model.ts
Outdated
|
||
const profileSchema: Schema = { | ||
profileName: { required: true, validate: (value) => !!value }, | ||
encodedText: { required: true, validate: (value) => !!value } |
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.
Should we have the extra layer of validation to make sure that encoded text follows the org/repo
format? So the validate function can use regex or any form of string manipulation to verify the encoded text adheres to the right format?
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.
Yup that's a good point. i guess we'll be matching for string/string
?
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.
Yep! 👍
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.
Looks good. @CATcher-org/2021-devs any further comments?
Co-authored-by: Anubhav <35621759+anubh-v@users.noreply.github.com>
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.
LGTM 👍
Summary
Fixes #567
The app proceeds silently if the selected profiles.json does not have a profileName or encodedText field.
(encodedText refers to the repo holding the settings.json / data.csv files)
Proposed Commit Message