Queen validators 👑

Table of Contents

مقال يشرح بالعربي الفائده من المكتبة وطريقة الاستخدام


  • easily customize form validation error massages with any localization solution
  • need a new rule ? just extend QueenValidationRule class and build your own rule
  • extension on String and dynamic Types give you little push


  queen_validators: ^0.0.1+9-beta

Validate variables

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

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

Validate Forms

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

Supported Rules

Rule#default message
IsOptionalallows you to skip the errors if the input is empty
IsRequiredthe input value must not be emptyrequired
IsEmailthe input value must be a valid email addressis not valid email address
Match(String stringToMatchWith,{bool ignoreCase = false})the input value must match other Stringdid not match
IsIn(List<String>)the input value must be in the provided listis not accepted
IsNotIn(List<String>)the input value must not be in the provided listis not valid email address
MaxLength(int max)the input value length must not be > the max'max length is $max'
MinLength(int min)the input value length must not be < the min'min length is $min'
RegExpRule(RegExp regX)the input value mush match the provided regXdid not match
Contain(String value)checks if the input does contain the provided valuemust contain $value
NotContains(String val)checks if input does not contain the provided valuemust not contain $value
ContainsAny(List<String> val)check if the value contain at lest one of String form the provided listmust contain any blacklisted keywords
NotContainsAny(List<String> val)check if the value does not contain any item from the provided listmust contain at least one of the whitelisted keywords