<commit_before>﻿using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using SFA.DAS.CommitmentsV2.Api.Extensions;

namespace SFA.DAS.CommitmentsV2.Api.Attributes
{
    public class ValidateModelAttribute : ActionFilterAttribute
    {
        public override void OnActionExecuting(ActionExecutingContext context)
        {
            if (!context.ModelState.IsValid)
            {
                context.Result = new BadRequestObjectResult(context.ModelState.CreateErrorResponse());
            }
        }
    }
}<commit_msg>Updated validate model filter to set response sub status code header<commit_after>﻿using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using SFA.DAS.CommitmentsV2.Api.Extensions;
using SFA.DAS.CommitmentsV2.Api.Http;
using SFA.DAS.CommitmentsV2.Api.Types.Http;

namespace SFA.DAS.CommitmentsV2.Api.Attributes
{
    public class ValidateModelAttribute : ActionFilterAttribute
    {
        public override void OnActionExecuting(ActionExecutingContext context)
        {
            if (!context.ModelState.IsValid)
            {
                context.HttpContext.Response.SetSubStatusCode(HttpSubStatusCode.DomainException);
                context.Result = new BadRequestObjectResult(context.ModelState.CreateErrorResponse());
            }
        }
    }
}
{'fraction_non_alphanumeric': 0.08138658628485305, 'fraction_numerical': 0.00452147701582517, 'mean_word_length': 3.1370716510903427, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4233547', 'n_tokens_mistral': 354, 'n_tokens_neox': 373, 'n_words': 59}