All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.twitter.finatra.validation.ValidationResult.scala Maven / Gradle / Ivy

package com.twitter.finatra.validation

sealed trait ValidationResult {
  def isValid: Boolean
}

object ValidationResult {
  case object Valid extends ValidationResult {
    override val isValid = true
  }
  
  case class Invalid(message: String, code: ErrorCode = ErrorCode.Unknown) extends ValidationResult {
    override val isValid = false
  }

  def apply(isValid: Boolean, message: => String, code: ErrorCode = ErrorCode.Unknown): ValidationResult = {
    if (isValid) Valid
    else Invalid(message, code)
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy