0
learnabp created
- ABP Framework version: v4.2.2
- UI type: MVC
- DB provider: EF Core
- Tiered (MVC) or Identity Server Separated (Angular): no
- Exception message and stack trace:
- Steps to reproduce the issue:
I am trying to have a validate confirm password input with password input, please see below code
I am getting the Validation Error come up twice please see below screen shot.
can you please suggest why i am getting the error twice?
public virtual async Task<IActionResult> OnPostAsync()
{
ValidateModel();
var input = ObjectMapper.Map<TenantInfoModel, SaasTenantCreateDto>(Tenant);
await TenantRegistrationAppService.RegisterTenantAsync( new RegisterTenantInputDto { SaasTenantCreateDto = input });
return NoContent();
}
public class TenantInfoModel : ExtensibleObject, IValidatableObject
{
[Required]
[StringLength(TenantConsts.MaxNameLength)]
public string Name { get; set; }
[SelectItems(nameof(EditionsComboboxItems))]
public Guid? EditionId { get; set; }
[Required]
[EmailAddress]
[StringLength(256)]
public string AdminEmailAddress { get; set; }
[Required]
[DataType(DataType.Password)]
[StringLength(128)]
[DisableAuditing]
public string AdminPassword { get; set; }
[Required]
[DataType(DataType.Password)]
[StringLength(128)]
[DisableAuditing]
public string ConfirmAdminPassword { get; set; }
public override IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{
if (!AdminPassword.Equals(ConfirmAdminPassword , StringComparison.Ordinal))
{
yield return new ValidationResult(
"The passwords do not match!",
new[] { "AdminPassword", "ConfirmAdminPassword" }
);
}
base.Validate(validationContext);
}
}
4 Answer(s)
-
0
hi
You can try to remove
base.Validate(validationContext);
-
0
no thats not it still same result
-
0
hi
Can you try to specify one member?
yield return new ValidationResult( "The passwords do not match!", new[] { "ConfirmAdminPassword" } );
-
0
Yes that works