district5/validators
最新稳定版本:3.1.0
Composer 安装命令:
composer require district5/validators
包简介
District5 Validators Library
关键字:
README 文档
README
Validators
A collection of validators implementing / extending the District5 Validator library.
Installation
Install using composer:
composer require district5/validators
Usage
Currently Available Validators
- Array of Numbers
- Bool Value
- Checkbox Value
- DateTime
- DateYYYMMDD
- Domain Name
- Email Address
- Hex
- Hex Colour
- Integer Value
- Integer Positive
- Integer Range
- JSON String
- Lat Lon Object
- Long Value
- Numeric Value
- Numeric Range
- Numeric Specific Values
- Regex
- Std Class with Properties
- String in Array of String
- String Length
- String of Defined Characters
- String Version Major Minor Patch Greater Than or Equal To
- String with Dashes
- String with Dashes and Underscores
- String with Dashes Dots and Underscores
- Sub Domain
- Unix Timestamp Seconds
- URL
General
Most validators work in the same way:
$validValue = true; $invalidValue = 'Hello'; $validator = new \District5\Validators\BoolValue(); $validator->isValid($validValue); // true $validator->isValid($invalidValue); // false
Some validators have configuration options that can be specified at construction time:
EmailAddress
Validate an email address:
<?php // Simple format check: $validator = new \District5\Validators\EmailAddress(); $validator->isValid('foo@gmail.com'); // true // Deeper check, which includes MX record lookup: $validator = new \District5\Validators\EmailAddress( ['deep' => true] ); $validator->isValid('foo@gmail.com'); // true $validator->isValid('foo@domainthatdoesntexist.com'); // false
Testing:
$ composer install
$ ./vendor/bin/phpunit
统计信息
- 总下载量: 145
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: mit
- 更新时间: 2024-03-25