handle method

  1. @override
bool handle(
  1. Map<String, dynamic> info
)
override

Handle the validation, the info variable will contain the following: info'rule' = Validation rule i.e "min". info'data' = Data the user has passed into the validation. info'message' = Overriding message to be displayed for validation (optional).

Implementation

@override
bool handle(Map<String, dynamic> info) {
  super.handle(info);
  RegExp regExp = RegExp("contains:([A-z0-9, ]+)");
  String match = regExp.firstMatch(info['rule'])!.group(1) ?? "";
  List<String> listMatches = match.split(",");

  return listMatches
      .any((element) => validate.contains(info['data'], element));
}