承接 yiiy/argus 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

yiiy/argus

最新稳定版本:1.0.0

Composer 安装命令:

composer require yiiy/argus

包简介

Lightweight PHP Data Validator

README 文档

README

Tests Total Downloads License

Lightweight PHP Data Validator

Argus is a PHP package designed to simplify and streamline data validation tasks in your applications. It offers a comprehensive set of validation rules to ensure the integrity and accuracy of your data.

Features

  • Common Validations: Perform checks for required fields, email format, string values, numeric values, and length restrictions.
  • Range Validation: Ensure numeric data falls within a specific range.
  • Customization: Easily define custom validation rules to meet your specific needs.
  • Error Reporting: Get clear and informative error messages to identify invalid data points.

Installation

You can install the package using Composer:

composer require yiiy/argus

Usage

The package provides a simple and intuitive API for data validation. Here's a basic example:

<?php

require 'vendor/autoload.php';

use Yi\Argus\Validator;

$data = [
    'name'  => 'John Doe',
    'email' => 'invalid_email',
    'age'   => 30,
];

$rules = [
    'name'  => ['required', 'string', 'length:2:255'],
    'email' => ['required', 'email'],
    'age'   => ['required', 'numeric', 'between:18:120'],
];

$validator = new Validator();
$errors = $validator->validate($data, $rules);

if (empty($errors)) {
    echo 'Data is valid!';
} else {
    echo 'Validation errors:' . PHP_EOL;
    foreach ($errors as $field => $errorMessages) {
        echo "  * $field: " . implode(', ', $errorMessages) . PHP_EOL;
    }
}

Supported Validations

  • required Checks if a field is present and not empty.
  • string Checks if a field value is a string.
  • numeric Checks if a field value is numeric.
  • email Checks if a field value is a valid email address.
  • length:min:max Checks if the field value length falls within the specified range (min and max are integers).
  • between:min:max Checks if a numeric field value falls within the specified range (min and max are integers).

License

This project is licensed under the MIT License - see the LICENSE file for details.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-03-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固