喷雾验证的身份/零

identity / zero for spray validations

我想 fold 喷雾验证。

但我不知道如何为 Directive 获取 neutral elementidentity

我想做的是

      def validateMap(data: Map[KeyType, Int]): Directive0 =
        data foldLeft (Directive.identity) { case (acc, (key,limit)) => 
        acc & validate(limit <= 10 && limit >= 0 , s"limit for $key has to be in range of 0..10")
    }

Spray 中是否为指令定义了 identity/neutral 元素? 我怎样才能得到它?

"pass" 是身份指令:

How can I get it ?

spray docs 不错,不过一般看源码更有效。您可以使用如下所示的 grep 在 spray checkout:

中找到它
$ grep --include='*.scala' -i Directive -R * | egrep -i 'noop|empty|identity'
spray-routing/src/main/scala/spray/routing/directives/BasicDirectives.scala:  def noop: Directive0 = Directive.Empty