-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvalidators.py
More file actions
60 lines (48 loc) · 1.39 KB
/
validators.py
File metadata and controls
60 lines (48 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
def valida_director(nome_completo):
if len(nome_completo) == 0:
return False
return True
def valida_gender(nome):
if len(nome) == 0:
return False
return True
def valida_movie(titulo, ano, classificacao, preco, diretores_id, generos_id):
if len(titulo) == 0:
return False
if len(ano) != 4 and 1895 > ano > 2021:
return False
if 18 < classificacao < 0:
return False
if preco == 0:
return False
if diretores_id < 1:
return False
if generos_id < 1:
return False
return True
def valida_user(nome_completo, CPF):
if len(nome_completo) == 0:
return False
if len(CPF) != 14:
return False
return True
def valida_location(data_inicio, data_fim, filmes_id, usuarios_id):
if filmes_id < 1:
return False
if usuarios_id < 1:
return False
if data_fim < data_inicio:
return False
return True
def valida_payment(tipo, status, codigo_pagamento, valor, locacoes_id):
if len(tipo) == 0 and tipo != "debito" and tipo != "credito" and tipo != "paypal":
return False
if len(status) == 0 and status != "aprovado" and status != "em analise" and status != "reprovado":
return False
if len(codigo_pagamento) == 0:
return False
if valor < 2.0:
return False
if locacoes_id < 1:
return False
return True