mirror of
				https://github.com/pelican-dev/panel.git
				synced 2025-11-04 10:36:53 +01:00 
			
		
		
		
	Co-authored-by: RMartinOscar <40749467+RMartinOscar@users.noreply.github.com> Co-authored-by: Boy132 <Boy132@users.noreply.github.com> Co-authored-by: Lance Pioch <git@lance.sh>
		
			
				
	
	
		
			36 lines
		
	
	
		
			874 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			36 lines
		
	
	
		
			874 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
 | 
						|
namespace App\Rules;
 | 
						|
 | 
						|
use Illuminate\Translation\PotentiallyTranslatedString;
 | 
						|
use Closure;
 | 
						|
use Illuminate\Contracts\Validation\ValidationRule;
 | 
						|
 | 
						|
class Port implements ValidationRule
 | 
						|
{
 | 
						|
    /**
 | 
						|
     * Run the validation rule.
 | 
						|
     *
 | 
						|
     * @param  Closure(string):PotentiallyTranslatedString  $fail
 | 
						|
     */
 | 
						|
    public function validate(string $attribute, mixed $value, Closure $fail): void
 | 
						|
    {
 | 
						|
        if (!is_numeric($value)) {
 | 
						|
            $fail('The :attribute must be numeric.');
 | 
						|
        }
 | 
						|
 | 
						|
        $value = intval($value);
 | 
						|
        if (floatval($value) !== (float) $value) {
 | 
						|
            $fail('The :attribute must be an integer.');
 | 
						|
        }
 | 
						|
 | 
						|
        if ($value < 0) {
 | 
						|
            $fail('The :attribute must be greater or equal to 0.');
 | 
						|
        }
 | 
						|
 | 
						|
        if ($value > 65535) {
 | 
						|
            $fail('The :attribute must be less or equal to 65535.');
 | 
						|
        }
 | 
						|
    }
 | 
						|
}
 |