Validating forms
Check what people enter before a record is saved
StellarAdmin fully integrates with ASP.NET Core validation, and runs validation before saving a record. If a field isn't valid, StellarAdmin will not save the record and will displays the form again with the validation errors.
The example below requires a code of up to 12 characters, and a group size between 1 and 40:
public class Trip
{
[Required, StringLength(12)]
public string Code { get; set; } = "";
[Range(1, 40)]
public int MaxGroupSize { get; set; } = 16;
}The screenshot below demonstrates what happens when the user attempts to save the form with invalid values.


StellarAdmin validates forms with the ASP.NET Core model validation pipeline, so validation libraries that plug into the pipeline work with StellarAdmin too.
For example, to validate StellarAdmin's forms with FluentValidation validators, enable FluentValidation's automatic validation by calling AddFluentValidationAutoValidation() from the FluentValidation.AspNetCore package.
A custom data source can also return validation errors when it saves a record. This is useful when you want to map validation errors from an external source such as a REST API.
Displaying database errors
When EF Core reports a concurrency conflict, the form displays "This record changed while you were working. Reload it and try again." If the record was deleted in the meantime, StellarAdmin returns a 404 Not Found response.
When saving fails for any other reason, such as a duplicate value in a unique index, StellarAdmin logs the exception, and the form displays "This record couldn't be saved. Try again."