<commit_before># Memio's Validator [![Travis CI](https://travis-ci.org/memio/validator.png)](https://travis-ci.org/memio/validator) [![SensioLabsInsight](https://insight.sensiolabs.com/projects/e5794d5b-5305-4569-bc9b-caeecf9ae982/mini.png)](https://insight.sensiolabs.com/projects/e5794d5b-5305-4569-bc9b-caeecf9ae982)

A validator library for Memio: allows to define `Constraints` to check if the built
[Memio models](http://github.com/memio/model) are valid
(e.g. `Method` cannot be both abstract and final).

> **Note**: This package is part of [Memio](http://memio.github.io/memio), a highly opinionated PHP code generator.
> Have a look at [the main repository](http://github.com/memio/memio).

## Installation

Install it using [Composer](https://getcomposer.org/download):

    composer require memio/validator:^2.0@alpha

## Example

Let's say we want to check that `Arguments` aren't scalar. In order to do so,
the first thing we'll need to do is to write a `Constraint`:

```php
<?php

require __DIR__.'/vendor/autoload.php';

use Memio\Validator\Constraint;
use Memio\Validator\Violation\{
    NoneViolation,
    SomeViolation
};

class ArgumentCannotBeScalar implements Constraint<commit_msg>Released v2.0.3<commit_after># Memio's Validator [![Travis CI](https://travis-ci.org/memio/validator.png)](https://travis-ci.org/memio/validator) [![SensioLabsInsight](https://insight.sensiolabs.com/projects/e5794d5b-5305-4569-bc9b-caeecf9ae982/mini.png)](https://insight.sensiolabs.com/projects/e5794d5b-5305-4569-bc9b-caeecf9ae982)

A validator library for Memio: allows to define `Constraints` to check if the built
[Memio models](http://github.com/memio/model) are valid
(e.g. `Method` cannot be both abstract and final).

> **Note**: This package is part of [Memio](http://memio.github.io/memio), a highly opinionated PHP code generator.
> Have a look at [the main repository](http://github.com/memio/memio).

## Installation

Install it using [Composer](https://getcomposer.org/download):

    composer require memio/validator:^2.0

## Example

Let's say we want to check that `Arguments` aren't scalar. In order to do so,
the first thing we'll need to do is to write a `Constraint`:

```php
<?php

require __DIR__.'/vendor/autoload.php';

use Memio\Validator\Constraint;
use Memio\Validator\Violation\NoneViolation;
use Memio\Validator\Violation\SomeViolation;

class ArgumentCannotBeScalar implements Constraint
{'fraction_non_alphanumeric': 0.1353135313531353, 'fraction_numerical': 0.03259075907590759, 'mean_word_length': 5.092964824120603, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 10, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3536220', 'n_tokens_mistral': 877, 'n_tokens_neox': 839, 'n_words': 206}