Javascript - Implement a validation rule

I need to apply a validation rule for a set of objects. This is my validation rules.

{      val1 : {
               "validation" : true,
               "name" : 'string',

       },
       val2 : {
               "validation" : true,
               "name" : 'string',
                "maxLength": 30
       },
       val3 : {
               "validation" : false,
               "name" : 'string',
                "type" : 'string'
       }
}

And these are the object the rules need to be applied to. The rules should apply only when validation property is true, when the validation property is false it should not apply.

var objMain = {     val1 : {
                          "id" : '32324',
                          "name" : 'page1',

                    },
                    val1 : {
                         "name" : 'page2',
                         "type": "template"
                    },
                    val1 : {
                          "name" : 'page3',
                          "type": "template2"
                    }
               }