queen_validators 0.0.1 copy "queen_validators: ^0.0.1" to clipboard
queen_validators: ^0.0.1 copied to clipboard

outdated

validate variables , forms and DTO s validation

Queen validators 👑 #

Table of Contents #

Validate variables #

const badEmail = 'QueenRoyal.kingdom';
print(badEmail.isEmail) // false

const validEmail = 'Queen@Royal.kingdom';
print(validEmail.isEmail) // true

const badUrl = 'queen url validation';
print(badUrl.isURL) // false

const validUrl = 'https://www.abc.com';
print(validUrl.isURL) // true

Validate Forms #

import 'package/queen_validators/queen_validators.dart';
@override
Widget build(BuildContext context) {
return TextFormField(
     // use qValidator function and provider list of rules to apply on this field
    validator: qValidator([
      IsEmail(),
      MinLength(8),
      MaxLength(30, msg: "optionally you can decide which message to display if the validation fails"),
    ]),
  );
  }

Validate Dto #

import 'package:queen_validators/queen_validators.dart';
 // extends QueenDto
class LoginDto extends QueenDto {
  final String email;
  final String password;

  LoginDto({
    this.email,
    this.password,
  }) : super();
// don't forget to call the super;


// setup your keys and rules
  @override
  Map<String, List<QueenValidationRule>> get rules => {
        'email': [IsEmail()],
        'password': [MinLength(5),MaxLength(50)]
      };


// make sure to user same keys you used in the roles getter
  @override
  Map<String, dynamic> toMap() {
    return {'email': this.email,
            'password': this.password,
            };
  }
}

void main() {
  try {
     // it will trow QValidationException containing the failed rules
    LoginDto(email: 'queen@kingdom.com', password: 'bar');
   } on QValidationException catch (e) {
    print(e.errors);
  }
}

Features #

  • easily customize form validation error massages with any localization solution
  • need a rule is not in this package ? just extend QueenValidationRule
  • validate DTO s directly after instantiate them

TODO #

  • arabic documentation
  • example app
  • publish to pub.dev
  • tests

installation #

for now you can only use it from the github repo

how to use flutter package from github

79
likes
0
pub points
86%
popularity

Publisher

verified publishermaxzod.com

validate variables , forms and DTO s validation

Homepage

License

unknown (LICENSE)

More

Packages that depend on queen_validators