DotVVM转发器验证不显示错误消息

时间:2017-10-05 13:36:13

标签: validation repeater dotvvm

我正在通过转发器创建输入,并在提交后,在控制台中显示验证错误,但错误消息未显示在

中继器:                              

                            <div class="form-group">
                                <label>
                                    <dot:Literal Text="{value: Common.Phone}" />
                                </label>
                                <div class="phone input-group">
                                    <div class="phone__predvolba">
                                        <bp:DropDownList DataSource="{value: _parent.PhoneCodes}"
                                                         SelectedValue="{value: PhoneCode }"
                                                         Validation.Enabled="false"
                                                         class="admin-control admin-dropdown" />
                                    </div>
                                    <div class="phone__cislo">
                                        <dot:TextBox Text="{value: PhoneNumber}" Type="Telephone" class="admin-control" />
                                    </div>
                                </div>
                            </div>

                            <div class="position-relative text-danger">
                                <dot:Validator Value="{value:  PhoneNumber}"
                                               ShowErrorMessageText="true" />
                            </div>

                        </ItemTemplate>

DTO:

public class EmailBaseDTO : IEntity<int>, IValidatableObject
{
    public int Id { get; set; }

    [Required(ErrorMessageResourceName = nameof(Common.Resources.Admin.Common.Email_RequiredValidation),
        ErrorMessageResourceType = typeof(Common.Resources.Admin.Common))]
    [StringLength(250,
        ErrorMessageResourceName = nameof(eCENTRE.Common.Resources.Admin.Common.String_Length_Validation_50),
        ErrorMessageResourceType = typeof(eCENTRE.Common.Resources.Admin.Common))]
    public string Value { get; set; }

    public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
    {
        if (!String.IsNullOrEmpty(Value) && !StaticFunctions.IsValidEmail(Value))
        {
            yield return new ValidationResult(
                UserTexts.EmailValidation,
                new[] { nameof(Value) }
            );
        }
    }
}

此DTO在我的DetailDTO中使用,如此

public ICollection<EmailBaseDTO> Emails { get; set; } = new List<EmailBaseDTO>();

在图像上,您可以看到验证错误被正确触发并且提交被中断。

enter image description here

0 个答案:

没有答案
相关问题