whatgoodisaroad/validity

sumMin() behave same as sumMax()

Closed this issue · 1 comments

In the aggregate validator sumMin() implemented using 'less than' operator (<) where as it must be 'grater than' (>) operator. Therefore sumMin behave same as sumMax(). This defect was seen in Validity Version 1.2.0

Current Implementation

            if ($reduction.length && min < numericSum($reduction)) {
                raiseAggregateError(
                    $reduction,
                    msg || format(
                        $.validity.messages.sumMin,
                        { min:min }
                    )
                );

Corrected Implementation

            if ($reduction.length && min > numericSum($reduction)) {
                raiseAggregateError(
                    $reduction,
                    msg || format(
                        $.validity.messages.sumMin,
                        { min:min }
                    )
                );

Included in 1.3.0. Thanks!