Download the PHP package mohamed-amine-sayagh/zec without Composer
On this page you can find all versions of the php package mohamed-amine-sayagh/zec. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mohamed-amine-sayagh/zec
More information about mohamed-amine-sayagh/zec
Files in mohamed-amine-sayagh/zec
Package zec
Short Description A Php Secure Data Parsing Library
License MIT
Informations about the package zec
Zec: PHP Data Parsing Library
The Zec Data Parsing and schema declaration Library is designed to bring schema definition and validation capabilities to PHP applications.
Installation
Composer
Requirements
- PHP 8.0 or higher
Usage Example
Here's an example of how to use the Zec library to define and validate a user profile schema:
Define a schema for user data validation
Parse user data and validate it
Expected Error Response
Current Version: v1.0.0, Release Date: 2024-10-01, Author: Mohamed Amine SAYAGH, Release Notes: Initial release of the Zec PHP Data Parsing Library., Release Link: [Zec 1.0.0](
Note: This library is currently in development. Official documentation and further resources will be available soon.
Author Information:
Table of Contents
- Installation
- Collaboration
- How to Contribute
- Usage
- Basic Parsing
- Validation
- Exception Handling with Parsing
- Parsing of an array of options
- Advanced Parser Configuration
- Complex Example: User Data Validation
- Creating Custom Parser Methods
- License
Some other great aspects
- Robust Schema Validation: Provides strong typing and validation similar to the Zec library, ensuring accurate data handling.
- Modular and Extensible: Easy to extend with custom parsers, accommodating diverse data validation needs.
- Separation of Concerns: Keeps data parsing separate from business logic for better security and maintainability.
- Ease of Testing: Simplifies testing by enforcing strict data validation.
- Flexible Configuration: Supports dynamic parser configurations and customizations without altering the core library.
- Community-Focused: Open for contributions, enhancing collective improvement and support.
Collaboration
We are fully open to collaboration! If you're interested in contributing to the PHP Data Parsing Library, we'd love to hear from you. Whether it's through code contributions, documentation improvements, or feature suggestions, your input is highly welcome.
How to Contribute
- Fork the Repository: Start by forking the repository to your own GitHub account.
- Clone Your Fork: Clone your fork to your local machine and set up the development environment.
- Create a New Branch: Make your changes in a new git branch.
- Commit Your Changes: Commit your modifications with clear and descriptive commit messages.
- Push Your Changes: Push your changes to your fork on GitHub.
- Submit a Pull Request: Open a pull request to the main branch of our repository. Please provide a clear description of the changes and any other information that will help us understand your contributions.
For more details, check our contribution guidelines (link to detailed contribution guidelines if available).
We look forward to building a powerful data parsing tool with a vibrant community of contributors!
Usage
Basic Parsing
Define and validate data types using simple schema definitions:
Validation
Quickly validate data after parsing:
Exception Handling with Parsing
Handle exceptions using parse_or_throw for critical data validation:
Parsing of an array of options
You can enhance the schema definition by incorporating additional validation options. This allows for more detailed control over data conformity based on specific requirements.
Advanced Parser Configuration
The library provides extensive Configurability for data validation, allowing users to define complex validation rules with custom messages and conditions. Below is an example of how to configure a detailed schema for an email field with specific validation rules:
Complex Example: User Data Validation
This example demonstrates validating a user data structure that includes nested arrays, optional fields, and union types, showcasing the library's capability to handle complex and realistic data models.
Creating Custom Parser Methods
To enhance flexibility and cater to specific validation needs, our library allows users to define custom parser methods. This section demonstrates how to create a size
parser method, which validates that the size of an array, length of a string, or value of a number meets a specific requirement.
The size
method checks if:
- An array's length equals a specified size.
- A string's length equals a specified number of characters.
- A numeric value is exactly equal to a specified number.
Here is how you can implement this custom parser:
You can now use the custom size
parser method in your schema definitions:
License
This project is licensed under the MIT License - see the LICENSE.md file for details.
MIT License
Copyright (c) 2024 Mohamed Amine SAYAGH
All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.