From 416aaf146b4fb56465769fa9a99def4a6ea1553d Mon Sep 17 00:00:00 2001 From: Nabil Abdel-Hafeez <7283535+987Nabil@users.noreply.github.com> Date: Sat, 31 Aug 2024 00:46:17 +0200 Subject: [PATCH] Type safe method to add validation to a Schema (#716) --- zio-schema/shared/src/main/scala/zio/schema/Schema.scala | 2 ++ 1 file changed, 2 insertions(+) diff --git a/zio-schema/shared/src/main/scala/zio/schema/Schema.scala b/zio-schema/shared/src/main/scala/zio/schema/Schema.scala index 6b722ce8e..a548dad08 100644 --- a/zio-schema/shared/src/main/scala/zio/schema/Schema.scala +++ b/zio-schema/shared/src/main/scala/zio/schema/Schema.scala @@ -151,6 +151,8 @@ sealed trait Schema[A] { def validate(value: A)(implicit schema: Schema[A]): Chunk[ValidationError] = Schema.validate[A](value) + def validation(validation: Validation[A]): Schema[A] = annotate(zio.schema.annotation.validate(validation)) + /** * Returns a new schema that combines this schema and the specified schema together, modeling * their tuple composition.