Are you referring to this?
If so, based on it, this is what I did:
Added the following in file called policy.py in my.product/src/my/product/policy.py
"""Module where all interfaces, events and exceptions live."""
from ncdhhscontenttype.ncssinfo import _
from zope import schema
from zope.interface import Interface
from zope.publisher.interfaces.browser import IDefaultBrowserLayer
from plone.supermodel import model
from Acquisition import aq_inner
from plone import api
from Products.Five import BrowserView
from z3c.form import validator
from zope.interface import Invalid
class IMyProductLayer(IDefaultBrowserLayer):
"""Marker interface that defines a browser layer."""
class CustomValidator(validator.SimpleFieldValidator):
def validate(self, value):
super(CustomValidator, self).validate(value)
if value:
if ['Please choose one:']:
raise Invalid(u'Value is not valid')
In my schema model file, policy.xml file, I called it using the following:
<field name="choices" type="zope.schema.Choice" indexer:searchable="true"> <description/> <required>True</required> <title>Choices</title> <values> <element>Please choose one:</element> <element>Choice A</element> <element>Choice B</element> <element>Choice C</element> </values> <form:validator="my.product.policy.CustomValidator"> </field>
Error message:
SupermodelParseError: error parsing attribute name
It is referring to the line that has the form:validator statement in my policy.xml file. I am sure I am missing something. Any help would be most appreciated. Thank you.