Permalink
Browse files

Fixed validation of SQS message size (Closes #32)

  • Loading branch information...
amrhassan committed Jun 20, 2018
1 parent bc608cf commit 3192c64b4adf511d13c11fa2793f1e4a713f3d46
@@ -10,6 +10,12 @@ private[aws4s] object ParamValidator {
def sizeInRangeInclusive[A: Sized](min: Int, max: Int): Param.Validator[A] =
v => if (v.size < min || v.size > max) Some(s"value size not in [$min,$max]") else None
def byteSizeInRangeInclusive(min: Int, max: Int): Param.Validator[String] =
v => {
val bytes = v.getBytes
if (bytes.size < min || bytes.size > max) Some(s"value byte size not in [$min,$max]") else None
}
def inRangeInclusive[A: PartialOrder](min: A, max: A): Param.Validator[A] =
v => if (v < min || v > max) Some(s"value not in [$min,$max]") else None
@@ -6,5 +6,5 @@ import org.aws4s.core.ParamValidator
case class MessageBody(raw: String)
extends SqsParam[String](
"MessageBody",
ParamValidator.sizeInRangeInclusive(0, 256)
ParamValidator.byteSizeInRangeInclusive(1, 262144 /* 256 KiB */)
)

0 comments on commit 3192c64

Please sign in to comment.