Skip to content

Commit

Permalink
add flight validation + add date checking
Browse files Browse the repository at this point in the history
  • Loading branch information
aboutdavid committed May 16, 2024
1 parent 5fff99e commit 72608b4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion add_flight.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from datetime import datetime

def is_valid_iata(code):
return re.fullmatch(r'[A-Z]{2}\d{1,4}', code) is not None
return re.fullmatch(r'[A-Za-z0-9]*[A-Za-z][A-Za-z0-9]*\d{1,4}', code) is not None
def is_valid_date(date):
# Check if the date matches the format YYYY-MM-DD
try:
Expand Down
4 changes: 4 additions & 0 deletions ci.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ config.events.forEach(async event => {
event.users.map(async user => {
var flights = await Promise.all(user.flights.map(async flight => {
var res
if (!/^\d{4}-\d{2}-\d{2}$/.test(flight.date)) {
console.error(`Invalid date in event ${event.name}: ${flight.code} on ${flight.date} for user ${user.name}/${user.id}`)
process.exit(1)
}
try {
res = await utils.checkFlight(flight.code, new Date(flight.date));
} catch (e) {
Expand Down

0 comments on commit 72608b4

Please sign in to comment.