from marshmallow.fields import DateTime, Integer, validate
from teal.marshmallow import SanitizedStr, URL
from ereuse_devicehub.resources.schemas import Thing
from ereuse_devicehub.resources.documents import models as m
# from marshmallow import ValidationError, validates_schema
class Document(Thing):
__doc__ = m.Document.__doc__
id = Integer(description=m.Document.id.comment, dump_only=True)
type = SanitizedStr(default='Document')
date = DateTime(data_key='endTime',
required=False,
description=m.Document.date.comment)
id_document = SanitizedStr(data_key='documentId',
default='',
description=m.Document.id_document.comment)
file_name = SanitizedStr(data_key='filename',
description=m.Document.file_name.comment,
validate=validate.Length(max=100))
file_hash = SanitizedStr(data_key='hash',
description=m.Document.file_hash.comment,
validate=validate.Length(max=64))
url = URL(description=m.Document.url.comment)