Out of the box with database constraints all that is needed is
public async Task<IActionResult> OnPostAsync()
{
if (!ModelState.IsValid)
{
return Page();
}
return RedirectToPage("Page to go to on successful post");
}
And then of course couple with attributes
[Required]
[Display(Name = "First Name")]
[StringLength(50)]
public string FirstName { get; set; }