Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The first question is how are you handling validation exceptions?</p> <p>the most common procedure to perform this kind of task is by using the fluentValidation, the response can return a message for more than one validation at the time, all the validations are against DTOs and you´ll need to implement an AbstractValidator, the first thing you need to do is to register the validators that belons to your applciation like the following:</p> <pre><code>Plugins.Add(new ValidationFeature()); container.RegisterValidators(typeof(CredentialsAuthValidator).Assembly); </code></pre> <p>I´m valdiating in this case that the Auth username and password should not be Empty, take a look to the following example:</p> <pre><code>public class CredentialsAuthValidator : AbstractValidator&lt;ServiceStack.ServiceInterface.Auth.Auth&gt; { public CredentialsAuthValidator() { RuleSet(ApplyTo.Post, () =&gt; { RuleFor(x =&gt; x.UserName).NotNull().WithMessage("Username Required").When(x =&gt; x.provider == "Credentials"); RuleFor(x =&gt; x.Password).NotNull().WithMessage("Password Required").When(x =&gt; x.provider == "Credentials"); } ); } } </code></pre> <p>if some of the validation fails you´ll get a responseStatus from the server with the errorCode and the messages. </p> <p>You can configure a custom httpHandlers in the case you would like to have a handler for specific scenarios or a global error handler, this can be performed in your serviceHost configuration, something like this:</p> <pre><code> GlobalHtmlErrorHttpHandler = new RazorHandler("/views/error"), CustomHttpHandlers = { {HttpStatusCode.NotFound, new RazorHandler("/views/notfound")}, {HttpStatusCode.Unauthorized, new RazorHandler("/views/login")}, {HttpStatusCode.Forbidden, new RazorHandler("/views/forbidden")}, } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload