定制 hesami/laravel-json-validator 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

hesami/laravel-json-validator

最新稳定版本:v1.2.0

Composer 安装命令:

composer require hesami/laravel-json-validator

包简介

A package for validating JSON data in Laravel

README 文档

README

A package for validating JSON data in Laravel

I developed this package to teach programming concepts to my students in the classroom. But I think it will be useful for you too

I hope I can expand it.😊

If you like to develop it, it will definitely be useful for other programmers, especially beginners.

Requirement

  • Laravel 6, 7, 8, 9
  • PHP 7.4 , 8

Installation:

composer require hesami/laravel-json-validator

How To use:

Rule Description
json_object To check that the input data is a Json string and contains an object
json_array To check that the input data is a Json string and contains an array
json_object_has_key To check that the input is a Json string and contains an array whose items have a key or keys
json_array_items_has_key To check that the input is a Json string and contains an array whose items have a key or keys
json_array_items_numeric Checks that the elements of the array are of numeric type.
json_array_items_distinct To check that the input data is a Json string and contains an distinct array
json_array_items_count To check that the input data is a Json string and contains an array that has a certain number (10 or ...) of objects
json_array_items_min To check that the input data is a Json string and contains an array containing at least $min objects
json_array_items_max To check that the input data is a Json string and contains an array that has at most :max objects

To check that the input data is a Json string and contains an object:

Validator::make($request->all(), [
    'movies' => ['json', 'json_object']
]);

To check that the input data is a Json string and contains an array:

Validator::make($request->all(), [
    'movies' => ['json', 'json_array']
]);

To check that the input data is a Json string and contains an object that has a key or keys:

Validator::make($request->all(), [
    'movies' => ['json', 'json_object', 'json_object_has_key:title,desc']
]);

To check that the input is a Json string and contains an array whose items have a key or keys:

Validator::make($request->all(), [
    'movies' => ['json', 'json_array', 'json_array_items_has_key:title,desc']
]);

Checks that the elements of the array are of numeric type:

Validator::make($request->all(), [
    'movies' => ['json', 'json_array', 'json_array_items_numeric']
]);

To check that the input data is a Json string and contains an distinct array:

Validator::make($request->all(), [
    'movies' => ['json', 'json_array', 'json_array_items_has_key:name', "json_array_items_distinct:name"]
]);

To check that the input data is a Json string and contains an array that has a certain number (10 or ...) of objects:

Validator::make($request->all(), [
    'movies' => ['json', 'json_array', "json_array_items_count:$count"]
]);

To check that the input data is a Json string and contains an array containing at least $min objects:

Validator::make($request->all(), [
    'movies' => ['json', 'json_array', "json_array_items_min:$min"]
]);

To check that the input data is a Json string and contains an array that has at most :max objects:

Validator::make($request->all(), [
    'movies' => ['json', 'json_array', "json_array_items_max:$max"]
]);

Attention:

To customize the text of the messages in this version, you need to manually write the message validation language in the file.

lng->en->validation.php

License

The MIT license (MIT).

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-02-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固