weap-io/laravel-validation-rules

Laravel验证规则的集合

v1.0.0 2020-06-20 16:54 UTC

This package is not auto-updated.

Last update: 2024-09-29 07:20:03 UTC


README

由Weap.io精心打造和维护的一套实用Laravel验证规则。Weap.io.

安装

安装包

composer require weap-io/laravel-validation-rules

网络

主机名

验证主机名。

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)]
]

端口

验证端口号。

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)]
];

银行

IBAN

验证IBAN。

use Weap\LaravelValidationRules\Rules\Bank\Iban;

return [
   'iban' => ['required', new Iban()]
];

BIC

验证BIC。

use Weap\LaravelValidationRules\Rules\Bank\Bic;

return [
    'bic' => ['required', new Bic()]
];

服务/Aws

S3存储桶名称

验证S3存储桶名称

use Weap\LaravelValidationRules\Rules\Services\Aws\S3BucketName;

return [
    'bucket_name' => ['required', new S3BucketName()],
];