Skip to content

Phauthentic/validator

Repository files navigation

Phauthentic Validator

PHP >= 8.0 phpstan Level 8 License: MIT

A SOLID validation library that also tries to do KISS.

  • Designed with maximum flexibility for customization in mind.
  • Tries to be as easy to use and set up as possible.
  • Doesn't include message translations intentionally - single responsibility principle - but provides the flexibility to hook your own system in.
  • Provides a way to customize the error result.
  • It is not exception driven as some other libs.
  • No further dependencies.
  • Framework-agnostic

Example

This is a very simple example. Please read the documentation.

$fieldBuilder = FieldBuilder::create(new FieldCollection());
$fieldBuilder->add('project.id', NotEmpty::NAME);
$fieldBuilder->add('project.name', Between::NAME, [3,10]);
$fieldBuilder->add('project.tasks.*.title', NotEmpty::NAME);
$fieldCollection = $fieldBuilder->getFieldCollection();

$validator = new Validator(
    $fieldCollection,
    (new ValidatorFactory())->createRuleCollection(),
    new ErrorCollection(),
    new GlossaryMessageFormatter()
);

if (!$result->isValid()) {
    var_dump($result->getErrors()->toArray());
}

Documentation

License

The MIT License (MIT)

  • Copyright (c) 2016-2019 Muhammad Syifa
  • Copyright (c) 2021 Dave Redfern
  • Copyright (c) 2022 Florian Krämer

About

A SOLID validation library, flexible and extendible.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy