liveBook · Manning

Validation

As explained in .NET MAUI in Action

Validation is the process of checking user-provided data against validity rules and informing the user when the data is invalid.

Validation checks user-provided data against validity rules, informs users when entries are invalid, and prevents invalid data from being submitted. Rules can require a number within a range, an approved-list value, or a valid email address. section 11.1.2

Validating a custom stepper

A stock-count stepper can prevent values below zero and disable its add button when input is invalid. Add a visible warning Label for feedback, or use validation behaviors from the .NET MAUI Community Toolkit. Rejecting an invalid value without explaining why is input prevention, not complete validation. section 11.1.2

private void MinusButton_Clicked(object sender, EventArgs e)
{
    if (Value > 0)
    {
        Value--;
        ValueEntry.Text = Value.ToString();
    }
}

Use the decrement guard as a concrete example of enforcing a lower-bound rule before changing control state. section 11.1.2

if (e.NewTextValue.StartsWith("-"))
{
    ValueEntry.Text = Value.ToString();
    return;
}

Use the text-entry guard as a concrete example of detecting a negative value and restoring the current valid value. section 11.1.2

How .NET MAUI in Action covers it

How deep it goes
Explains validation rules, feedback, and implementation choices, but stops short of detailed bindable-property implementation.
Examples
Uses a stock-count stepper, nonnegative range checks, warning labels, approved lists, and email-address checks.
What it assumes
Assumes familiarity with UI event handlers and custom controls while introducing validation feedback from the beginning.
What you can do after
Apply validation through warning labels, control-state checks, or .NET MAUI Community Toolkit behaviors.
How it connects
Connects validation with custom controls, bindable properties, behaviors, and the .NET MAUI Community Toolkit.

Also explained in

Compare how 30 books explain validation →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of .NET MAUI in Action. The section links point to the parts of the book it draws on.