Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

4
  • It's going to be a textarea for the user to add additional information. I'm going to limit the char length and would like to make sure they're not adding any JS or other code. What other rule from rules.js would you recommend I use for the frontend? Also, before saving the data in the DB, should I utilise the validation mehtods in \Magento\Eav\Model\Attribute\Data\AbstractData? Thank you! Commented Nov 16, 2017 at 16:36
  • Also, great presentation! Commented Nov 16, 2017 at 16:46
  • 1
    Hi @MikeMason, if it's a text field, maybe a alphanumeric check could make sense but that maybe will not allow enough. If you want to apply additional filters, have a look at the Zend\Validator classes, for example Zend\Validator\StringLength, see here: framework.zend.com/manual/2.1/en/modules/… Commented Nov 17, 2017 at 5:58
  • Many thanks for your suggestions. I had a look at the Zend Validator; looks interesting. To see how this has been implemented by Magento2, I had search through the code for examples, but I didn't seem to find it being used anywhere. Does M2 not use the Zend Validator for it's own input validation? Commented Nov 17, 2017 at 9:45