@@ -215,6 +215,7 @@ class JvmWatermarker : Watermarker() {
215215 * When [fileType] is null the type is taken from [source]'s extension.
216216 * When [squash] is true: watermarks with the same content are merged.
217217 * When [singleWatermark] is true: only the most frequent watermark is returned.
218+ * When [validateAll] is true: All resulting Trendmarks are validated to check for errors.
218219 *
219220 * Returns a warning if some watermarks could not be converted to Trendmarks.
220221 * Returns an error if no watermark could be converted to a Trendmark.
@@ -224,8 +225,18 @@ class JvmWatermarker : Watermarker() {
224225 fileType : String? = null,
225226 squash : Boolean = true,
226227 singleWatermark : Boolean = true,
228+ validateAll : Boolean = true,
227229 ): Result <List <Trendmark >> {
228- return getWatermarks(source, fileType, squash, singleWatermark).toTrendmarks(SOURCE )
230+ val result = getWatermarks(source, fileType, squash, singleWatermark).toTrendmarks(SOURCE )
231+
232+ if (validateAll && result.hasValue && result.value!! .isNotEmpty()) {
233+ for (trendmark in result.value) {
234+ val validationStatus = trendmark.validate()
235+ result.appendStatus(validationStatus)
236+ }
237+ }
238+
239+ return result
229240 }
230241
231242 /* *
@@ -260,6 +271,7 @@ class JvmWatermarker : Watermarker() {
260271 /* *
261272 * Removes all watermarks in [source] and returns them.
262273 *
274+ * When [singleWatermark] is true: only the most frequent watermark is returned.
263275 * When [fileType] is null the type is taken from [source]'s extension.
264276 */
265277 fun removeWatermarks (
0 commit comments