定制 schematicon/validator 二次开发

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

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

schematicon/validator

最新稳定版本:v1.2.0

Composer 安装命令:

composer require schematicon/validator

包简介

Schemation Validator is powerful validator of various data structures.

README 文档

README

Build Status Downloads this Month Stable version

Validator is Schematicon Schema validator. Schemeaticon schema is innovative declarative language for data structure description. It is programming-language independent; that means you can define the schema using NEON, YAML or native PHP arrays.

Example

my_family.neon:

type: map properties: name: string surname: string sex: enum: [male, female] age: int|null # property may be a null ?height: float # property may not exist at all; if exist, it has to be a float siblings: type: array item: type: string

The following inputs may be validated againts the defined schema:

$normalizer = new Schematicon\Validator\Normalizer(); $schema = Neon\Neon::decode(file_get_contents('./my_family.neon')); $schema = $normalizer->normalize($schema); $validator = new Schematicon\Validator\Validator($schema); $result = $validator->validate([ 'name' => 'jon', 'surname' => 'snow', 'sex' => 'male', 'age' => 18, 'height' => 180.00, 'siblings' => ['Arya'], ]); $result->isValid(); // true $result->getErrors(); // []

Installation

Use composer:

$ composer require schematicon/validator

License

MIT. See full license.

The development was sponsored by Sygic Travel.

统计信息

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

GitHub 信息

  • Stars: 20
  • Watchers: 4
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04