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

fix: add validation step to check if the event date is in the future. #751

Merged
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/create-event-workflow-reusable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ jobs:
if(Number(HH) > 23 || Number(HH) < 0 || !(Number(MM) === 0 || Number(MM) === 30)){
core.setFailed(`${time} is an invalid input. Time should be in UTC time zone in "HH:MM"(MM can be 00 or 30), like: 08:30 or 16:00. No PM or AM versions.`);
}
// Validate if the event is in the future
const eventDate = new Date('${{ inputs.date }}T${{ inputs.time }}:00Z');
const currentDate = new Date();
if (eventDate <= currentDate) {
core.setFailed('The event cannot be scheduled in the past.');
Copy link
Member

Choose a reason for hiding this comment

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

please make it more detailed, I mean the error message:

  • specify what was the event date specified by the user
  • specify what is the current time

when user makes a mistake, they make it unintentionally so definitely good to show them in logs what went wrong

}
- name: Checkout repository
uses: actions/checkout@v2
- name: Setup Node.js
Expand Down