-
Notifications
You must be signed in to change notification settings - Fork 1
Server Validation
damiancosmoschapman edited this page Oct 5, 2021
·
2 revisions
Home / Developer / Server Tier / Validation
Description of Server Side Validation, using **Fluent Validation **as a validation framework with code example for creating the Validator.
PDF-API uses FluentValidation as a validation framework. For details, please see https://fluentvalidation.net/. The FluentValidation Validators are part of the BaseTemplate model - a relevant validator must be injected into the Base class during construction.
The Validator is applied to a specific DTO. Therefore your DTO must be defined before creating the validator. An example of a validator is shown below:
internal class Comment_VLD : AbstractValidator<Comment_DTO>
{
internal Comment_VLD()
{
//Mandatory - CmmValue
RuleFor(f => f.CmmValue).Length(1, 1024).WithMessage("Invalid Comment").WithName("CommentValueValidation");
}
}