26 lines
603 B
Crystal
26 lines
603 B
Crystal
|
|
||
|
|
||
|
module FosdemRecorder
|
||
|
class UrlValidator
|
||
|
class PageIsNotFosdemError < Exception
|
||
|
def message
|
||
|
"Not a fosdem stream. URL must start with https://fosdem.org/..."
|
||
|
end
|
||
|
end
|
||
|
|
||
|
class PageIsNotScheduleError < Exception
|
||
|
def message
|
||
|
"Not a schedule page. URL must contain .../schedule/event/..."
|
||
|
end
|
||
|
end
|
||
|
|
||
|
def self.validate_event!(url) : Nil
|
||
|
return if url =~ %r{^https://fosdem.org/\d+/schedule/event/.*}
|
||
|
|
||
|
raise PageIsNotScheduleError.new if url =~ %r{^https://fosdem.org/.*}
|
||
|
raise PageIsNotFosdemError.new
|
||
|
nil
|
||
|
end
|
||
|
end
|
||
|
end
|