PureConfig v0.6.0 Release Notes
Release Date: 2017-02-14 // about 7 years ago-
🆕 New features
- New
ProductHint
trait allowing customization of the derivedConfigConvert
for case classes, superseedingConfigFieldMapping
(docs). In addition to defining field name mappings,ProductHint
instances control: - Whether default field values should be used when fields are missing in the config (docs);
- Whether unknown keys are ignored or cause pureconfig to return a
Failure
(docs). - Support for reading and writing
java.util.UUID
s; - Support for reading and writing
java.nio.file.Path
s; - Support for reading and writing
java.net.URI
s; - Support multiple failures, e.g. when multiple fields of a class fail to convert;
- Add
ConfigReaderFailure
ADT to model failures andConfigReaderFailures
to represent a non empty list of errors; - Add
ConfigValueLocation
, which is the physical location of a ConfigValue represented by a file name and a line number; - Add
loadConfigOrThrow
methods to the API; - Add helpers to create
ConfigConvert
: ConfigConvert.fromStringConvert
that requires a functionString => Either[ConfigReaderFailure, T]
ConfigConvert.fromStringConvertTry
that requires a functionString => Try[T]
ConfigConvert.fromStringConvertOpt
that requires a functionString => Option[T]
- Add
ConfigConvert.catchReadError
to convert a function that can throw exception into a safe function that returns aEither[CannotConvert, T]
;
- New
💥 Breaking changes
ConfigConvert.from
now returns a value of typeEither[ConfigReaderFailures, T]
instead ofTry[T]
;CoproductHint
has been changed to adapt to the newConfigConvert
:CoproductHint.from
now returns a value of typeEither[ConfigReaderFailures, Option[ConfigValue]]
CoproductHint.to
now returns a value of typeEither[ConfigReaderFailures, Option[ConfigValue]]
- The default field mapping changed from camel case config keys (e.g.
exampleKey
) to kebab case keys (e.g.example-key
). Case class fields are still expected to be camel case. The old behavior can be retained by putting in scope animplicit def productHint[T] = ProductHint[T](ConfigFieldMapping(CamelCase, CamelCase))
; ConfigFieldMapping
has no type parameters now;ConfigFieldMapping
was replaced byProductHint
as the type of object to put in scope in order to customize the derivation ofConfigConvert
for case class. OldConfigFieldMapping
implicit instances in scope have no effect now. The migration can be done by replacing code likeimplicit def mapping: ConfigFieldMapping[T] = <mapping>
withimplicit def productHint: ProductHint[T] = ProductHint(<mapping>)
;ConfigConvert.fromString
,ConfigConvert.fromNonEmptyString
,ConfigConvert.vstringConvert
,ConfigConvert.nonEmptyStringConvert
are now deprecated and the new helpers should be used instead.