"""Trafaret schemas for data validation. The schemes are created for validation data before saving it into database. Only data coming from uploaded documents is validated. Calculated data is not included in validation schema. """ import trafaret as t PHF_RECORD_SCHEMA = t.Dict({ t.Key('original_track_id'): t.Int, t.Key('track_name'): t.String(max_length=255), t.Key('upc', optional=True): t.String(max_length=20, allow_blank=True), t.Key('isrc', optional=True): t.String(max_length=16, allow_blank=True), t.Key('track_artist'): t.String(max_length=100), t.Key('length_minute'): t.Int(lt=65535), t.Key('length_seconds'): t.Int(lt=65535), t.Key('label', optional=True): t.String(max_length=255, allow_blank=True), t.Key('public_domain', optional=True): t.String( max_length=10, allow_blank=True), t.Key('writer', optional=True): t.String(max_length=255, allow_blank=True), t.Key('release_date', optional=True): t.String( max_length=255, allow_blank=True), t.Key('release_title', optional=True): t.String( max_length=255, allow_blank=True), t.Key('release_artist', optional=True): t.String( max_length=255, allow_blank=True), t.Key('original_publishers', optional=True): t.Or( t.String(max_length=255, allow_blank=True), t.Atom(None)), t.Key('store'): t.String(max_length=30), t.Key('transaction_type', optional=True): t.String( max_length=10, allow_blank=True), t.Key('usage_type', optional=True): t.Or(t.Int(lt=65535), t.Atom(None)), t.Key('qty'): t.Int, t.Key('royalty_rate', optional=True): t.Or( t.Float, t.Atom(None), t.String('N/A')), t.Key('royalty', optional=True): t.Or( t.Float, t.Atom(None), t.String('N/A')), t.Key('gross_revenue', optional=True): t.Or(t.Float, t.Atom(None)), t.Key('net_revenue', optional=True): t.Or( t.Float, t.Atom(None), t.String('N/A')), t.Key('dist_fee', optional=True): t.Or( t.Float, t.Atom(None), t.String('N/A')), t.Key('admin_fee', optional=True): t.Or( t.Float, t.Atom(None), t.String('N/A')) }, allow_extra='*')