Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
AI OnAI Off
Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
Please write a bit more, are those properties part of block that is then used on a page? Or part of List<T> property?
Ideally please share the code for all models used.
Hi,
I have a specialized property in episerver named LocationInformation with a below given structure:
public virtual string Name{ get; set; }
public virtual string City { get; set; }
[RegularExpression("^(\\+\\s?)?((?<!\\+.*)\\(\\+?\\d+([\\s\\-\\.]?\\d+)?\\)|\\d+)([\\s\\-\\.]?(\\(\\d+([\\s\\-\\.]?\\d+)?\\)|\\d+))*(\\s?(x|ext\\.?)\\s?\\d+)?$", ErrorMessage = "Invalid Phone Number")]
public virtual string PhoneNumber { get; set; }
The phone property is not a required one & the given regex handles it fine. With the regex, validation kicks in the next instant.
Issue
Now when i create a custom attribute with the same regex in it ,the validation only kicks in when the page which includes this specialized location property is published.
Could some one shed some insights on why client validation kicks in with regex & not with custom attribute?
Additional details:
This specialized LocationInformation property is part of a block.Here is the code for the same:
public class ContactBlock : SiteBlockData { [Display(Name = "Locations", Description = "Locations", GroupName = SystemTabNames.Content, Order = 40)] [DistinctLocationInformation] [EditorDescriptor(EditorDescriptorType = typeof(CollectionEditorDescriptor<LocationInformation>))] public virtual IList<LocationInformation> LocationInformations { get; set; } }
This Contact block once configured is added on a standard page by the editor.
Note: [DistinctLocationInformation] is a custom attribute to check for any duplicate locations if any when you publish the contact block.
Regards.