We will continuing using previous tutorial "Logistics" and add validator to show how to use this feature

## Add Validation to TransportGuide

Open your Visual Code and login. Open object **TransportGuide**.

Add to the existing property **documentNumber** the following validation rule:

  • Document Number must be filled

Find property **documentNumber** and bellow the property and the following code lines

  • **_value** reference the property in the scope.

If you return null, the validation engine will assume True.

Code above is the some as doing:

The result of the validation will be structured:

  • **IsValid** Boolean

  • **ErrorMessage** error validation message if **IsValid** is False

Also you can have global Validator that is associate with the Object (not with a Property).

Lets add global validation of the Object **TransportGuide**, where transport guide have to have at least one shipping guide.

The full code of the **TransportGuide** have to be:

## Download & Update Nuget packages

Build and download Nuget packages. _On build file ("Logistics") select "Download" (choosing directory where you want to download the files)_

Open your Visual Studio and the project previous created "Tutorial - Logistics".

Update the 2 Nuget packages on your Visual Studio project. _note: before updating, on command prompt (cmd), PowerShell or Package Manager Console of Visual Studio execute the command bellow_

_This clean nuget cache of the system, ensuring that version want is running_

## Use of Validaters

On class "Program.cs" add the following function:

Add call on "main" to the function that you have create.

Run the program and in the command prompt you should see the messages of the validations performed.


The solution is available: [Source](🔗)