<?php

namespace Modules\Admin\app\Rules;

use Closure;
use Illuminate\Contracts\Validation\ValidationRule;

class PointRule implements ValidationRule
{
    static public function check($value): bool
    {
        $point = (int) $value;

        return ((0 <= $point) && ($point <= 1000000000));
    }

    static public function message(): string
    {
        return 'The point must be from 0 to 1,000,000,000';
    }
    /**
     * Run the validation rule.
     */
    public function validate(string $attribute, mixed $value, Closure $fail): void
    {
        if (!$this->check($value)) {
            $fail($this->message());
        }
    }
}
