@@ -164,6 +164,22 @@ class ConfigYamlLoaderImpl extends ConfigYamlLoader {
164
164
case None => Validated .valid(None )
165
165
}
166
166
167
+ private def parseOptionalBoolean (
168
+ fields : Map [String , Json ],
169
+ fieldName : String
170
+ ): ValidatedNel [String , Option [Boolean ]] =
171
+ fields.get(fieldName) match {
172
+ case Some (jsonValue) =>
173
+ jsonValue
174
+ .as[Boolean ]
175
+ .leftMap(_ =>
176
+ s " Invalid ' $fieldName' field format, should be a boolean "
177
+ )
178
+ .toValidatedNel
179
+ .map(Some (_))
180
+ case None => Validated .valid(None )
181
+ }
182
+
167
183
private def parseFeed (feedJson : Json ): ValidatedNel [String , Feed ] =
168
184
feedJson.asObject.map(_.toMap) match {
169
185
case None => Validated .invalidNel(" Feed entry is not a valid JSON object" )
@@ -177,7 +193,7 @@ class ConfigYamlLoaderImpl extends ConfigYamlLoader {
177
193
parseOptionalString(feedFields, " inlineInput" )
178
194
val filterValidated = parseOptionalQueryAST(feedFields, " filter" )
179
195
val formatInValidated
180
- : Validated [NonEmptyList [String ], Option [FormatIn ]] =
196
+ : Validated [NonEmptyList [String ], Option [FormatIn ]] =
181
197
parseOptionalFormatIn(feedFields, " formatIn" )
182
198
val fieldNamesValidated =
183
199
parseOptionalFieldNames(feedFields, " fieldNames" )
@@ -190,6 +206,9 @@ class ConfigYamlLoaderImpl extends ConfigYamlLoader {
190
206
feedFields,
191
207
" excludeFields"
192
208
)
209
+ val showEmptyFieldsValidated =
210
+ parseOptionalBoolean(feedFields, " showEmptyFields" )
211
+
193
212
(
194
213
nameValidated,
195
214
commandsValidated,
@@ -199,7 +218,8 @@ class ConfigYamlLoaderImpl extends ConfigYamlLoader {
199
218
fieldNamesValidated,
200
219
rawIncludeValidated,
201
220
rawExcludeValidated,
202
- excludeFieldsValidated
221
+ excludeFieldsValidated,
222
+ showEmptyFieldsValidated
203
223
)
204
224
.mapN(Feed .apply)
205
225
}
@@ -223,7 +243,10 @@ class ConfigYamlLoaderImpl extends ConfigYamlLoader {
223
243
parseOptionalFeeds(fields, " feeds" )
224
244
val fieldNamesValidated =
225
245
parseOptionalFieldNames(fields, " fieldNames" )
226
- (fieldNamesValidated, feedsValidated).mapN(ConfigYaml .apply)
246
+ val showEmptyFieldsValidated =
247
+ parseOptionalBoolean(fields, " showEmptyFields" )
248
+
249
+ (fieldNamesValidated, feedsValidated, showEmptyFieldsValidated).mapN(ConfigYaml .apply)
227
250
}
228
251
}
229
252
}
0 commit comments