We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enhance API be adding support for NonEmptyList and NonEmptyVector:
An example of code would be:
def nonEmptyList[A](key: String)(cpl: String => ConfigParser[List[A]]): ConfigParser[NonEmptyList[A]] = cpl(key) bind { case head :: tail => ConfigParser.pure(NonEmptyList(head, tail)) case Nil => ConfigParser(s"non-empty-list failure for $key") { _ => Left(ConfigErrors.of(ConfigError.WrongType(ConfigKey.Relative(key), "expected non-empty list", None))) } }
and
def nonEmptyVector[A](key: String)(cpv: String => ConfigParser[Vector[A]]): ConfigParser[NonEmptyVector[A]] = cpv(key) bind { case Vector() => ConfigParser(s"non-empty-vector failure for $key") { _ => Left(ConfigErrors.of(ConfigError.WrongType(ConfigKey.Relative(key), "expected non-empty vector", None))) } case v => ConfigParser.pure(NonEmptyVector(v.head, v.tail)) }
The text was updated successfully, but these errors were encountered:
This issue implies adding a dependency to cats.
Sorry, something went wrong.
jrudnick
No branches or pull requests
Enhance API be adding support for NonEmptyList and NonEmptyVector:
An example of code would be:
def nonEmptyList[A](key: String)(cpl: String => ConfigParser[List[A]]): ConfigParser[NonEmptyList[A]] = cpl(key) bind { case head :: tail => ConfigParser.pure(NonEmptyList(head, tail)) case Nil => ConfigParser(s"non-empty-list failure for $key") { _ => Left(ConfigErrors.of(ConfigError.WrongType(ConfigKey.Relative(key), "expected non-empty list", None))) } }
and
def nonEmptyVector[A](key: String)(cpv: String => ConfigParser[Vector[A]]): ConfigParser[NonEmptyVector[A]] = cpv(key) bind { case Vector() => ConfigParser(s"non-empty-vector failure for $key") { _ => Left(ConfigErrors.of(ConfigError.WrongType(ConfigKey.Relative(key), "expected non-empty vector", None))) } case v => ConfigParser.pure(NonEmptyVector(v.head, v.tail)) }
The text was updated successfully, but these errors were encountered: