Base solution for your next web application
Open Closed

Is TenancyNameRegex on Tenant Display Name Intentional? #12655


User avatar
0
jlennard created

We're currently upgrading from v13 to v14.3 and noticed that CreateTenantInput.Name now has [RegularExpression(TenantConsts.TenancyNameRegex)] applied, restricting the display name to the same URL-slug format as TenancyName — meaning values like "Acme Corp" would fail validation on create. We have existing tenant records whose Name values don't match this regex, so we're planning to remove the [RegularExpression] attribute from Name manually, but wanted to check first whether this was intentional and if there's something we're missing about how the tenant Name field is expected to be used. For reference, TenantEditDto.Name does not carry this attribute, so there's already an inconsistency between create and edit validation.

Markdown is supported
Copy & paste or drag & drop images (max 30 MB per image)

1 Answer(s)
  • User Avatar
    0
    oguzhanagir created
    Support Team

    Hi @jlennard

    Thanks for pointing this out. You are right to question this.

    In ASP.NET Zero, TenancyName and Name have different purposes:

    • TenancyName is the unique tenant identifier and can be used for URL/subdomain-style tenant resolution, so TenantConsts.TenancyNameRegex is expected there.
    • Name is the tenant display name. Values like Acme Corp should be valid for this field.

    So applying TenantConsts.TenancyNameRegex to CreateTenantInput.Name is not necessary for the display name, and the fact that TenantEditDto.Name does not have the same attribute also shows an inconsistency between create and edit validation.

    You can remove the [RegularExpression(TenantConsts.TenancyNameRegex)] attribute from CreateTenantInput.Name in your project. If you are using the React, Angular or MVC UI, also check the client-side pattern / regex validation on the tenant create/edit forms so the UI and backend remain consistent.

    Existing tenant records do not need to be changed. Only TenancyName should continue to follow the slug style format.

    Thanks for reporting this; we will review it on our side as well.

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)