# ValidationRule Class

> ValidationRule class in the TX Sheet Control .NET API: Cell constraints shared with the editor. Covers 1 constructor and 16 properties and a C# example.

- **Product:** TX Sheet Control
- **Section:** Documentation
- **Kind:** Class
- **Namespace:** `TXTextControl.TXSheetControl.Server`
- **Package:** `TXTextControl.TXSheetControl.Server` (assembly `TXTextControl.TXSheetControl.Api.dll`, from the private NuGet feed or the supplied NuGet folder)
- **Package:** `TXTextControl.TXSheetControl.Blazor` (assembly `TXTextControl.TXSheetControl.Api.dll`, from the private NuGet feed or the supplied NuGet folder)
- **Implements:** `System.IEquatable<TXTextControl.TXSheetControl.Server.ValidationRule>`
- **Path:** TX Sheet Control > API Reference > .NET API > TXTextControl.TXSheetControl.Server > ValidationRule Class
- **1471 words**
- **Web URL:** https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/validationrule/
- **LLMs URL:** https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/validationrule/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/validationrule/llms-full.txt

---

Cell constraints shared with the editor. Types and operators use the same portable strings as JavaScript.

### Syntax

```csharp
public class ValidationRule
```

Interfaces: `IEquatable<ValidationRule>`.

### Members

#### Constructors

| Constructor | Description |
|---|---|
| [Constructor](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/validationrule/constructor/llms-full.txt) |  |

#### Properties

| Property | Description |
|---|---|
| [AllowBlank](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/validationrule/allowblank-property/llms-full.txt) |  |
| [ErrorMessage](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/validationrule/errormessage-property/llms-full.txt) |  |
| [ErrorStyle](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/validationrule/errorstyle-property/llms-full.txt) |  |
| [ErrorTitle](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/validationrule/errortitle-property/llms-full.txt) |  |
| [Formula1](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/validationrule/formula1-property/llms-full.txt) |  |
| [Formula2](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/validationrule/formula2-property/llms-full.txt) |  |
| [Id](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/validationrule/id-property/llms-full.txt) |  |
| [InputMessage](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/validationrule/inputmessage-property/llms-full.txt) |  |
| [InputTitle](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/validationrule/inputtitle-property/llms-full.txt) |  |
| [Operator](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/validationrule/operator-property/llms-full.txt) |  |
| [Range](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/validationrule/range-property/llms-full.txt) |  |
| [ShowDropdown](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/validationrule/showdropdown-property/llms-full.txt) |  |
| [ShowErrorMessage](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/validationrule/showerrormessage-property/llms-full.txt) |  |
| [ShowInputMessage](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/validationrule/showinputmessage-property/llms-full.txt) |  |
| [Type](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/validationrule/type-property/llms-full.txt) |  |
| [Values](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/validationrule/values-property/llms-full.txt) |  |

### Examples

Apply ValidationRule to a small working document, then return the exported bytes. The caller can save or download the result.

```csharp
using TXTextControl.TXSheetControl.Server;

async Task<byte[]> CreateValidationRuleReportAsync(ServerSheetControl control)
{
    var book = control.Workbook;
    var sheet = await book.Sheets.AtAsync(0);
    await sheet.Cell("B8").SetValueAsync(120);
    await sheet.Cell("B9").SetValueAsync(80);
    await sheet.Cell("B10").SetFormulaAsync("=SUM(B8:B9)");
    await sheet.Cell("A1").SetTextAsync("October invoice");
    await sheet.Cell("A1").FormatAsync(new { fontFamily = "Liberation Sans", fontSize = 16, bold = true, textColor = "#ffffff", fillColor = "#163b63" });
    await sheet.Range("B8:B10").FormatAsync(new { numberFormatCode = "#,##0.00", fontFamily = "Liberation Sans", fontSize = 11 });

    var settings = new ValidationRule()
    {
        AllowBlank = true,
        Formula1 = "0",
        Formula2 = "10000",
        Operator = "between",
        Range = "B8:B9",
        Type = "decimal"
    };

    await sheet.Validation.SetAsync("B8:B9", settings);
    return await control.SaveAsync(StreamType.SpreadsheetML);
}
```

### See Also

