-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #51 from r-argentina-programa/fix/wrong-class-subm…
…issions Fix: Incorrect channel submissions
- Loading branch information
Showing
2 changed files
with
94 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,29 @@ | ||
interface IValidateSubmissionDeliveryFormat { | ||
classNumber: number; | ||
delivery: string; | ||
} | ||
|
||
export const validateSubmissionDeliveryFormat = ({ | ||
classNumber, | ||
delivery, | ||
}: IValidateSubmissionDeliveryFormat) => { | ||
const FIRST_LINK_FORMAT_LESSON_NUMBER = 5; | ||
const linkFormatRegex = /github\.com\/[a-zA-Z]/; | ||
if (classNumber < FIRST_LINK_FORMAT_LESSON_NUMBER) { | ||
return true; | ||
} | ||
if ( | ||
classNumber >= FIRST_LINK_FORMAT_LESSON_NUMBER && | ||
linkFormatRegex.test(delivery) | ||
) { | ||
return true; | ||
} | ||
return false; | ||
}; | ||
interface IValidateSubmissionDeliveryFormat { | ||
classNumber: number; | ||
delivery: string; | ||
} | ||
|
||
export const validateSubmissionDeliveryFormat = ({ | ||
classNumber, | ||
delivery, | ||
}: IValidateSubmissionDeliveryFormat) => { | ||
const FIRST_LINK_FORMAT_LESSON_NUMBER = 5; | ||
const codeFormatRegex = /```[^`]+```/; | ||
const linkFormatRegex = /github\.com\/[a-zA-Z]/; | ||
|
||
if ( | ||
classNumber < FIRST_LINK_FORMAT_LESSON_NUMBER && | ||
codeFormatRegex.test(delivery) | ||
) { | ||
return true; | ||
} | ||
|
||
if ( | ||
classNumber >= FIRST_LINK_FORMAT_LESSON_NUMBER && | ||
linkFormatRegex.test(delivery) | ||
) { | ||
return true; | ||
} | ||
|
||
return false; | ||
}; |