Code coverage report for src/Common/Assert/Max.js

Statements: 100% (8 / 8)      Branches: 100% (2 / 2)      Functions: 100% (1 / 1)      Lines: 100% (8 / 8)      Ignored: none     

All files » src/Common/Assert/ » Max.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34    1                                 1   31 31   31 12     19       1  
'use strict';
 
var _           = require("lodash"),
    Type        = require("../Type"),
    Safe        = require("../Safe"),
    Exception   = require("../Exception/Exception");
 
 
 
/**
 *
 * Test the max length of any kind of object
 *
 * @throws {Exception}
 *
 * @param {*} val
 * @return {*}
 *
 */
var Max = function(val, max){
 
    max = Safe.number(max);
    var length = Safe.length(val);
 
    if(length > max){
        throw new Exception("VALIDATION_MAX", { value: max });
    }
 
    return val;
 
};
 
module.exports = Max;