An open API service indexing awesome lists of open source software.

https://github.com/attributes-php/options

A collection of Attributes to enhance the validation/serialization stages
https://github.com/attributes-php/options

enhance serialization validation

Last synced: 5 months ago
JSON representation

A collection of Attributes to enhance the validation/serialization stages

Awesome Lists containing this project

README

          

# Attributes Options



Latest Version
Software License

**Attributes Options** is a collection of Attributes that can be used to enhance the [validation](https://github.com/Attributes-PHP/validation)
and/or [serialization](https://github.com/Attributes-PHP/serializer) stages.

## Supported options

### Class specific options

- *AliasGenerator*, generates an alias per each class property

### Property options

- *Alias*, specifies a given alias for a property
- *Ignore*, skips the validation and/or serialization of a property

## Requirements

- PHP 8.1+

We aim to support versions that haven't reached their end-of-life.

## How it works?

```php
'user',
'password' => '1234',
];

// Validation stage
$validator = new Validator();
$login = $validator->validate($rawData, new Login);

var_dump($login->user); // string(4) "user
var_dump($login->password); // string(4) "1234"

// Serialization stage
$serializer = new Serializer;
$serializedData = $serializer->serialize($login);

var_dump($serializedData); // array { ["user_name"] => "user" }
```

## Installation

```bash
composer require attributes-php/options
```

Attributes Options was created by **[André Gil](https://www.linkedin.com/in/andre-gil/)** and is open-sourced software licensed under the **[MIT license](https://opensource.org/licenses/MIT)**.