简体   繁体   English

应用服务验证中的Asp.Net Boilerplate抛出异常

[英]Asp.Net Boilerplate throwing exception on app service validation

Fallowing the Asp.Net Boilerplate documentation, i can see that when the model is not valid an exception is thrown: 查看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.
    }
}

Is there an alternative way in the Asp.Net Boilerplate core to change this approach? Asp.Net Boilerplate核心中是否有其他方法可以更改此方法?

thanl you in advance. 提前告诉你。

ABP validates input only if it implements IValidate. ABP仅在实现IValidate时才验证输入。 If you do not want to validate it, do not implement this interface, that's all. 如果您不想验证它,就不要实现此接口,仅此而已。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM