Is there a way to scrub a value for a specific property?

189 views Asked by At

Apologies if this is documented somewhere, but I was unable to find it.

I have this nested shortId field

{ 
  ...
  "positions" 
    [ 
      { 
        ....
        "shortId": ABC123 
      },  
    ] 
} 

I need to scrub it the same way guids are scrubbed. Looking through the code, it looks like the scrubbers are based around detecting the format of the current value. Is there a way to detect if the value can be scrubbed based on the property name?

Cheers, Drew

[edit] So far, it looks like I'll need to create a new scrubber that parses the entire StringBuilder to identify the properties. I'm wondering if someone has already done this or if I need to write it myself.

1

There are 1 answers

1
Simon On BEST ANSWER

https://github.com/VerifyTests/Verify/blob/main/docs/serializer-settings.md#scrub-member-by-name

[Fact]
public Task ScrubMemberByNameFluent()
{
    var target = new IgnoreExplicitTarget
    {
        Include = "Value",
        Field = "Value",
        Property = "Value",
        PropertyByName = "Value"
    };
    return Verify(target)
        // For all types
        .ScrubMember("PropertyByName")
}