smithy.api.Length.scala Maven / Gradle / Ivy
package smithy.api
import smithy4s.Hints
import smithy4s.Schema
import smithy4s.ShapeId
import smithy4s.ShapeTag
import smithy4s.schema.Schema.long
import smithy4s.schema.Schema.recursive
import smithy4s.schema.Schema.struct
/** Constrains a shape to minimum and maximum number of elements or size.
* @param min
* Integer value that represents the minimum inclusive length of a shape.
* @param max
* Integer value that represents the maximum inclusive length of a shape.
*/
final case class Length(min: Option[Long] = None, max: Option[Long] = None)
object Length extends ShapeTag.Companion[Length] {
val id: ShapeId = ShapeId("smithy.api", "length")
val hints: Hints = Hints(
smithy.api.Documentation("Constrains a shape to minimum and maximum number of elements or size."),
smithy.api.Trait(selector = Some(":test(list, map, string, blob, member > :is(list, map, string, blob))"), structurallyExclusive = None, conflicts = None, breakingChanges = None),
).lazily
// constructor using the original order from the spec
private def make(min: Option[Long], max: Option[Long]): Length = Length(min, max)
implicit val schema: Schema[Length] = recursive(struct(
long.optional[Length]("min", _.min).addHints(smithy.api.Documentation("Integer value that represents the minimum inclusive length of a shape.")),
long.optional[Length]("max", _.max).addHints(smithy.api.Documentation("Integer value that represents the maximum inclusive length of a shape.")),
)(make).withId(id).addHints(hints))
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy