fix bug with RUT validation
This commit is contained in:
parent
ae40849c21
commit
84eb228a6c
@ -32,7 +32,7 @@ func is_valid_rut(rut: String) -> bool:
|
|||||||
print_debug("RUT is too large, that is a company!")
|
print_debug("RUT is too large, that is a company!")
|
||||||
return false
|
return false
|
||||||
|
|
||||||
if verifier != generate_verifier(rut):
|
if verifier != generate_verifier(rut_temp):
|
||||||
return false
|
return false
|
||||||
|
|
||||||
return true
|
return true
|
||||||
@ -51,13 +51,13 @@ func generate_verifier(rut: String) -> String:
|
|||||||
|
|
||||||
var i: int = rut_length - 1
|
var i: int = rut_length - 1
|
||||||
while i >= 0:
|
while i >= 0:
|
||||||
sum = sum + rut.substr(i, i + 1).to_int() * multiplier
|
sum = sum + rut.substr(i, 1).to_int() * multiplier
|
||||||
multiplier = multiplier + 1
|
multiplier = multiplier + 1
|
||||||
if multiplier == 8:
|
if multiplier == 8:
|
||||||
multiplier = 2
|
multiplier = 2
|
||||||
i = i - 1
|
i = i - 1
|
||||||
|
|
||||||
var tempSum: float = int(sum)
|
var tempSum: float = sum
|
||||||
division = int(floor(tempSum / 11))
|
division = int(floor(tempSum / 11))
|
||||||
division = division * 11
|
division = division * 11
|
||||||
remainder = sum - division
|
remainder = sum - division
|
||||||
@ -79,6 +79,7 @@ func is_valid_email(email: String) -> bool:
|
|||||||
return false
|
return false
|
||||||
return true
|
return true
|
||||||
|
|
||||||
|
|
||||||
func _on_Button_pressed() -> void:
|
func _on_Button_pressed() -> void:
|
||||||
var name = get_node("%Name")
|
var name = get_node("%Name")
|
||||||
var rut = get_node("%Rut")
|
var rut = get_node("%Rut")
|
||||||
|
Loading…
Reference in New Issue
Block a user