mugomes/mgformvalidation

Maintainers

Package info

github.com/mugomes/mgformvalidation

pkg:composer/mugomes/mgformvalidation

Statistics

Installs: 1

Dependents: 0

Suggesters: 0

Stars: 0

1.0.0 2026-04-27 23:14 UTC

This package is auto-updated.

Last update: 2026-05-02 22:38:50 UTC


README

Validação de Formulário em PHP sem redirecionamento para POST e GET.

📦 Instalação

Via Composer (recomendado)

composer require mugomes/mgformvalidation

Manual

Copie o arquivo mgformvalidation.php para o seu projeto e faça a inclusão.

Exemplo de Uso

if (getenv('REQUEST_METHOD') == 'POST') {
    $mgformvalidation = new mgformvalidation();

    $mgformvalidation->rules([
        'nome' => 'required|min:3|max:5',
        'email' => 'required|email'
    ])->json();

    $mgformvalidation->success(function () {
        echo json_encode(['success' => 'Formulário com dados enviados!']);
    });
}

echo '<style>
.mgformvalidation-error {
    color: #ef4444;
    font-size: 14px;
    margin-top: 4px;
}

.mgformvalidation-success {
    color: #22c55e;
    margin-top: 15px;
    text-align: center;
}
</style>';

echo mgformvalidation::form('post', '');
echo '<h2>Contato</h2>';

echo '<input type="text" name="nome" placeholder="Nome">';
echo mgformvalidation::dataError('mgformvalidation-error', 'nome');

echo '<input type="email" name="email" placeholder="E-mail">';
echo mgformvalidation::dataError('mgformvalidation-error', 'email');

echo '<button type="submit">Enviar</button>';

echo mgformvalidation::dataSuccess('mgformvalidation-success');
echo mgformvalidation::endForm();

echo mgformvalidation::scripts();

💙 Apoie

👤 Autor

Murilo Gomes Julio

🔗 https://www.bluice.com.br

📺 https://youtube.com/@mugomesoficial

License

The MGFormValidation is provided under:

SPDX-License-Identifier: LGPL-2.1-only

Beign under the terms of the GNU Lesser General Public License version 2.1 only.

All contributions to the MGFormValidation are subject to this license.