mirror of https://github.com/kcal-app/kcal.git
28 lines
531 B
PHP
28 lines
531 B
PHP
<?php
|
|
|
|
namespace App\Rules;
|
|
|
|
use Illuminate\Contracts\Validation\Rule;
|
|
|
|
class ArrayNotEmpty implements Rule
|
|
{
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function passes($attribute, $value): bool
|
|
{
|
|
return !empty(array_filter($value, function ($value) {
|
|
// Allow other "empty-y" values like false and 0.
|
|
return $value !== null;
|
|
}));
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function message(): string
|
|
{
|
|
return 'At least one :attribute must be set.';
|
|
}
|
|
}
|