Skip to content

Commit b602db0

Browse files
committed
swapping old validation
1 parent ce9479e commit b602db0

File tree

4 files changed

+7
-9
lines changed

4 files changed

+7
-9
lines changed

app/controllers/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from pydantic import BaseModel, ValidationError, FilePath
1212

1313
from app import error_messages
14-
from pprint import pprint
1514

1615
# access control
1716
def resource(resource_name):
@@ -87,7 +86,6 @@ def wrapped(*args, **kwargs):
8786
try:
8887
validator.parse_raw(data)
8988
except ValidationError as e:
90-
pprint(e.errors())
9189
for error in e.errors():
9290
msg = error_messages.get(error['type'])
9391
ctx = error.get('ctx')

app/controllers/authController.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
jwt_refresh_token_required,
88
get_jwt_identity,
99
)
10+
from . import field_validator
1011
from sqlalchemy import or_
1112
from app import Usuario, fieldsFormatter, Perfil
1213
from app import AuthLoginSchema
@@ -17,7 +18,7 @@
1718

1819

1920
@app.route("/auth", methods=["POST"])
20-
@validate(body=AuthLoginSchema)
21+
@field_validator(AuthLoginSchema)
2122
def login():
2223
data = request.get_json()
2324

app/controllers/perfilController.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from flask import request, jsonify
33
from flask_jwt_extended import jwt_required, get_jwt_identity
44
from sqlalchemy import exc, or_
5-
from . import resource, paginate
5+
from . import resource, paginate, field_validator
66
from app import Perfil, Usuario
77
from app import fieldsFormatter
88

@@ -86,7 +86,7 @@ def perfilView(perfil_id):
8686
@app.route("/perfil/add", methods=["POST"])
8787
@jwt_required
8888
@resource("perfil-add")
89-
@validate(body=PerfilAddSchema)
89+
@field_validator(PerfilAddSchema)
9090
def perfilAdd():
9191

9292
data = request.get_json()
@@ -134,7 +134,7 @@ def perfilAdd():
134134
@app.route("/perfil/edit/<perfil_id>", methods=["PUT"])
135135
@jwt_required
136136
@resource("perfil-edit")
137-
@validate(body=PerfilAddSchema)
137+
@field_validator(PerfilAddSchema)
138138
def perfilEdit(perfil_id):
139139
data = request.get_json()
140140

app/controllers/usuarioController.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def usuarioView(usuario_id):
8080
@app.route("/usuario/add", methods=["POST"])
8181
@jwt_required
8282
@resource("usuario-add")
83-
@validate(body=UsuarioAddSchema)
83+
@field_validator(UsuarioAddSchema)
8484
def usuarioAdd():
8585
data = request.get_json()
8686

@@ -129,7 +129,7 @@ def usuarioAdd():
129129
@app.route("/usuario/edit/<usuario_id>", methods=["PUT"])
130130
@jwt_required
131131
@resource("usuario-edit")
132-
@validate(body=UsuarioEditSchema)
132+
@field_validator(UsuarioEditSchema)
133133
def usuarioEdit(usuario_id):
134134
data = request.get_json()
135135

@@ -232,7 +232,6 @@ def usuarioDelete(usuario_id):
232232
# --------------------------------------------------------------------------------------------------#
233233

234234
@app.route("/usuario/cadastro", methods=["POST"])
235-
#@validate(body=CadastroAddSchema)
236235
@field_validator(CadastroAddSchema)
237236
def cadastroAdd():
238237
data = request.get_json()

0 commit comments

Comments
 (0)