public async Task <IActionResult> IsNameUnique(string name) { var site = await _contextService.CurrentSiteAsync(); var isNameUnique = await _permissionSetRules.IsNameUniqueAsync(site.Id, name); return(Ok(isNameUnique)); }
public CreatePermissionSetValidator(IPermissionSetRules rules) { RuleFor(c => c.Name) .NotEmpty().WithMessage("Permission set name is required.") .Length(1, 50).WithMessage("Permission set name must be at least 1 and at max 50 characters long.") .MustAsync((c, p, cancellation) => rules.IsNameUniqueAsync(c.SiteId, p)) .WithMessage(c => $"A permission set with name {c.Name} already exists."); }