-
Notifications
You must be signed in to change notification settings - Fork 8
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
US 5 // Filter resources that have path #1308
US 5 // Filter resources that have path #1308
Conversation
38cd34a
to
10ff91c
Compare
e6c2a92
to
68f4be7
Compare
10ff91c
to
09091f6
Compare
68f4be7
to
9d82891
Compare
Codecov Report
@@ Coverage Diff @@
## us-6/filter-resources-that-contain-value #1308 +/- ##
===========================================================================
Coverage ? 49.46%
===========================================================================
Files ? 194
Lines ? 8374
Branches ? 1934
===========================================================================
Hits ? 4142
Misses ? 4205
Partials ? 27 |
export const isPathMissing = ( | ||
resource: { [key: string]: any }, | ||
path: string | ||
): boolean => { | ||
if (path in resource) { | ||
if (path in resource && path !== '') { |
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.
Is there situation where the path is empty string ?
If so is it better to filter paths when you generate them (just a suggestion)
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, this has been removed in a later PR. The path can never be empty (''
).
export const DOES_NOT_EXIST = 'Does not exist'; | ||
export const EXISTS = 'Exists'; | ||
export const CONTAINS = 'Contains'; | ||
export type PredicateFilterT = typeof EMPTY_VALUE | typeof CONTAINS | null; | ||
|
||
export type PredicateFilterT = | ||
| typeof DOES_NOT_EXIST | ||
| typeof EXISTS | ||
| typeof CONTAINS | ||
| null; |
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.
I suggest use this to be more Typescripty
const PREDICATE_VALUES = [DEFAULT_OPTION, DOES_NOT_EXIST, EXISTS, CONTAINS] as const
;
type TPredicateValues = typeof PREDICATE_VALUES;
and then
type TPredicateValue = TPredicateValues[0 | 1 | 2] or TPredicateValues[number]
and then select by index when you need it TPredicateValues[index]
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.
bon idee! I'll do that in a new PR.
predicatePath: string | null; | ||
predicateFilter: PredicateFilterT | null; | ||
predicateValue: string | null; | ||
predicateFilter: ((resource: Resource) => boolean) | null; |
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.
I think it make sense if the predicateFilter
can be rename it to predicate
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.
this too.
09091f6
to
e00d2a3
Compare
Signed-off-by: Dinika Saxena <[email protected]>
Signed-off-by: Dinika Saxena <[email protected]>
Signed-off-by: Dinika Saxena <[email protected]>
d3ca970
to
da6b3d4
Compare
2781640
into
us-6/filter-resources-that-contain-value
How has this been tested?
Types of changes
Checklist: