OnTopicCMS / OnTopic-Editor-AspNetCore

ASP.NET Core version of an editor for Ignia's OnTopic CMS.
4 stars 0 forks source link

`TextAttribute`: Limit `MaxLength` to 255 if `IsIndexedAttribute` #32

Closed JeremyCaney closed 3 years ago

JeremyCaney commented 3 years ago

If an AttributeDescriptor is set to IsIndexedAttribute, then the MaxLength should be implicitly set to 255, if the MaxLength isn't otherwise set. This will ensure that data isn't truncated when saved to the database—or that the page won't generate an error due to the data exceeding the database definition. (This behavior may vary by the database used.)

JeremyCaney commented 3 years ago

This should also be applied to e.g., the TextArea attribute type, and the FilePath attribute type. While the TextArea will often be used with IsExtendedAttribute, it certainly isn’t limited to it. E.g., the MetaDescription is a two row TextArea, but restricted to fewer than 250 characters.

JeremyCaney commented 3 years ago

Added the IsExtendedAttribute property to the AttributeDescriptorViewModel (ad70a05), and used it to to implicitly set the maxlength on text and textarea inputs, assuming the MaximumLength property isn't set (2c88e7e).