A set of useful Laravel validation rules crafted and maintained by Weap.io.
Install the package:
composer require weap-io/laravel-validation-rules
Validate a hostname.
use Weap\LaravelValidationRules\Rules\Network\Hostname;
// Given input must be a valid hostname (with or without TLD)
return [
'host' => ['required', new Hostname()]
]
// Given input must be a valid hostname without TLD
return [
'host' => ['required', new Hostname($withTld = false)]
]
Validate a port number.
use Weap\LaravelValidationRules\Rules\Network\Port;
// The input must be a valid port number (0 excluded)
return [
'port' => ['required', new Port()]
];
// The input must be a valid port number (0 included)
return [
'port' => ['required', new Port($allowZero = true)]
];
Validate an IBAN.
use Weap\LaravelValidationRules\Rules\Bank\Iban;
return [
'iban' => ['required', new Iban()]
];
Validate a BIC.
use Weap\LaravelValidationRules\Rules\Bank\Bic;
return [
'bic' => ['required', new Bic()]
];
Validate an S3 Bucket name
use Weap\LaravelValidationRules\Rules\Services\Aws\S3BucketName;
return [
'bucket_name' => ['required', new S3BucketName()],
];