Skip to content

Commit

Permalink
implicit class to handle validations akka#3253
Browse files Browse the repository at this point in the history
  • Loading branch information
sfali committed Aug 25, 2024
1 parent 6cc3254 commit d51c06a
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
package akka.stream.alpakka
package azure

import com.typesafe.config.Config

import java.time.{ZoneOffset, ZonedDateTime}
import java.time.format.DateTimeFormatter

Expand Down Expand Up @@ -41,4 +43,14 @@ package object storage {
* have XML elements with an empty text value inside.
*/
private[storage] def emptyStringToOption(value: String): Option[String] = if (value == "") None else Option(value)

implicit private[storage] class ConfigOps(src: Config) {

def getString(path: String, defaultValue: String): String = {
if (src.hasPath(path)) src.getString(path) else defaultValue
}

def getOptionalString(path: String): Option[String] =
if (src.hasPath(path)) emptyStringToOption(src.getString(path)) else None
}
}

0 comments on commit d51c06a

Please sign in to comment.