Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validação de ano com restrições redundantes #29

Merged
merged 3 commits into from Mar 14, 2016
Merged

Validação de ano com restrições redundantes #29

merged 3 commits into from Mar 14, 2016

Conversation

felipeuntill
Copy link
Contributor

Basicamente a antiga validação verificava se o length do ano informado era inferior a 2 ou superior a 4 ou seja isso restringia o length data especificada em 2,3,4, vide bloco abaixo:

if (yearLength < 2 && yearLength > 4)

Considerando que qualquer ano com data inferior a 1000 e superior a 3000 vai retornar false por causa da validação abaixo:

return !(y < 1000 || y >= 3000);

Os seguintes exemplos de parâmetros inválidos passariam por todo o processamento do método até serem restringidos na última validação:

"10", length = 2 // Qualquer outro número com length 2 também apresentaria o mesmo problema
"200", length = 3 // Qualquer outro número com length 3 também apresentaria o mesmo problema

Teríamos o custo de dar cast nos dados e proceder com as demais validações porque a primeira não está restringindo os dados em conjunto com as demais validações.

@cacontinuos
Copy link
Collaborator

By analyzing the blame information on this pull request, we identified @fernahh to be a potential reviewer

@cacontinuos
Copy link
Collaborator

You changed source files, but no tests were changed.

It might be OK if this is a refactory and no behavior has changed,
otherwise, please add a test to guarantee that your code works.

fernahh added a commit that referenced this pull request Mar 14, 2016
Validação de ano com restrições redundantes
@fernahh fernahh merged commit 5a91e52 into ContaAzul:master Mar 14, 2016
@fernahh
Copy link
Contributor

fernahh commented Mar 14, 2016

Valeu @felipeuntill! 🍻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants