This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package fpmax | |
import scala.util.Try | |
import scala.io.StdIn.readLine | |
object App0 { | |
def main: Unit = { | |
println("What is your name?") | |
val name = readLine() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ca.yk.gov.cfs.fm.common | |
object validators { | |
import rules._ | |
val centreCodeRule: RuleOp[String] = nonEmpty && maxLength(10) | |
val accountCodeOp: ValidatorOp[String] = define("ACCOUNT_CODE", nonEmpty && maxLength(22)) | |
val billingCentreCodeOp: ValidatorOp[String] = define("BILLING_CODE", centreCodeRule || startsWith("B")) | |
val orderNumberPrefixOp: ValidatorOp[String] = define("ORDER_NUMBER_PREFIX", (nonEmpty && maxLength(2)) || pattern("^[a-zA-Z]+$".r)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ca.yk.gov.cfs.fm.common | |
import scala.util.matching.Regex | |
object rules { | |
sealed trait ValidatorOp[A] | |
object ValidatorOp { | |
final case class Definition[A](fieldName: String, rules: RuleOp[A]) extends ValidatorOp[A] |