NameValidationPolicyAnnotation
Class sealed net8.0
Represents an annotation that customizes the name validation rules applied to a resource when it is added to the application model.
namespace Aspire.Hosting.ApplicationModel;
public sealed class NameValidationPolicyAnnotation : Aspire.Hosting.ApplicationModel.IResourceAnnotation{ // ...} 8 members
Remarks
Section titled Remarks By default, resource names must be 1–64 ASCII characters long, start with a letter, contain only letters, digits, and hyphens, and not contain consecutive or trailing hyphens. Use this annotation to relax individual rules. The
NameValidationPolicyAnnotation.None policy disables every rule, which is useful for internal resources (such as installers or rebuilders) that append suffixes to user-provided resource names and are never deployed. Constructors1
Section titled ConstructorsProperties5
Section titled PropertiesMaxLengthget; initint? Gets the maximum allowed length for the resource name, or
null to disable length validation. Defaults to ModelName.DefaultMaxLength. ValidateAllowedCharactersget; initbool Gets a value indicating whether to validate that the name contains only ASCII letters, digits, and hyphens. Defaults to
true. ValidateNoConsecutiveHyphensget; initbool Gets a value indicating whether to validate that the name does not contain consecutive hyphens. Defaults to
true. ValidateNoTrailingHyphenget; initbool Gets a value indicating whether to validate that the name does not end with a hyphen. Defaults to
true. ValidateStartsWithLetterget; initbool Gets a value indicating whether to validate that the name starts with an ASCII letter. Defaults to
true. Fields2
Section titled FieldsDefaultstatic The default policy that enforces all standard name validation rules.
Nonestatic A policy that disables all name validation rules.