Skip to main content

I need to validate all attributes of a dataset. This can be done using a single AttributeValidator, but that gives me the following problems:

- It gives multiple errors on missing mandatory attributes (first error would be something like 'attribute fails check for <attribute> is not null', the second error could be something like 'attribute fails check for Maximum Length =12'). If a mandatory attribute is missing I only want the first error message as I know all other checks will fail.

- It gives unwanted errors for optional attributes without value. I only want to check the value if there is a value.

I have solved this by making parallel paths in which each path checks one attribute. For optional attributes there is first a Tester which tests if the attribute has a value and next there is the AttributeValidator. For mandatory attributes the path consists of two AttributeValidators: the first checks on 'Not Null' and the seconds checks on 'minimum length' / 'range' / etc. All parallel paths are combined at a ListExploder to be able to create a report in Excel with all error messages. See the image.

As I have many more datasets to check, I would like if there is a way in which my checks on attributes can be done with less transformers.

Kind regards,

 

Maarten.

That's an interesting scenario. It looks like you really want a setting that says either:

  • Feature is processed against all tests, or...
  • Feature is output after the first failed test

I suggest you click on the ideas tab above and post that as an idea for other users to vote on. It's not something we have right now, and it might be useful behaviour for other users too.

I will mention the case to our developer as well, where if an attribute fails the 'has value' test, it's hardly worth trying other validation of it.

Other than that, I think you're probably taking the most sensible route in using a combination of Testers and other transformers, but maybe someone else here has a better solution...?


Hi @maarten, there might be a room to improve the AttributeValidator so that users can apply it to various advanced scenarios. As a meantime workaround, how about this workflow?

0684Q00000ArJuBQAV.png

Since a validation message (every element of the '_fme_validation_message_list{}') that is given by the AttributeValidator always contains the tested attribute name surrounded by single quotations, you can extract the attribute name using the StringSearcher with an appropriate regex. e.g.

(?<=')r^']+

Then you can filter the validation messages for each attribute with some transformers.

See also the attached demo: filter-attribute-validation-message.fmw (FME 2016.1)


Dear Mark and Takashi,

Thank you both for your answers.

I decided to stick with my first solution, but replaced the Tester (which tests if the attribute has a value) with a AttributeValidator, which will give a nice error message.

For each attribute (which can be in different datasets), I now created custom transformers which can be used in the workbenches for checking the different datasets.

I even created a geometric validator using a clipper, for which I defined a custom error message which I can combine in a neat way with the error messages from the AttributeValidators.


Reply