Ejegg has uploaded a new change for review.
https://gerrit.wikimedia.org/r/286934
Change subject: Restore check_not_empty
......................................................................
Restore check_not_empty
Partially reverts 8329b0e9021d
Bug: T134189
Change-Id: I8d314d3167257932fb38237bfdfe10abccaf3cb5
---
M gateway_common/DataValidator.php
M gateway_common/DonationData.php
2 files changed, 14 insertions(+), 4 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/DonationInterface
refs/changes/34/286934/1
diff --git a/gateway_common/DataValidator.php b/gateway_common/DataValidator.php
index 009b8dd..56b210c 100644
--- a/gateway_common/DataValidator.php
+++ b/gateway_common/DataValidator.php
@@ -175,12 +175,16 @@
* normalized) DonationInterface data set.
* @param GatewayType $gateway
* @param array $data Normalized donation data.
+ * @param array $check_not_empty An array of fields to do empty
validation
+ * on. If this is not populated, no fields will throw errors for being
empty,
+ * UNLESS they are required for a field that uses them for more complex
+ * validation (the 'calculated' phase).
* @throws BadMethodCallException
- * @return array An array of errors in a format ready for any
derivitive of
+ * @return array An array of errors in a format ready for any
derivative of
* the main DonationInterface Form class to display. The array will be
empty
* if no errors were generated and everything passed OK.
*/
- public static function validate( GatewayType $gateway, $data ) {
+ public static function validate( GatewayType $gateway, $data,
$check_not_empty = array() ){
//return the array of errors that should be generated on
validate.
//just the same way you'd do it if you were a form passing the
error array around.
@@ -239,6 +243,12 @@
),
);
+ // Additional fields we should check for emptiness.
+ if ( $check_not_empty ) {
+ $validations['not_empty'] = array_unique( array_merge(
+ $check_not_empty, $validations['not_empty']
+ ) );
+ }
$errors = array();
$results = array();
diff --git a/gateway_common/DonationData.php b/gateway_common/DonationData.php
index 992b5ef..901009c 100644
--- a/gateway_common/DonationData.php
+++ b/gateway_common/DonationData.php
@@ -972,10 +972,10 @@
* If it is not, it will return an array of errors ready for any
* DonationInterface form class derivitive to display.
*/
- public function getValidationErrors( $recalculate = false ) {
+ public function getValidationErrors( $recalculate = false,
$check_not_empty = array() ){
if ( is_null( $this->validationErrors ) || $recalculate ) {
// Run legacy validations
- $this->validationErrors = DataValidator::validate(
$this->gateway, $this->normalized );
+ $this->validationErrors = DataValidator::validate(
$this->gateway, $this->normalized, $check_not_empty );
// Run modular validations.
// TODO: Move this... somewhere.
--
To view, visit https://gerrit.wikimedia.org/r/286934
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I8d314d3167257932fb38237bfdfe10abccaf3cb5
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/DonationInterface
Gerrit-Branch: master
Gerrit-Owner: Ejegg <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits