google-listings-and-ads
google-listings-and-ads copied to clipboard
Validate product attributes input on edit product page
The product attributes entered by the user on the edit product page are not validated. A simple validation is done when the product is being synced to Google but we should do a validation on any user input too before saving the data in DB.
We decided to keep the validation simple and let Google handle it, so there's no need to do complex validations. For example, for the GTIN attribute, we do not need to set up a set of rules to check its correctness, simply checking if it has the right format (correct length, numeral) should be enough.
It's also going to be helpful to add validation for less obvious rules. For example the availability date in the Google docs mentions that it can only be 1 year in the future:
Required if you set the availability [availability] attribute to preorder or backorder. (You can then provide the date (up to 1 year in the future) when your product will be shipped using the availability date [availability_date] attribute).
This also implies that the date must be in the future.