-
Notifications
You must be signed in to change notification settings - Fork 419
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove iron integration trait scope restriction (#4111)
- Loading branch information
Showing
3 changed files
with
39 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
integrations/iron/src/test/scala-3/com/example/RefinedString.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.example | ||
|
||
import io.github.iltotore.iron.* | ||
import sttp.tapir.Validator | ||
import sttp.tapir.codec.iron.PrimitiveValidatorForPredicate | ||
import sttp.tapir.codec.iron.ValidatorForPredicate | ||
|
||
final class RefinedStringConstraint | ||
|
||
object RefinedStringConstraint { | ||
|
||
given Constraint[String, RefinedStringConstraint] with { | ||
|
||
override inline def test(value: String): Boolean = value.nonEmpty | ||
|
||
override inline def message: String = "Should not be empty" | ||
} | ||
|
||
given PrimitiveValidatorForPredicate[String, RefinedStringConstraint] = | ||
ValidatorForPredicate.fromPrimitiveValidator(Validator.pattern[String]("^.+")) | ||
} | ||
|
||
opaque type RefinedString = String :| RefinedStringConstraint | ||
|
||
object RefinedString extends RefinedTypeOps[String, RefinedStringConstraint, RefinedString] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters