Asp.Net Boilerplate throwing exception on app service validation

4.8k views Asked by At

Fallowing the Asp.Net Boilerplate documentation, i can see that when the model is not valid an exception is thrown:

/// <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?

thanl you in advance.

1

There are 1 answers

0
hikalkan On

ABP validates input only if it implements IValidate. If you do not want to validate it, do not implement this interface, that's all.