File tree Expand file tree Collapse file tree 1 file changed +21
-4
lines changed
Expand file tree Collapse file tree 1 file changed +21
-4
lines changed Original file line number Diff line number Diff line change @@ -2,15 +2,32 @@ import { isEmpty } from 'lodash';
22import { GitHubQuery , ProjectQueryType , QueryType } from './types' ;
33
44export const isValid = ( query : GitHubQuery ) : boolean => {
5- // The current requirement is that the query has a querytype
6- // TODO: have each option implement a validation function
7- if ( query . queryType === QueryType . Projects ) {
8- if ( isEmpty ( query . options ?. organization ) && query . options ?. kind === ProjectQueryType . ORG ) {
5+ if ( query . queryType === QueryType . Repositories ) {
6+ if ( isEmpty ( query . owner ) ) {
7+ return false ;
8+ }
9+ }
10+ if (
11+ query . queryType === QueryType . Commits ||
12+ query . queryType === QueryType . Contributors ||
13+ query . queryType === QueryType . Tags ||
14+ query . queryType === QueryType . Releases ||
15+ query . queryType === QueryType . Labels ||
16+ query . queryType === QueryType . Milestones ||
17+ query . queryType === QueryType . Vulnerabilities ||
18+ query . queryType === QueryType . Stargazers
19+ ) {
20+ if ( isEmpty ( query . owner ) || isEmpty ( query . repository ) ) {
921 return false ;
1022 }
23+ }
24+ if ( query . queryType === QueryType . Projects ) {
1125 if ( isEmpty ( query . options ?. user ) && query . options ?. kind === ProjectQueryType . USER ) {
1226 return false ;
1327 }
28+ if ( isEmpty ( query . options ?. organization ) ) {
29+ return false ;
30+ }
1431 }
1532 return ! ! query . queryType ;
1633} ;
You can’t perform that action at this time.
0 commit comments