Blocks Validation

Vote:
 

Hi all,

 

I need to make custom validation on content area in block.

I`ve used befor custom validation by creating a class which inherits from ValidationAttribute.

What I need to do is to pass Value1 property vale that exists in the same model into validator:

[Display(
Name = "Value1",
GroupName = SystemTabNames.Content,
Order = 1)]
[Required]
public virtual string Value1 { get; set; }

[Display(
Name = "Value2",
GroupName = SystemTabNames.Content,
Order = 2)]
[MyValidator(Value = Value1)]
public virtual string Value2 { get; set; }

 

Thanks,

Dan

#71741
May 28, 2013 10:12
Vote:
 

Can you change your logic to an implementation using a validator class that inplements IValidate<YourBlockType> and the Validate method? That way it would be very easy to compare the values from Value1 with Value2.

Also, you might want to check out the System.Web.Mvc.CompareAttribute and decorate your model’s Value2 property with that one.

#71792
May 29, 2013 11:28
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.