nwilging/laravel-strict-types-validation 问题修复 & 功能扩展

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

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

nwilging/laravel-strict-types-validation

Composer 安装命令:

composer require nwilging/laravel-strict-types-validation

包简介

A validator for laravel to require strict types in form request data

README 文档

README

Tests Coverage Latest Stable Version License Total Downloads

Ensures incoming form request data is of a certain datatype.

About

While Laravel includes many useful validation rules out of the box, it lacks the ability to validate data type as well as content type. There have been a couple complaints about this over the years, but due to the versatile nature of Laravel, it doesn't seem likely that validation rules such as integer or boolean will begin validating that the data is actually of the desired type.

This package provides a way for you to require the incoming data to be of a given type, such as int, bool, float, etc.

Installation

Pre Requisites

  1. Laravel v8+
  2. PHP 7.4+

Install with Composer

composer require nwilging/laravel-strict-types-validation

Usage

When constructing validation rules, simply add type:<desired type> to the validation rules string/array.

$rules = [
    'id' => 'required|type:int', # This will require the incoming `id` to be an integer.
];

Failure Messages

The failure message format is:

The :attribute must be of type :type

Where attribute is the attribute being validated (id from the above example) and type is the desired type to validate against (int in the above example).

If the above example failed, we would receive this message:

The id must be of type int

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-05-24

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固