- [TXTextControl.TXSheetControl.Server Namespace](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/llms-full.txt)
- [Data Validation](https://docs.textcontrol.com/tx-sheet-control/spreadsheets/validation/llms-full.txt)

---

## In This Section

- [ValidationRule.AllowBlank Property](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/validationrule/allowblank-property/llms-full.txt): ValidationRule.AllowBlank property in the TX Sheet Control .NET API, with its syntax, its type bool?, a C# example and remarks on awaiting tasks and handles.
- [ValidationRule Constructor](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/validationrule/constructor/llms-full.txt): ValidationRule constructor in the TX Sheet Control .NET API, with its syntax, a C# example and remarks on awaiting tasks and handles.
- [ValidationRule.ErrorMessage Property](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/validationrule/errormessage-property/llms-full.txt): ValidationRule.ErrorMessage property in the TX Sheet Control .NET API, with its syntax, its type string? and a C# example.
- [ValidationRule.ErrorStyle Property](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/validationrule/errorstyle-property/llms-full.txt): ValidationRule.ErrorStyle property in the TX Sheet Control .NET API, with its syntax, its type string? and a C# example.
- [ValidationRule.ErrorTitle Property](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/validationrule/errortitle-property/llms-full.txt): ValidationRule.ErrorTitle property in the TX Sheet Control .NET API, with its syntax, its type string? and a C# example.
- [ValidationRule.Formula1 Property](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/validationrule/formula1-property/llms-full.txt): ValidationRule.Formula1 property in the TX Sheet Control .NET API, with its syntax, its type string?, a C# example and remarks on awaiting tasks and handles.
- [ValidationRule.Formula2 Property](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/validationrule/formula2-property/llms-full.txt): ValidationRule.Formula2 property in the TX Sheet Control .NET API, with its syntax, its type string?, a C# example and remarks on awaiting tasks and handles.
- [ValidationRule.Id Property](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/validationrule/id-property/llms-full.txt): ValidationRule.Id property in the TX Sheet Control .NET API, with its syntax, its type string?, a C# example and remarks on awaiting tasks and handles.
- [ValidationRule.InputMessage Property](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/validationrule/inputmessage-property/llms-full.txt): ValidationRule.InputMessage property in the TX Sheet Control .NET API, with its syntax, its type string? and a C# example.
- [ValidationRule.InputTitle Property](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/validationrule/inputtitle-property/llms-full.txt): ValidationRule.InputTitle property in the TX Sheet Control .NET API, with its syntax, its type string? and a C# example.
- [ValidationRule.Operator Property](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/validationrule/operator-property/llms-full.txt): ValidationRule.Operator property in the TX Sheet Control .NET API, with its syntax, its type string?, a C# example and remarks on awaiting tasks and handles.
- [ValidationRule.Range Property](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/validationrule/range-property/llms-full.txt): ValidationRule.Range property in the TX Sheet Control .NET API, with its syntax, its type string?, a C# example and remarks on awaiting tasks and handles.
- [ValidationRule.ShowDropdown Property](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/validationrule/showdropdown-property/llms-full.txt): ValidationRule.ShowDropdown property in the TX Sheet Control .NET API, with its syntax, its type bool? and a C# example.
- [ValidationRule.ShowErrorMessage Property](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/validationrule/showerrormessage-property/llms-full.txt): ValidationRule.ShowErrorMessage property in the TX Sheet Control .NET API, with its syntax, its type bool? and a C# example.
- [ValidationRule.ShowInputMessage Property](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/validationrule/showinputmessage-property/llms-full.txt): ValidationRule.ShowInputMessage property in the TX Sheet Control .NET API, with its syntax, its type bool? and a C# example.
- [ValidationRule.Type Property](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/validationrule/type-property/llms-full.txt): ValidationRule.Type property in the TX Sheet Control .NET API, with its syntax, its type string, a C# example and remarks on awaiting tasks and handles.
- [ValidationRule.Values Property](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/validationrule/values-property/llms-full.txt): ValidationRule.Values property in the TX Sheet Control .NET API, with its syntax, its type string[], a C# example and remarks on awaiting tasks and handles.

---

## Nearby

- **Previous:** [ValidationFailure.Rule Property](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/validationfailure/rule-property/llms-full.txt)
- **Next:** [ValidationRule Constructor](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/validationrule/constructor/llms-full.txt)
