aops-vulcanus/0001-add-paging-parameter-schema.patch
2023-07-04 16:24:36 +08:00

42 lines
1.4 KiB
Diff

From db18901aae967d1bf6b26a751d25a8f63eba7c2d Mon Sep 17 00:00:00 2001
From: rabbitali <shusheng.wen@outlook.com>
Date: Wed, 7 Jun 2023 16:35:22 +0800
Subject: [PATCH] add paging parameter schema
---
vulcanus/restful/serialize/validate.py | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/vulcanus/restful/serialize/validate.py b/vulcanus/restful/serialize/validate.py
index 1c00804..0e5c6ea 100644
--- a/vulcanus/restful/serialize/validate.py
+++ b/vulcanus/restful/serialize/validate.py
@@ -16,7 +16,8 @@ Author:
Description:
"""
import re
-from marshmallow import ValidationError
+
+from marshmallow import Schema, ValidationError, fields
def validate(verifier, data, load=False):
@@ -72,4 +73,12 @@ class ValidateRules:
validation rules for password, which only contains string or number
"""
if not re.findall("[a-zA-Z0-9]{6,20}", string):
- raise ValidationError("password should only contains string or number, between 6 and 20 characters!!")
\ No newline at end of file
+ raise ValidationError("password should only contains string or number, between 6 and 20 characters!!")
+
+
+class PaginationSchema(Schema):
+ """
+ filter schema of paging parameter
+ """
+ page = fields.Integer(required=False, validate=lambda s: 10**6 > s > 0)
+ per_page = fields.Integer(required=False, validate=lambda s: 10**3 > s > 0)
--
Gitee