from marshmallow import Schema, fields, validate, EXCLUDE class CreateCustomerSchema(Schema): """Validation schema for creating a new customer""" class Meta: unknown = EXCLUDE customer_last_name = fields.Str( required=True, validate=validate.Length(min=1, max=250), error_messages={"required": "Last name is required"} ) customer_first_name = fields.Str( required=True, validate=validate.Length(min=1, max=250), error_messages={"required": "First name is required"} ) customer_town = fields.Str( required=True, validate=validate.Length(min=1, max=140), error_messages={"required": "Town is required"} ) customer_state = fields.Int( required=True, validate=validate.Range(min=0, max=50), error_messages={"required": "State is required"} ) customer_zip = fields.Str( required=True, validate=validate.Length(min=5, max=10), error_messages={"required": "Zip code is required"} ) customer_email = fields.Email( allow_none=True, load_default=None ) customer_home_type = fields.Int( required=True, validate=validate.Range(min=0, max=10), error_messages={"required": "Home type is required"} ) customer_phone_number = fields.Str( allow_none=True, validate=validate.Length(max=25), load_default=None ) customer_address = fields.Str( required=True, validate=validate.Length(min=1, max=1000), error_messages={"required": "Address is required"} ) customer_apt = fields.Str( allow_none=True, validate=validate.Length(max=140), load_default=None ) customer_description = fields.Str( allow_none=True, validate=validate.Length(max=2000), load_default=None ) class UpdateCustomerSchema(Schema): """Validation schema for updating an existing customer""" class Meta: unknown = EXCLUDE customer_last_name = fields.Str( validate=validate.Length(min=1, max=250) ) customer_first_name = fields.Str( validate=validate.Length(min=1, max=250) ) customer_town = fields.Str( validate=validate.Length(min=1, max=140) ) customer_state = fields.Int( validate=validate.Range(min=0, max=50) ) customer_zip = fields.Str( validate=validate.Length(min=5, max=10) ) customer_email = fields.Email( allow_none=True ) customer_home_type = fields.Int( validate=validate.Range(min=0, max=10) ) customer_phone_number = fields.Str( allow_none=True, validate=validate.Length(max=25) ) customer_address = fields.Str( validate=validate.Length(min=1, max=1000) ) customer_apt = fields.Str( allow_none=True, validate=validate.Length(max=140) ) customer_automatic = fields.Int( validate=validate.Range(min=0, max=10) ) customer_description = fields.Str( allow_none=True, validate=validate.Length(max=2000) ) customer_fill_location = fields.Int( allow_none=True, validate=validate.Range(min=0, max=10) ) class UpdateDescriptionSchema(Schema): """Validation schema for updating customer description""" class Meta: unknown = EXCLUDE description = fields.Str( allow_none=True, validate=validate.Length(max=2000) ) fill_location = fields.Int( allow_none=True )