Skip to content

Commit

Permalink
api(Requests): Add validation rules to store and update requests
Browse files Browse the repository at this point in the history
Ref issue #85
  • Loading branch information
poppabear8883 committed Sep 26, 2018
1 parent a8573c5 commit 3633840
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 6 deletions.
11 changes: 10 additions & 1 deletion app/Http/Requests/StoreAlbum.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,16 @@ public function authorize()
public function rules()
{
return [
//
'artists_id' => 'required|integer|exists:artists,id',
'title' => 'required|string|max:255',
'alt_title' => 'string|max:255',
'year' => 'required|integer',
'description' => 'max:255',
'has_explicit_lyrics' => 'required|boolean',
'full_album_price' => 'between:0.00,999.99',
'rank' => 'integer|between:1,20',
'is_active' => 'boolean',
'deleter_id' => 'integer|exists:users,id'
];
}
}
2 changes: 1 addition & 1 deletion app/Http/Requests/StoreGenre.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function authorize()
public function rules()
{
return [
//
'name' => 'required|string'
];
}
}
9 changes: 8 additions & 1 deletion app/Http/Requests/StoreLabel.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,14 @@ public function authorize()
public function rules()
{
return [
//
'moniker' => 'required|max:255',
'alt_moniker' => 'max:255',
'email' => 'email',
'city' => 'max:255',
'territory' => 'max:255',
'country_code' => 'exists:countries,code',
'official_url' => 'url',
'profile_url' => 'max:64', // TODO This requires further validation, to prevent tomfoolery, profanity, etc..
];
}
}
8 changes: 7 additions & 1 deletion app/Http/Requests/StoreSong.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,13 @@ public function authorize()
public function rules()
{
return [
//
'name' => 'required|string|max:255',
'alt_name' => 'string|max:255',
'flac_file' => 'required|file|max:2000000',
'track_number' => 'integer|max:99',
'preview_start' => 'between:0.000,9999.999',
'is_active' => 'boolean',
'album_id' => 'required|exists:albums,id',
];
}
}
9 changes: 8 additions & 1 deletion app/Http/Requests/UpdateLabel.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,14 @@ public function authorize()
public function rules()
{
return [
//
'moniker' => 'max:255',
'alt_moniker' => 'max:255',
'email' => 'email',
'city' => 'max:255',
'territory' => 'max:255',
'country_code' => 'exists:countries,code',
'official_url' => 'url',
'profile_url' => 'max:64', // TODO This requires further validation, to prevent tomfoolery, profanity, etc..
];
}
}
8 changes: 7 additions & 1 deletion app/Http/Requests/UpdateSong.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,13 @@ public function authorize()
public function rules()
{
return [
//
'name' => 'string|max:255',
'alt_name' => 'string|max:255',
'flac_file' => 'file|max:2000000',
'track_number' => 'integer|max:99',
'preview_start' => 'between:0.000,9999.999',
'is_active' => 'boolean',
'album_id' => 'exists:albums,id',
];
}
}

0 comments on commit 3633840

Please sign in to comment.