Skip to content

Commit

Permalink
fix: adding Episode Structure validation
Browse files Browse the repository at this point in the history
  • Loading branch information
KitsuneSemCalda committed Mar 29, 2024
1 parent acd54d8 commit b263003
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions Structure/Episode.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
package structure

import "errors"
import (
"errors"
"net/url"
)

type Episode struct {
Number int
Url string
}

func IsValidEpisode(episode Episode) bool {
var err error

if episode.Number <= 0 {
return false
}
Expand All @@ -16,7 +21,9 @@ func IsValidEpisode(episode Episode) bool {
return false
}

return true
_, err = url.ParseRequestURI(episode.Url)

return err == nil
}

func NewEpisode(number int, url string) (*Episode, error) {
Expand Down

0 comments on commit b263003

Please sign in to comment.