Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
kciesielski committed Jun 19, 2024
1 parent 878dcfe commit 7651268
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,12 @@ trait TapirCodecIron extends DescriptionWitness with LowPriorityValidatorForPred
witness: ValueOf[NM]
): PrimitiveValidatorForPredicate[T, MaxLength[NM]] =
ValidatorForPredicate.fromPrimitiveValidator(Validator.maxLength[T](witness.value))

inline given validatorForMinLengthOnString[T <: String, NM <: Int](using
witness: ValueOf[NM]
): PrimitiveValidatorForPredicate[T, MinLength[NM]] =
ValidatorForPredicate.fromPrimitiveValidator(Validator.minLength[T](witness.value))

inline given validatorForMinLengthOnIterable[X, C[X] <: Iterable[X], NM <: Int](using
witness: ValueOf[NM]
): PrimitiveValidatorForPredicate[C[X], MinLength[NM]] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,12 @@ class TapirCodecIronTestScala3 extends AnyFlatSpec with Matchers {
"Generated schema for described Int with extra constrains" should "apply given constrains" in {
val schema = implicitly[Schema[Int :| (Positive DescribedAs "Age should be positive")]]

schema.validator should matchPattern {
case Validator.Mapped(Validator.Min(0, true), _) =>
schema.validator should matchPattern { case Validator.Mapped(Validator.Min(0, true), _) =>
}
}

"Generated schema for described String with extra constrains" should "apply given constrains" in {
type Constraint = (Not[Empty] & Alphanumeric) DescribedAs "name should not be empty and only made of alphanumeric characters"
type Constraint = (Not[Empty] & Alphanumeric) DescribedAs "name should not be empty and only made of alphanumeric characters"
type VariableString = String :| Constraint
val schema = implicitly[Schema[VariableString]]

Expand All @@ -99,13 +98,12 @@ class TapirCodecIronTestScala3 extends AnyFlatSpec with Matchers {
codec.decode("954") shouldBe a[DecodeResult.Value[_]]
codec.decode("spaces not allowed") shouldBe a[DecodeResult.InvalidValue]
}

"Generated schema for non empty string" should "use a MinLength validator" in {
type VariableString = String :| Not[Empty]
val schema = implicitly[Schema[VariableString]]

schema.validator should matchPattern {
case Validator.Mapped(Validator.MinLength(1, false), _) =>
schema.validator should matchPattern { case Validator.Mapped(Validator.MinLength(1, false), _) =>
}
}

Expand All @@ -117,7 +115,6 @@ class TapirCodecIronTestScala3 extends AnyFlatSpec with Matchers {
case Validator.Mapped(Validator.All(List(Validator.MinLength(33, false), Validator.MaxLength(83, false))), _) =>
}
}


"Generated codec for Less" should "use tapir Validator.max" in {
type IntConstraint = Less[3]
Expand Down

0 comments on commit 7651268

Please sign in to comment.