You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Instead of creating a Check with specific logic for the splitEmail, why not leverage the existing containsOnce predicate and also the map method that the reader has taken time to implement in this exercise?
Also there is no need to convert to an intermediate Tuple...
val splitEmail: Check[Errors, String, Array[String]] = Check(containsOnce('@')) map (_.split('@'))
val checkLeft: Check[Errors, String, String] =
Check(longerThan(0))
val checkRight: Check[Errors, String, String] =
Check(longerThan(3) and contains('.'))
val joinEmail: Check[Errors, Array[String], String] =
Check { case Array(l, r) => (checkLeft(l), checkRight(r)).mapN(_ + "@" + _) }
val checkEmail: Check[Errors, String, String] =
splitEmail andThen joinEmail
The text was updated successfully, but these errors were encountered:
Instead of creating a Check with specific logic for the splitEmail, why not leverage the existing
containsOnce
predicate and also themap
method that the reader has taken time to implement in this exercise?Also there is no need to convert to an intermediate Tuple...
The text was updated successfully, but these errors were encountered: