cledilsonweb/lontra-validator

PHP 数据验证器,为 Laminas 框架提供额外验证器(getlaminas.org)

0.2.1 2022-04-18 20:56 UTC

This package is auto-updated.

Last update: 2024-09-19 02:13:49 UTC


README

Latest Version on Packagist Software License Total Downloads

lontra-validator 是一个验证器包,是 laminas-validator 的补充,与 laminas-form 的验证兼容。它提供了一个面向对象的解决方案。

ArrayRecordExists - Check if values in array exists on database
DateBetween - Checks whether the date is between values entered.
DateGreaterThan - Checks if date is greater
DateLessThan - Checks if date is less
EndsWith - If text ends with a value
IsArray - If value is a valid array
Password - Checks whether the entered value is a valid password with the options uppercase, lowercase, number, special characters.
StartsWith - If text starts with a value
WordCount - Validate the number of words in a string

依赖项

lontra-validator 依赖于 laminas-validator(以及可选的 laminas-db 以与数据库进行比较),由 Linux 基金会维护

安装

通过 Composer

$ composer require cledilsonweb/lontra-validator

用法

$validator = new DateBetween([
    'max' => '2020-10-10', 
    'min' => '2020-05-05', 
    'format' => 'Y-m-d', 
    'inclusive' => true
]);
echo $validator->isValid('2020-06-06'); //true

可以在 Laminas Form 中使用 InputFilter 验证器

$inputFilter->add(
    [
        'name' => 'input_name',
        'required' => true,
        'filters' => // your filters...,
        'validators' => [
            [
                'name' => DateBetween::class
                'options' => [
                    'max' => '2020-10-10', 
                    'min' => '2020-05-05', 
                    'format' => 'Y-m-d', 
                    'inclusive' => true
                ]
            ]
        ]
    ]
);

变更日志

有关最近更改的更多信息,请参阅变更日志

测试

$ composer test

要运行集成测试,您需要启用 extension=pdo_sqlite

建议和安全

如果您发现任何与安全相关的问题或有任何建议,请 创建新问题

致谢

许可协议

MIT 许可协议(MIT)。有关更多信息,请参阅许可文件