Skip to content

Commit

Permalink
Merge branch 'migrate-rules-to-validation-rules' of https://github.co…
Browse files Browse the repository at this point in the history
…m/owlchester/kanka into migrate-rules-to-validation-rules
  • Loading branch information
spitfire305 committed Sep 9, 2024
2 parents 4b4ce5e + 62035f0 commit 30f947f
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion app/Rules/AccountEmail.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class AccountEmail implements ValidationRule
*/
public function validate(string $attribute, mixed $value, Closure $fail): void
{
if(Str::contains($value, ['@boxmail.lol', '@fireboxmail.lol'])) {
if (Str::contains($value, ['@boxmail.lol', '@fireboxmail.lol'])) {
$fail('The validation error message.');
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/Rules/AccountName.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class AccountName implements ValidationRule
*/
public function validate(string $attribute, mixed $value, Closure $fail): void
{
if (Str::contains($value, ['<', '>', 'https', 'http://', 'www.', 'Ђ', ' Illuro']) && Str::length($value) < 31) {
if (Str::contains($value, ['<', '>', 'https', 'http://', 'www.', 'Ђ', ' Illuro']) && Str::length($value) < 31) {
$fail('Invalid account name.');
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/Rules/CalendarFormat.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class CalendarFormat implements ValidationRule
*/
public function validate(string $attribute, mixed $value, Closure $fail): void
{
if(preg_match('/^[ymMds\s,-]+$/', $value)) {
if (preg_match('/^[ymMds\s,-]+$/', $value)) {
$fail(__('calendars.validators.format'));
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/Rules/CampaignDelete.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class CampaignDelete implements ValidationRule
*/
public function validate(string $attribute, mixed $value, Closure $fail): void
{
if(!Str::is(mb_strtolower($value), 'delete')) {
if (!Str::is(mb_strtolower($value), 'delete')) {
$fail(__('validation.delete_campaign', ['code' => 'delete']));
}
}
Expand Down
6 changes: 3 additions & 3 deletions app/Rules/EntityFileRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ public function validate(string $attribute, mixed $value, Closure $fail): void
if ($value instanceof UploadedFile && !$value->isValid()) {
$fail(__('validation.mimes', ['values' => 'jpg, jpeg, png, gif, webp, pdf, xls(x), csv, mp3, ogg, json']));
}

// Block any hacking shenanigans
if ($this->shouldBlockPhpUpload($value, [])) {
$fail(__('validation.mimes', ['values' => 'jpg, jpeg, png, gif, webp, pdf, xls(x), csv, mp3, ogg, json']));
}

if (empty($value->getPath())) {
$fail(__('validation.mimes', ['values' => 'jpg, jpeg, png, gif, webp, pdf, xls(x), csv, mp3, ogg, json']));
}

$validExtensions = explode(',', 'jpeg,png,jpg,gif,webp,pdf,xls,xlsx,mp3');
if (!in_array($value->guessExtension(), $validExtensions)) {
$fail(__('validation.mimes', ['values' => 'jpg, jpeg, png, gif, webp, pdf, xls(x), csv, mp3, ogg, json']));
Expand Down
4 changes: 2 additions & 2 deletions app/Rules/EntityLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ public function validate(string $attribute, mixed $value, Closure $fail): void
->where('access', 1)
->where('action', CampaignPermission::ACTION_READ)
->first();

// We don't check for the public role have deny as a permission, this is good enough
if (empty($permission)) {
$fail( __('validation.entity_link'));
$fail(__('validation.entity_link'));
}
}
}

0 comments on commit 30f947f

Please sign in to comment.