validadores 1.0.9 copy "validadores: ^1.0.9" to clipboard
validadores: ^1.0.9 copied to clipboard

Validadores para formulários PT-BR, validações como CPF,CNPJ,OBRIGATORIO,EMAIL,IGUAL,Valor Mínimo,Valor Máximo,Tamanho Mínimo,Tamanho Máximo.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:validadores/Validador.dart';

void main() => runApp(MalidadoresMain());

class MalidadoresMain extends StatelessWidget {

  @override
  Widget build(BuildContext context) {

    final _formKey = GlobalKey<FormState>();

    return MaterialApp(
      title: 'Validador',
      debugShowCheckedModeBanner: false,
      home: Scaffold(
        appBar: AppBar(
          title: Text('Validadores'),
        ),
        body: Form(
          key: _formKey,
          child: Container(
              padding: EdgeInsets.all(20),
              child: Column(
                children: <Widget>[
                  TextFormField(
                    validator: (value) {
                      // Aqui entram as validações
                      return Validador()
                          .add(Validar.CPF, msg: 'CPF Inválido')
                          .add(Validar.OBRIGATORIO, msg: 'Campo obrigatório')
                          .minLength(11)
                          .maxLength(11)
                          .valido(value,clearNoNumber: true);

                    },
                    decoration: const InputDecoration(
                        helperText: 'informe seu cpf',
                        hintText: '123.456.789-00',
                        labelText: 'CPF'
                    ),
                  ),
                  ElevatedButton(
                    onPressed: () {
                      if (_formKey.currentState!.validate()) {
                        print('Valido');
                      }
                    },
                    child: Text('Enviar'),
                  )
                ],
              )
          ),
        ),
      )
      ,
    );
  }

}
25
likes
120
pub points
86%
popularity

Publisher

verified publisher365apps.com.br

Validadores para formulários PT-BR, validações como CPF,CNPJ,OBRIGATORIO,EMAIL,IGUAL,Valor Mínimo,Valor Máximo,Tamanho Mínimo,Tamanho Máximo.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on validadores