Lesson 3: More validator types
So far every check compared a field with one fixed text. Most fields are not like that: a date changes on every drawing, a revision follows a pattern, and some checks are about the PDF itself or a logo rather than a field. In this lesson you give each field the right kind of Validator.
What you learn
- Which Validator type to use for which field.
- How to build a Pattern from the value on the template, and what a pattern built from one value does and does not accept.
- The Date, Page format and Image Validators, and the whole-file checks PDF/A and Readable text.
- Required, Optional and Hidden checks, and what each does in a report.
- The Not checked marker on fields that nothing checks.
Files for this lesson
Download Lesson 3 files (zip) and unpack it.
| File | What it is for |
|---|---|
template/NDXTEST-NHX-B1-00-DR-A-200100_P02_A3_landscape.pdf | The template for the document type. |
check/NDXTEST-NHX-B1-00-DR-A-200110_P01_A3_landscape.pdf | Drawing to check. |
check/NDXTEST-NHX-B1-01-DR-A-200111_P01_A3_landscape.pdf | Drawing to check. |
check/NDXTEST-NHX-B1-02-DR-A-200112_P01_A3_landscape.pdf | Drawing to check. |
check/NDXTEST-NHX-B1-RF-DR-A-200113_P01_A2_landscape.pdf | Drawing to check. |
check/NDXTEST-NHX-B1-ZZ-DR-A-200114_P01_A3_landscape.pdf | Drawing to check. |
check/NDXTEST-NHX-B1-ZZ-DR-A-200115_P01_A3_landscape.pdf | Drawing to check. |
Several of these drawings have a planted fault. The self-check at the end lists them.
Choosing a Validator
So far every check was a Fixed value. This lesson adds Date, Pattern, Not empty, Image and Page format; which type fits which field, for every type, is in the decision table Validators › Which Validator to use.
The training drawings are not PDF/A files. A PDF/A check fails on every one of them, so it is left out of this lesson.
Patterns
A Pattern describes the form of a value with building blocks, for example "P" + 2 digits. The blocks must match the whole text. The main blocks are Text, Number (a count of digits), Letters, Any characters, One of, and List.
In this lesson the patterns come from Looks like … in the guided field validation, which builds the blocks from the value on the template. A pattern built from one value asks for exactly that shape, so the scale pattern above accepts 1:200 and 1:500 but not 1:50 or 1:1250. The other ways to make one, From examples… and Regex, and every building block are in Validators › Pattern.
Required, optional and hidden checks
Every Validator has an Applicability: Required (the default; a failure fails the file), Optional (listed, but never fails the file) or Hidden (not checked and not listed, but it can still decide which PDFs belong to the document type, as lesson 5 shows). See Validators › Required, optional and hidden checks.
The Not checked marker
A field whose value no Validator checks is marked Not checked in the Items section: NodePDF reads it, but it can never fail. The marker goes away as soon as a check reads the field.
Steps
Set up the project and the fields
- Create a new project named
Lesson 3, drop the lesson 3 template on the Doctypes tab, open the document type and rename it toDrawingwith Edit details. - Choose Auto-extract title block, then Remove all. Click these boxes: CLIENT, DATE, SCALE, REVISION and CHECKED. Do not add any checks in the popup. Choose Add 5 fields. All five rows are marked Not checked.
Give each field the right check
For each row, expand it (the chevron in front of the name) and choose Add check. The same choices appear as in step 3 of the guided field validation.
- CLIENT: choose Exactly "EXAMPLE CLIENT".
- DATE: choose A date. The check uses the format of the date on the template, DD/MM/YYYY.
- REVISION: choose Looks like P02. Click the new Pattern block and look at the blocks:
"P" + 2 digits. - SCALE: choose Looks like 1:200 @ A3. The pattern is
1 digit + ":" + 3 digits + " @ A" + 1 digit. - CHECKED: choose Not empty: someone must have checked the drawing, whoever it was.
The Not checked markers are gone, and every row shows Passes on the template.
Check the logo
- In the Items section, choose Image validation. The canvas editor opens at the step Pick the image.
- Drag a rectangle around the NODEHEX logo above the CLIENT box. The captured image appears in the panel.
- Under Where to look, keep In an area of page 1. The area is set around the logo. Keep the Match threshold at 0.80.
- The panel shows On this drawing: passes. Type
Logoas the Title and choose Done.
The image must appear at the same size as on the template; its position may move a little within the area. See Validators › Image.
Check the sheet size
- Choose Add › Validator: Page format.
- Under the formats, tick A3. Keep Pages must be at Any of these, the Tolerance at 3 mm and Pages to check at Every page.
- Type
Sheet sizeas the Name (optional) and choose Save. It passes on the template.
Run the report
- On the Validate tab, choose the six PDFs from the
checkfolder, name the reportLesson 3, and choose Run report. - Export the report to Excel. On the Results sheet, filter Status on FAIL and look at the Validator, Extracted Text and Details columns.
Try an optional check
- Back on the document type page, expand the Logo row and click its Image block. Set Applicability to Optional and choose Save.
- Run the report again as
Lesson 3 optional. The logo failure now shows as "Fail (optional)" (in Excel: Status FAIL with Fails File "No"), and that drawing passes unless something else fails. - Set the Logo check back to Required.
Exercise
Set up the document type with the six checks from the steps (CLIENT, DATE, REVISION, SCALE, CHECKED and the Logo), plus the Page format check, all Required. No row may show Not checked. Run the report on the six drawings.
You're done when…
- no row in the Items section is marked Not checked, and every check passes on the template;
- the report shows Files 6, and Results 6: 1 passed, 5 failed;
- only drawing 200110 passes;
- you can name, from the Excel export, the check that fails each of the other five drawings (see the answers below).
Check yourself
Exercise answers
Which check fails on each of the five failing drawings?
- 200111: DATE. It reads "31/13/2026", which is not a real date: there is no month 13. Details:
Not a date in the format DD/MM/YYYY. - 200112: REVISION. The REVISION box is empty, so the check fails with
The extract is empty. - 200113: Sheet size (Page format). The sheet is A2, not A3. Its field checks fail too, because on an A2 sheet the title block sits on a different part of the page, so the A3 areas read nothing (the same effect as the A1 sheet in lesson 2).
- 200114: SCALE. "1:1250 @ A3" has four digits after the colon, and the pattern allows three.
- 200115: Logo. The logo is missing. Details: the image was not found, with the best similarity found.
Questions
The data frame Title block in NDX Example - Text and drawings uses several of these types: SCALE is a Pattern (1 digit + ":" + 3 digits + " @ A" + 1 digit), DATE a Date in DD/MM/YYYY, JOB No. a Pattern of 5 digits, and Role a One of a list. The A3FFF example drawing fails its SCALE pattern, because "1:100 @ A3FFF" has more than one character after "@ A".