本文整理汇总了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
示例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()
示例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"
示例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?')