class TitleSchema(Schema): """Schema for the additional title.""" title = SanitizedUnicode(required=True, validate=validate.Length(min=3)) type = SanitizedUnicode() lang = ISOLangString() @validates_schema def validate_data(self, data, **kwargs): """Validate type.""" if data.get('type'): validate_entry('titles.type', data)
class DescriptionSchema(Schema): """Schema for the additional descriptions.""" DESCRIPTION_TYPES = [ "abstract", "methods", "seriesinformation", "tableofcontents", "technicalinfo", "other" ] description = SanitizedHTML(required=True, validate=validate.Length(min=3)) type = SanitizedUnicode( required=True, validate=validate.OneOf( choices=DESCRIPTION_TYPES, error=_( 'Invalid description type. {input} not one of {choices}.'))) lang = ISOLangString()
class MetadataSchema(Schema): """Schema for the record metadata.""" field_load_permissions = { # TODO: define "can_admin" action } field_dump_permissions = { # TODO: define "can_admin" action } class Meta: """Meta class to accept unknwon fields.""" unknown = INCLUDE # Metadata fields resource_type = fields.Nested(ResourceTypeSchema, required=True) creators = fields.List(fields.Nested(CreatorSchema), required=True) title = SanitizedUnicode(required=True, validate=validate.Length(min=3)) additional_titles = fields.List(fields.Nested(TitleSchema)) publisher = SanitizedUnicode() publication_date = EDTFDateString(required=True) subjects = fields.List(fields.Nested(SubjectSchema)) contributors = fields.List(fields.Nested(ContributorSchema)) dates = fields.List(fields.Nested(DateSchema)) languages = fields.List(ISOLangString()) # alternate identifiers identifiers = fields.List(fields.Nested(IdentifierSchema)) related_identifiers = fields.List( fields.Nested(RelatedIdentifierSchema), validate=_no_duplicates, error=_('Invalid related identifiers cannot contain duplicates.')) sizes = fields.List( SanitizedUnicode( validate=_not_blank(_('Size cannot be a blank string.')))) formats = fields.List( SanitizedUnicode( validate=_not_blank(_('Format cannot be a blank string.')))) version = SanitizedUnicode() rights = fields.List(fields.Nested(RightsSchema)) description = SanitizedUnicode(validate=validate.Length(min=3)) additional_descriptions = fields.List(fields.Nested(DescriptionSchema)) locations = fields.List(fields.Nested(LocationSchema)) funding = fields.List(fields.Nested(FundingSchema)) references = fields.List(fields.Nested(ReferenceSchema))
class MySchema(Schema): f = ISOLangString()