Completed
Push — master ( 8b9cfc...42b0f8 )
by wiese
319:40 queued 254:38
created

skins/cat17/src/app/lib/state_aggregation/membership/payment_and_bank_data_are_valid.js   A

Complexity

Total Complexity 4
Complexity/F 4

Size

Lines of Code 23
Function Count 1

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 0
wmc 4
c 1
b 0
f 0
nc 4
mnd 2
bc 4
fnc 1
dl 0
loc 23
rs 10
bpm 4
cpm 4
noi 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A module.exports 0 17 4
1
'use strict';
2
3
var _ = require( 'underscore' ),
4
	validationResult = require( './../validation_result' )
5
;
6
7
module.exports = function ( state ) {
8
	var result = _.clone( validationResult ),
9
		respectiveValidators = _.pick( state.membershipInputValidation, [ 'iban', 'bic', 'accountNumber', 'bankCode' ] )
10
	;
11
12
	result.dataEntered = state.membershipFormContent.paymentType !== null || _.contains( _.pluck( respectiveValidators, 'dataEntered' ), true );
13
14
	if ( _.contains( _.pluck( respectiveValidators, 'isValid' ), false ) || state.validity.bankData === false ) {
15
		result.isValid = false;
16
	} else if ( state.membershipFormContent.paymentType === null ) {
17
		result.isValid = null;
18
	} else {
19
		result.isValid = true;
20
	}
21
22
	return result;
23
};
24