6 changed files with 122 additions and 1 deletions
@ -0,0 +1,15 @@ |
|||||
|
package com.xsn.explorer.errors |
||||
|
|
||||
|
import com.alexitc.playsonify.models.{FieldValidationError, NotFoundError, PublicError} |
||||
|
import play.api.i18n.{Lang, MessagesApi} |
||||
|
|
||||
|
trait MasternodeError |
||||
|
|
||||
|
case object MasternodeNotFoundError extends MasternodeError with NotFoundError { |
||||
|
|
||||
|
override def toPublicErrorList(messagesApi: MessagesApi)(implicit lang: Lang): List[PublicError] = { |
||||
|
val message = messagesApi("error.masternode.notFound") |
||||
|
val error = FieldValidationError("ip", message) |
||||
|
List(error) |
||||
|
} |
||||
|
} |
@ -0,0 +1,17 @@ |
|||||
|
package com.xsn.explorer.models |
||||
|
|
||||
|
import com.alexitc.playsonify.models.WrappedString |
||||
|
|
||||
|
class IPAddress (val string: String) extends WrappedString |
||||
|
|
||||
|
object IPAddress { |
||||
|
private val pattern = "^(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})$".r.pattern |
||||
|
|
||||
|
def from(string: String): Option[IPAddress] = { |
||||
|
if (pattern.matcher(string).matches()) { |
||||
|
Some(new IPAddress(string)) |
||||
|
} else { |
||||
|
None |
||||
|
} |
||||
|
} |
||||
|
} |
Loading…
Reference in new issue