New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to ignore text parts in plain text validator #313

Closed
armandoruizgonzalez opened this Issue Dec 3, 2017 · 2 comments

Comments

Projects
None yet
2 participants
@armandoruizgonzalez

armandoruizgonzalez commented Dec 3, 2017

In XML it is easy, because there is a tag called @Ingore, but in PlainTextMessageValidator it does not exist.
Example: in my flat plot I have from position 12 to 22 a field that is dynamic that is the date, then the plot when I compare it I get error.

Thank's a lot

@christophd

This comment has been minimized.

Member

christophd commented Dec 5, 2017

You can make use of the String validation matcher such as @startsWith()@, @endsWith()@ in oder to check that the plaintext is as expected. That solution might be quite limited though.

The validation of your plaintext payload is very specific to your needs. There is no generic way to ignore this piece of character sequence other than writing a custom PlainTextMessageValidator that is aware of ignoring that particular sequence block. Writing a custom validator based on an existing validator is not very hard to accomplish. I think this should be the best solution for you.

@christophd christophd changed the title from how to ignore part of a flat plot? to How to ignore text parts in plain text validator Dec 5, 2017

@christophd

This comment has been minimized.

Member

christophd commented Dec 5, 2017

I have added a simple way to do this kind of ignore operation which is based on the @ignore@ placeholder that should be placed at the exact same position in the text.

Source text

Your current id is '1234567890'

Control text

Your current id is '@ignore@'

This will ignore the exact same word in the source text. A word is specified by non-word characters (\W) in Java. Also you can give the exact amount of characters to ignore:

Source text

Your current id is '#12345-67890'

Control text

Your current id is '@ignore(12)@'

This will ignore exactly 12 characters starting from the position of the @ignore@ expression.

In general this requires you to know the exact text structure including all whitespace characters.

@christophd christophd added this to the v2.7.3 milestone Dec 5, 2017

@christophd christophd closed this in f8aea21 Dec 5, 2017

@christophd christophd removed the READY label Dec 5, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment