/// <summary>
        /// Get validation rules for an model
        /// </summary>
        /// <param name="controllerContext">Current controller context</param>
        /// <param name="model">Model to validate</param>
        /// <returns>Object which can be JSON serialized</returns>
        /// <remarks>Will only return rules which has not been fulfilled.</remarks>
        public ValidationRules GetRules(ControllerContext controllerContext, object model)
        {
            var metadata2 = ModelMetadataProviders.Current.GetMetadataForProperties(model, model.GetType()  );
            var validation = new ValidationRules();
            foreach (var modelMetadata in metadata2)
            {
                var validators = modelMetadata.GetValidators(controllerContext);
                if (!validators.Any())
                    continue;

                foreach (var validator in validators)
                {
                    foreach (var rule in validator.GetClientValidationRules())
                    {
                        if (rule.ValidationParameters.Any())
                        {
                            foreach (var kvp in rule.ValidationParameters)
                            {
                                validation.Rules.Add(modelMetadata.PropertyName, kvp.Key, kvp.Value.ToString());
                            }
                        }
                        else
                            validation.Rules.Add(modelMetadata.PropertyName, rule.ValidationType, "true");

                        validation.Messages.Add(modelMetadata.PropertyName, rule.ValidationType, rule.ErrorMessage);
                    }
                }
            }

            return validation;
        }
        public void SerializeValidationRules()
        {
            var rules = new ValidationRules();
            rules.Messages.Add("SomeProp", "required", "The field is required, dude!");
            rules.Rules.Add("someProp", "required", "true");
            rules.Rules.Add("someProp", "max", "40");

            var actual = JsonConvert.SerializeObject(new JsonResponse(true, rules));

            Assert.Equal(@"{""success"":true,""contentType"":""validation-rules"",""body"":{""messages"":{""SomeProp"":{""required"":""The field is required, dude!""}},""rules"":{""someProp"":{""required"":""true""}}}}", actual);
        }