Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add record.spotify_uri format validation
- Loading branch information
Showing
6 changed files
with
22 additions
and
10 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,8 +1,14 @@ | ||
class Record < ActiveRecord::Base | ||
attr_accessible :artist, :title, :cover_url, :spotify_uri | ||
|
||
validates :artist, presence: true | ||
validates :title, presence: true | ||
|
||
validates_format_of :cover_url, with: %r{\.(gif|jpe?g|png)$}i, | ||
message: "should be an image URL (jpg, gif or png)", | ||
allow_blank: true | ||
|
||
validates_format_of :spotify_uri, with: %r{spotify:(album|track):[a-zA-Z0-9]+}, | ||
This comment has been minimized.
Sorry, something went wrong. |
||
message: "should be a correct album Spotify URI", | ||
allow_blank: true | ||
end |
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
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
%r{} 👍