ywana-core8 0.1.15 → 0.1.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ywana-core8",
3
- "version": "0.1.15",
3
+ "version": "0.1.16",
4
4
  "description": "ywana-core8",
5
5
  "homepage": "https://ywana.github.io/workspace",
6
6
  "author": "Ernesto Roldan Garcia",
@@ -13,18 +13,20 @@ export const ResetPasswordBox = ({ logo, title, userRequired = true, oldPwdRequi
13
13
  const [error, setError] = useState()
14
14
 
15
15
  useEffect(() => {
16
- setIsValid(validate())
16
+ const [valid, error] = validate()
17
+ setIsValid(valid)
18
+ setError(error)
17
19
  }, [form.password1, form.password2, form.oldPassword])
18
20
 
19
21
  function validate() {
20
22
  const hasRequiredUser = userRequired ? form.user && form.user.length > 0 : true
21
23
  const hasRequiredOldPwd = oldPwdRequired ? form.oldPassword && form.oldPassword.length > 0 : true
22
24
  const hasPassword1 = form.password1 && form.password1.length > 0
23
- const [isValid, error] = hasPassword1 ? validatePassword(form.password1) : [false, "La contraseña es requerida."]
24
- setError(error)
25
+ let [isValid, error] = hasPassword1 ? validatePassword(form.password1) : [false, "La contraseña es requerida."]
26
+
25
27
  const areEqual = form.password1 === form.password2
26
- if (isValid && !areEqual) setError("Las contraseñas no coinciden.")
27
- return hasRequiredUser && hasRequiredOldPwd && areEqual && isValid
28
+ if (isValid && !areEqual) error = "Las contraseñas no coinciden."
29
+ return [hasRequiredUser && hasRequiredOldPwd && areEqual && isValid, error]
28
30
  }
29
31
 
30
32
  function changeField(id, value) {