LazZiya / XLocalizer

Localizer package for Asp.Net Core web applications, powered by online translation and auto resource creating.
https://docs.ziyad.info
129 stars 14 forks source link

Data Annotation issue: FormatException: Input string was not in a correct format. #48

Closed faresayyad closed 4 months ago

faresayyad commented 4 months ago

Hello,

I am getting an issue when trying to show Idenity register page in Arabic culture: I disable all attributes one by one to figure out which one causing the issue and it seems to be the Compare attribute.

       [Required]
            [StringLength(maximumLength: 100, MinimumLength = 6)]
            [DataType(DataType.Password)]
            [Display(Name = "Password")]
            public string Password { get; set; }

            /// <summary>
            ///     This API supports the ASP.NET Core Identity default UI infrastructure and is not intended to be used
            ///     directly from your code. This API may change or be removed in future releases.
            /// </summary>
            [DataType(DataType.Password)]
            [Display(Name = "Confirm password")]
            [Compare(otherProperty: "Password")]
            public string ConfirmPassword { get; set; }

I have tried to add specific validation error in Program.cs like this:

 ops.ValidationErrors = new ValidationErrors
        {
            CompareAttribute_MustMatch="Values '{0}' must match value '{1}'"
        };

nothing changes. same error: FormatException: Input string was not in a correct format.

faresayyad commented 4 months ago

It's my mistake, there should be a key/value in translated XML file