Asp.Net Boilerplate在应用服务验证上抛出异常

时间:2014-11-13 22:08:22

标签: c# asp.net-mvc validation viewmodel boilerplate

通过Asp.Net Boilerplate文档,我可以看到当模型无效时会引发异常:

/// <summary>
/// Validates the method invocation.
/// </summary>
public void Validate()
{
    if (_parameters.IsNullOrEmpty())
    {
        //Object has no parameter, no need to validate.
        return;
    }

    if (_parameters.Length != _arguments.Length)
    {
        throw new Exception("Method parameter count does not match with argument count!");
    }

    for (var i = 0; i < _parameters.Length; i++)
    {
        Validate(_parameters[i], _arguments[i]);
    }

    if (_validationErrors.Any())
    {
        throw new AbpValidationException("Method arguments are not valid! See ValidationErrors for details.") { ValidationErrors = _validationErrors };
    }

    foreach (var argument in _arguments)
    {
        Normalize(argument); //TODO@Halil: Why not normalize recursively as we did in validation.
    }
}

在Asp.Net Boilerplate核心中是否有另一种方法可以改变这种方法?

提前告诉你。

1 个答案:

答案 0 :(得分:0)

只有在实施IValidate时,ABP才会验证输入。如果您不想验证它,请不要实现此界面,这就是全部。