Download the PHP package riley19280/laravel-rules-to-schema without Composer
On this page you can find all versions of the php package riley19280/laravel-rules-to-schema. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download riley19280/laravel-rules-to-schema
More information about riley19280/laravel-rules-to-schema
Files in riley19280/laravel-rules-to-schema
Package laravel-rules-to-schema
Short Description Parse Laravel validation rules into a Json Schema
License MIT
Homepage https://github.com/riley19280/laravel-rules-to-schema
Informations about the package laravel-rules-to-schema
Laravel Rules to Schema
Create a json schema for your Laravel rules
Prerequisites
It is recommended to use FormRequest
classes in your application to use this package.
This allows for easy extraction of rule objects to pass them into this package.
You can still use this package just by passing in an array of rules, but that is a but more cumbersome.
Installation
You can install the package via composer:
And publish the config file with:
Usage
Customization
JSON Schema Representation
This package relies on riley19280/fluent-json-schema to build and represent JSON schemas. For details on how to use and configure the objects returned from the rule parser, please see the documentation for that package.
Registering schemas for custom rules
JSON Schema definitions for custom rules can be registered in the config file by providing the rule name or class name.
The type can be any of the simple JSON schema types (array, boolean, integer, null, number, object, string).
If a more complex type is required, you can provide the class name that implements LaravelRulesToSchema\Contracts\HasJsonSchema
Extending the rule parser
Should you want to further customize or tweak how rules are parsed, additional parsers can be added in the config file.
Each parser is run for each rule in the order it is defined in the config file.
Custom parsers must implement the LaravelRulesToSchema\Contracts\RuleParser
interface.
Tools for package developers
If your package contains a custom rule, you can provide the types as part of the package as well.
In a service provider you can use the following methods to programmatically register a rule or parser:
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
- Riley Aven
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-rules-to-schema with dependencies
illuminate/contracts Version ^10.0||^11.0
riley19280/fluent-json-schema Version ^1.2.1
spatie/invade Version ^2.1
spatie/laravel-package-tools Version ^1.16