本文整理匯總了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?')