--- a/src/pyams_file/schema.py Mon Sep 11 13:26:57 2017 +0200
+++ b/src/pyams_file/schema.py Mon Sep 11 13:28:17 2017 +0200
@@ -18,7 +18,7 @@
from pyams_file.interfaces import IFile, IFileField, IMediaFile, IMediaField, IImage, IImageField, \
IThumbnailImageField, IVideo, IVideoField, IAudio, IAudioField, DELETED_FILE
from z3c.form.interfaces import NOT_CHANGED
-from zope.schema.interfaces import WrongType
+from zope.schema.interfaces import WrongType, RequiredMissing
# import packages
from zope.interface import implementer
@@ -32,7 +32,10 @@
schema = IFile
def _validate(self, value):
- if (value is DELETED_FILE) or (value is NOT_CHANGED):
+ if value is DELETED_FILE:
+ if self.required and not self.default:
+ raise RequiredMissing
+ elif value is NOT_CHANGED:
return
elif isinstance(value, tuple):
try: