From c741f6b3b771d7e08c6936f9f54539735a71aa78 Mon Sep 17 00:00:00 2001 From: Nabil Abdel-Hafeez <7283535+987Nabil@users.noreply.github.com> Date: Tue, 3 Sep 2024 02:43:32 +0200 Subject: [PATCH] Type safe method to add validation to a Schema (#716) (#734) --- 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 228e61d20..59a0f617f 100644 --- a/zio-schema/shared/src/main/scala/zio/schema/Schema.scala +++ b/zio-schema/shared/src/main/scala/zio/schema/Schema.scala @@ -156,6 +156,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.