# NameValidationPolicyAnnotation Properties

- Package: [Aspire.Hosting](/reference/api/csharp/aspire.hosting.md)
- Type: [NameValidationPolicyAnnotation](/reference/api/csharp/aspire.hosting/namevalidationpolicyannotation.md)
- Kind: `Properties`
- Members: `5`

Represents an annotation that customizes the name validation rules applied to a resource when it is added to the application model.

## MaxLength

- Name: `MaxLength`
- Modifiers: `nullable` `get; init`
- Returns: `int?`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/bd20f904cde09ecb9c9ae5116a6f13614bf2d7c2/src/Aspire.Hosting/ApplicationModel/NameValidationPolicyAnnotation.cs)

Gets the maximum allowed length for the resource name, or `null` to disable length validation. Defaults to `ModelName.DefaultMaxLength`.

```csharp
public int? MaxLength { get; init; }
```

## ValidateAllowedCharacters

- Name: `ValidateAllowedCharacters`
- Modifiers: `get; init`
- Returns: `bool`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/bd20f904cde09ecb9c9ae5116a6f13614bf2d7c2/src/Aspire.Hosting/ApplicationModel/NameValidationPolicyAnnotation.cs)

Gets a value indicating whether to validate that the name contains only ASCII letters, digits, and hyphens. Defaults to `true`.

```csharp
public bool ValidateAllowedCharacters { get; init; }
```

## ValidateNoConsecutiveHyphens

- Name: `ValidateNoConsecutiveHyphens`
- Modifiers: `get; init`
- Returns: `bool`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/bd20f904cde09ecb9c9ae5116a6f13614bf2d7c2/src/Aspire.Hosting/ApplicationModel/NameValidationPolicyAnnotation.cs)

Gets a value indicating whether to validate that the name does not contain consecutive hyphens. Defaults to `true`.

```csharp
public bool ValidateNoConsecutiveHyphens { get; init; }
```

## ValidateNoTrailingHyphen

- Name: `ValidateNoTrailingHyphen`
- Modifiers: `get; init`
- Returns: `bool`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/bd20f904cde09ecb9c9ae5116a6f13614bf2d7c2/src/Aspire.Hosting/ApplicationModel/NameValidationPolicyAnnotation.cs)

Gets a value indicating whether to validate that the name does not end with a hyphen. Defaults to `true`.

```csharp
public bool ValidateNoTrailingHyphen { get; init; }
```

## ValidateStartsWithLetter

- Name: `ValidateStartsWithLetter`
- Modifiers: `get; init`
- Returns: `bool`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/bd20f904cde09ecb9c9ae5116a6f13614bf2d7c2/src/Aspire.Hosting/ApplicationModel/NameValidationPolicyAnnotation.cs)

Gets a value indicating whether to validate that the name starts with an ASCII letter. Defaults to `true`.

```csharp
public bool ValidateStartsWithLetter { get; init; }
```
