当前位置: 首页>>代码示例>>Python>>正文


Python fields.Email方法代码示例

本文整理汇总了Python中marshmallow.fields.Email方法的典型用法代码示例。如果您正苦于以下问题:Python fields.Email方法的具体用法?Python fields.Email怎么用?Python fields.Email使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在marshmallow.fields的用法示例。


在下文中一共展示了fields.Email方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create_app

# 需要导入模块: from marshmallow import fields [as 别名]
# 或者: from marshmallow.fields import Email [as 别名]
def create_app(self):
        app = Flask(__name__)
        Rebar().init_app(app=app)

        class NestedSchema(validation.RequestSchema):
            baz = fields.List(fields.Integer())

        class Schema(validation.RequestSchema):
            foo = fields.Integer(required=True)
            bar = fields.Email()
            nested = fields.Nested(NestedSchema)

        @app.route("/stuffs", methods=["POST"])
        def json_body_handler():
            data = get_json_body_params_or_400(schema=Schema)
            return response(data)

        return app 
开发者ID:plangrid,项目名称:flask-rebar,代码行数:20,代码来源:test_errors.py

示例2: __init__

# 需要导入模块: from marshmallow import fields [as 别名]
# 或者: from marshmallow.fields import Email [as 别名]
def __init__(self, allow_extra):
        class LocationSchema(Schema):
            latitude = fields.Float(allow_none=True)
            longitude = fields.Float(allow_none=True)

        class SkillSchema(Schema):
            subject = fields.Str(required=True)
            subject_id = fields.Integer(required=True)
            category = fields.Str(required=True)
            qual_level = fields.Str(required=True)
            qual_level_id = fields.Integer(required=True)
            qual_level_ranking = fields.Float(default=0)

        class Model(Schema):
            id = fields.Integer(required=True)
            client_name = fields.Str(validate=validate.Length(max=255), required=True)
            sort_index = fields.Float(required=True)
            # client_email = fields.Email()
            client_phone = fields.Str(validate=validate.Length(max=255), allow_none=True)

            location = fields.Nested(LocationSchema)

            contractor = fields.Integer(validate=validate.Range(min=0), allow_none=True)
            upstream_http_referrer = fields.Str(validate=validate.Length(max=1023), allow_none=True)
            grecaptcha_response = fields.Str(validate=validate.Length(min=20, max=1000), required=True)
            last_updated = fields.DateTime(allow_none=True)
            skills = fields.Nested(SkillSchema, many=True)

        self.allow_extra = allow_extra  # unused
        self.schema = Model() 
开发者ID:samuelcolvin,项目名称:pydantic,代码行数:32,代码来源:test_marshmallow.py

示例3: test_ma_field_to_reqparse_argument_single_values

# 需要导入模块: from marshmallow import fields [as 别名]
# 或者: from marshmallow.fields import Email [as 别名]
def test_ma_field_to_reqparse_argument_single_values():
    # Test a simple integer.
    result = utils.ma_field_to_reqparse_argument(ma.Integer(required=True))
    assert result["type"] is int
    assert result["required"] is True
    assert result["action"] == "store"
    assert "help" not in result

    # Test that complex fields default to string.
    result = utils.ma_field_to_reqparse_argument(ma.Email(required=True, description="A description"))
    assert result["type"] is str
    assert result["required"] is True
    assert result["action"] == "store"
    assert result["help"] == "A description" 
开发者ID:apryor6,项目名称:flask_accepts,代码行数:16,代码来源:utils_test.py

示例4: fuzzy_schema_deserialization_disambiguation

# 需要导入模块: from marshmallow import fields [as 别名]
# 或者: from marshmallow.fields import Email [as 别名]
def fuzzy_schema_deserialization_disambiguation(data, _):
    if isinstance(data, dict):
        return ShapeSchema
    if isinstance(data, str):
        return fields.Email

    raise TypeError('Could not detect type. '
                    'Are you sure this is a shape or an email?') 
开发者ID:Bachmann1234,项目名称:marshmallow-polyfield,代码行数:10,代码来源:shapes.py


注:本文中的marshmallow.fields.Email方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。