mascame/formality

Form fields type guesser. Tries to detect the field type based on the name and the given config.

1.0.0 2017-10-01 16:43 UTC

This package is not auto-updated.

Last update: 2024-11-01 21:36:06 UTC


README

Packagist Travis license

Form fields type guesser. Tries to detect the field type based on the name and the given config.

Installation

composer require mascame/formality

Usage

$types = [
    'password' => [], // will match the keyword `password`
    'text' => [
        'autodetect' => [
            'title',  
        ]
    ],
    'textarea' => [
        'autodetect' => [
            'body',  
        ],
    ],
    'datetime' => [
        'regex' => [
            '/_at$/'
        ],
    ],
];

$parser = new Mascame\Formality\Parser\Parser($types);

print $parser->parse('title');  // text
print $parser->parse('body');  // textarea
print $parser->parse('created_at');  // datetime
print $parser->parse('password');  // password

Run Tests

vendor/bin/codecept run unit