import 'dart:async';

class Validators{
  final validarPassword = StreamTransformer<String, String>.fromHandlers(
    handleData: (password, sink){
      if(password.length >= 5){
        sink.add(password);
      }else if(password.isEmpty){
        sink.addError('Campo obligatorio');
      }else{
        sink.addError('La contraseña debe tener al menos 5 caracteres');
      }
    },
  );

  final validarEmail = StreamTransformer<String, String>.fromHandlers(
    handleData: (email, sink){
      if(email.isNotEmpty){
        sink.add(email);
      }else{
        sink.addError('Campo obligatorio');
      }
    },
  );

  final validarGroupName = StreamTransformer<String, String>.fromHandlers(
    handleData: (name, sink){
      if(name.isNotEmpty){
        sink.add(name);
      }else{
        sink.addError('El nombre no debe estar vacío');
      }
    },
  );
}