from marshmallow import Schema, fields
from marshmallow.validate import Range

REQUIRED_ERROR_MESSAGE = {"required": "Campo obrigatório"}


class CartItemLoadSchema(Schema):
    id_product = fields.Integer(required=True, error_messages=REQUIRED_ERROR_MESSAGE)
    quantity = fields.Integer(
        validate=Range(min=1, error="Quantidade mínima de produtos é 1"),
        required=True,
        error_messages=REQUIRED_ERROR_MESSAGE
    )


class CartItemDumpSchema(Schema):
    product = fields.String()
    sale = fields.String()
    value = fields.Decimal(places=2)
    quantity = fields.Integer()


class CartLoadSchema(Schema):
    products = fields.Nested(CartItemLoadSchema, many=True, required=True, error_messages=REQUIRED_ERROR_MESSAGE)

b0ef673178b165d60a6584919f7e2d147db47eef
<mask token>


class CartItemDumpSchema(Schema):
    product = fields.String()
    sale = fields.String()
    value = fields.Decimal(places=2)
    quantity = fields.Integer()


class CartLoadSchema(Schema):
    products = fields.Nested(CartItemLoadSchema, many=True, required=True,
        error_messages=REQUIRED_ERROR_MESSAGE)

<mask token>


class CartItemLoadSchema(Schema):
    <mask token>
    <mask token>


class CartItemDumpSchema(Schema):
    product = fields.String()
    sale = fields.String()
    value = fields.Decimal(places=2)
    quantity = fields.Integer()


class CartLoadSchema(Schema):
    products = fields.Nested(CartItemLoadSchema, many=True, required=True,
        error_messages=REQUIRED_ERROR_MESSAGE)

<mask token>


class CartItemLoadSchema(Schema):
    id_product = fields.Integer(required=True, error_messages=
        REQUIRED_ERROR_MESSAGE)
    quantity = fields.Integer(validate=Range(min=1, error=
        'Quantidade mínima de produtos é 1'), required=True, error_messages
        =REQUIRED_ERROR_MESSAGE)


class CartItemDumpSchema(Schema):
    product = fields.String()
    sale = fields.String()
    value = fields.Decimal(places=2)
    quantity = fields.Integer()


class CartLoadSchema(Schema):
    products = fields.Nested(CartItemLoadSchema, many=True, required=True,
        error_messages=REQUIRED_ERROR_MESSAGE)

<mask token>
REQUIRED_ERROR_MESSAGE = {'required': 'Campo obrigatório'}


class CartItemLoadSchema(Schema):
    id_product = fields.Integer(required=True, error_messages=
        REQUIRED_ERROR_MESSAGE)
    quantity = fields.Integer(validate=Range(min=1, error=
        'Quantidade mínima de produtos é 1'), required=True, error_messages
        =REQUIRED_ERROR_MESSAGE)


class CartItemDumpSchema(Schema):
    product = fields.String()
    sale = fields.String()
    value = fields.Decimal(places=2)
    quantity = fields.Integer()


class CartLoadSchema(Schema):
    products = fields.Nested(CartItemLoadSchema, many=True, required=True,
        error_messages=REQUIRED_ERROR_MESSAGE)

from marshmallow import Schema, fields
from marshmallow.validate import Range

REQUIRED_ERROR_MESSAGE = {"required": "Campo obrigatório"}


class CartItemLoadSchema(Schema):
    id_product = fields.Integer(required=True, error_messages=REQUIRED_ERROR_MESSAGE)
    quantity = fields.Integer(
        validate=Range(min=1, error="Quantidade mínima de produtos é 1"),
        required=True,
        error_messages=REQUIRED_ERROR_MESSAGE
    )


class CartItemDumpSchema(Schema):
    product = fields.String()
    sale = fields.String()
    value = fields.Decimal(places=2)
    quantity = fields.Integer()


class CartLoadSchema(Schema):
    products = fields.Nested(CartItemLoadSchema, many=True, required=True, error_messages=REQUIRED_ERROR_MESSAGE)
