com.github.vickumar1981.svalidate
A Validatable[A] extends ValidatableResult[A][String] and using it defaults the ValidationDsl to use a String return type. This can be changed by implementing ValidatableResult[A][B] directly where B is return type instead.
object TestValidation { case class Address(street: String, city: String, state: String, zipCode: String) implicit object AddressValidator extends Validatable[Address] { override def validate(value: Address): Validation = { (value.street.nonEmpty orElse "Street addr. is required") ++ (value.city.nonEmpty orElse "City is required") ++ (value.zipCode.matches("\\d{5}") orElse "Zip code must be 5 digits") ++ (value.state.matches("[A-Z]{2}") orElse "State abbr must be 2 letters") } } }
the class to validate
Override this class to validate type A using a ValidationResult[B]
A Validatable[A] extends ValidatableResult[A][String] and using it defaults the ValidationDsl to use a String return type. This can be changed by implementing ValidatableResult[A][B] directly where B is return type instead.
the class to validate