cledilsonweb/lontra-validator 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

cledilsonweb/lontra-validator

Composer 安装命令:

composer require cledilsonweb/lontra-validator

包简介

PHP data validators and extra validators for Laminas Framework(getlaminas.org)

README 文档

README

Latest Version on Packagist Software License Total Downloads

The lontra-validator is a validator package, a complement to laminas-validator, compatible with validation for laminas-form. It provides an OOP approach.

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
Validator - This class has tools for using laminas-validator and lontra-validator validations

Dependencies

lontra-validator depends on laminas-validator (and suggested(but not required) laminas-db to compare with the database), maintained by the Linux Foundation

Install

Via Composer

$ composer require cledilsonweb/lontra-validator

Usage

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

// Using static validation
echo Validator::isValid(DateBetween::class, '2020-06-06', ['max' => '2020-10-10', 'min' => '2020-05-05']); //true
// Or
echo Validator::validateDateBetween('2020-06-06', ['max' => '2020-10-10', 'min' => '2020-05-05']); //true

It is possible to use the validator on the Laminas Form with 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
                ]
            ]
        ]
    ]
);

To customize the validation message:

$inputFilter->add(
    [
        'name' => 'input_name',
        'required' => true,
        'filters' => // your filters...,
        'validators' => [
            [
               'name' => DateGreaterThan::class, 'options' => [                        
                'format' => 'Y-m-d',                        
                'min' => 'now',                        
                'messages' => [                            
                    DateGreaterThan::NOT_GREATER_INCLUSIVE => 'A data informada deve ser maior ou igual a data atual',                            DateGreaterThan::NOT_GREATER           => "A data informada deve ser maior que a data atual",                            DateGreaterThan::IVALID_FORMAT         => "A data informada está no formato inválido",                            DateGreaterThan::IVALID_DATE           => "A data informada é inválida",                        
                    ]                    
                ]
            ]
        ]
    ]
);

Change log

Please see CHANGELOG for more information on what has changed recently.

Testing

$ composer test

To run the integration test, you need to enable extension=pdo_sqlite

Suggestions and Security

If you discover any security related issues or have any suggestions, please create a new issue.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 47
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-07-24

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固