:pray: would anyone have any suggestion or where ...
# protobufs
a
🙏 would anyone have any suggestion or where can I see examples on how to build a protobuf matcher that checks that a property in the protobuf message is either of type UUID4 ..... or that it simply matches the regex 🙏 from my kotlin code below 👇 you can clearly see I don't know what to pass in and I don't want to serialize from JSON, but from protobuf or maybe I am doing it all wrong and can't be done like this as there isn't a direct equivalent to
<http://au.com|au.com>.dius.pact.consumer.dsl.DslPart
for protobuf.... so I wonder if Protobuf requires a different approach to what I am attempting here questionmario
Copy code
@Pact(consumer = "my-service")
    fun createPact(builder: PactBuilder): V4Pact {

        val messageFile = loadFileFromJarResource("/events/pub/a/v1/a_event.proto")

        return builder
            .usingPlugin("protobuf")
            .expectsToReceive("an AEvent ", "core/interaction/message")
            .with(
                mapOf(
                    "message.contents" to mapOf(
                        "pact:proto" to messageFile.path,
                        "pact:message-type" to "AlertEvent",
                        "pact:content-type" to "application/protobuf",
                        "pact:protobuf-config" to mapOf("additionalIncludes" to listOf("/Users/anna.nava/dev/protobuf/proto")),
                        "this_amazing_property" to mapOf(
                            //this compiles, but passes empty string: "id" to regex("^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$")
                            //this doesn't compile:"id" to matchRegex("^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$")
                            //this compiles, but ends up passing in an empty string:  "id" to regex("[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89aAbB][a-f0-9]{3}-[a-f0-9]{12}")
                            //"id" to mapOf("matchers" to mapOf("match" to "regex", "regex" to "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}\$" ))
                             "id" to regexp("^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$", "123e4567-e89b-12d3-a456-426614174000")

                        ),
(apologies if this is not the right channel for, very appreciated if anyone can redirect me where is best for me to ask this, thanks!)
r
I think the way it is meant to be done is something like:
Copy code
"this_amazing_property" to "matching(uuid, '123e4567-e89b-12d3-a456-426614174000')"
a
thanks! I appreciate that.... unfortunately it errors (my interpretation is uuid is only supported with JSON not protobuf)
Copy code
matching(uuid, '123e4567-e89b-12d3-a456-426614174000')
   │          ──┬─  
   │            ╰─── This is not a valid matcher type
   │ 
   │ Note: Valid matchers are: equalTo, regex, type, datetime, date, time, include, number, integer, decimal, boolean, contentType, semver
in case anyone has the same problem with uuid / regex... the only way I could get this to work was:
Copy code
"this_amazing_property" to "matching(regex, '^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}\$', '123e4567-e89b-12d3-a456-426614174222')"
actually not really 😞 the regex gets ignored 😞 it's like in this way I am only able to get the generator working.... but not really the matcher (it simply gets ignored)