Skip to content

Commit

Permalink
Improved initializer validator
Browse files Browse the repository at this point in the history
  • Loading branch information
wilburx9 committed Feb 19, 2020
1 parent bfc0eb4 commit f517016
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions lib/src/common/validator_utills.dart
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,10 @@ class ValidatorUtils {
if (init.redirectUrl == null) return Strings.cannotBeNull('redirectUrl');
if (init.fName == null) return Strings.cannotBeNull('fName');
if (init.lName == null) return Strings.cannotBeNull('lName');
if (init.acceptAchPayments == null) return Strings.cannotBeNull('withAch');
if (init.acceptAchPayments == null)
return Strings.cannotBeNull('acceptAchPayments');
if (init.acceptMpesaPayments == null)
return Strings.cannotBeNull('withMpesa');
return Strings.cannotBeNull('acceptMpesaPayments');
if (init.acceptMpesaPayments) {
if (init.currency.toUpperCase() != "KES") {
return "currency should be \"KES\" for Mpesa payments but \"${init.currency}\" was passed";
Expand All @@ -165,23 +166,27 @@ class ValidatorUtils {
}
}
if (init.acceptAccountPayments == null)
return Strings.cannotBeNull('withAccount');
return Strings.cannotBeNull('acceptAccountPayments');
if (init.acceptCardPayments == null)
return Strings.cannotBeNull('withCard');
return Strings.cannotBeNull('acceptCardPayments');
if (init.acceptGHMobileMoneyPayments == null)
return Strings.cannotBeNull('withGHMobileMoney');
return Strings.cannotBeNull('acceptGHMobileMoneyPayments');
if (init.acceptUgMobileMoneyPayments == null)
return Strings.cannotBeNull('withUgMobileMoney');
return Strings.cannotBeNull('acceptUgMobileMoneyPayments');
if (init.acceptMobileMoneyFrancophoneAfricaPayments == null)
return Strings.cannotBeNull('acceptMobileMoneyFrancophoneAfricaPayments');
if (init.isPreAuth == null) return Strings.cannotBeNull('isPreAuth');
if (init.displayFee == null) return Strings.cannotBeNull('displayFee');
if (init.displayEmail == null) return Strings.cannotBeNull("displayEmail");
if (init.displayAmount == null)
return Strings.cannotBeNull("displayAmount");
if (!init.acceptCardPayments &&
!init.acceptAccountPayments &&
!init.acceptAchPayments &&
!init.acceptMpesaPayments &&
!init.acceptGHMobileMoneyPayments &&
!init.acceptUgMobileMoneyPayments) {
!init.acceptUgMobileMoneyPayments &&
!init.acceptMobileMoneyFrancophoneAfricaPayments) {
return "No payment mode";
}
return null;
Expand Down

0 comments on commit f517016

Please sign in to comment.