lupuscoding/din-validator

Package to validate strings for DIN specifications

1.0.0 2022-06-06 20:24 UTC

This package is auto-updated.

Last update: 2024-09-07 14:04:54 UTC


README

Library to validate if strings meet specific DIN Specifications.

Currently, included specs:

  • DIN SPEC 91379

Contents

Requirements #

  • PHP >= 7.4

Install #

composer require lupuscoding/din-validator

Usage #

To validate a string for a certain DIN specification, it is recommended to use the static ValidatorFactory methods.

For example: We want to validate an user input for DIN SPEC 91379

function testUserInput(string $input) {
    // do some stuff
    if (!LupusCoding\DinValidator\ValidatorFactory::validateDinSpec91379($input)) {
        // do something if input is not valid
    }
    // do other stuff
}

You are also able to use specific tests, if you need more detailed information. The majority validator methods of this library should work on basis of a single character. Because of this, you should be able to test single characters if they are part of the specification. For this, initialize the class, related to the required specification (src/Specs/) and search for a method to fit your needs.

Development #

  • Every contribution should respect PSR-2 and PSR-12.
  • Methods must provide argument types and return types.
  • Class properties must be typed.
  • doc blocks must only contain descriptive information.
  • doc blocks may additionally contain a type declaration for arguments or return values, if the type declaration is not precise.

For example: func(): array may not be precise if the method returns an array of arrays or objects. Consider a doc block entry like @return array[] or @return MyObject[] for clarification.

Testing #

First install phpunit by executing

composer install

Then start phpunit by executing

vendor/bin/phpunit