Label Validation
Last updated
Last updated
Breaking Change Notice
Prior to Ango Hub 3.10, a toggle in the project settings allowed the project manager to decide whether the validations in the project prevented submission or not. This toggle was global for the entire project, meaning that all validations in the project either prevented submission or not.
Since Ango Hub 3.10, the toggle has been deprecated. Instead, the project manager can now decide whether each validation prevents submission or not by including a boolean named preventSubmission
to the error. If true
, the annotator will not be able to submit when the error is shown. If false
, the annotator will be shown the option to submit the task anyway.
For validation code created before this change, or wherever the preventSubmission
boolean is not present, we default to preventing submission.
You can show errors to labelers when they try to submit annotations that don't fit requirements of your choice, and if you so wish, you can prevent them from submitting their label entirely.
Ango Hub provides a fully customizable and programmatic way to validate annotations, allowing you to create JavaScript functions that hook directly into Ango Hub's code and run when annotators attempt to save or submit their annotations.
Label validation is run only when the labeler clicks on Save or Submit.
Label validation will not run unless you enable the Enable Custom Validation toggle in the Custom Validation section of the project settings:
Navigate to the project where you'd like to enable label validation, then go to the Settings tab and enter the Label Validation section:
Enable Custom Validation: when enabled, validation will be activated for the current project.
In the code area below, you will enter your JavaScript function containing the logic of your label validation. You may click on Validate Code to check for syntax errors and try your code on sample labels.
In the code area of the Label Validation section, enter a JavaScript function that takes one parameter (we'll call it answers,) and returns a list of dicts with the errors you'd like to show. The function will be run every time an annotator tries to save or submit annotations.
Ango Hub will pass one parameter to your function, a JSON object which contains all objects, relations, and classifications the annotator is trying to submit.
This is a sample 'answers' parameter you'll receive from Ango Hub. In this case, the user created two PDF areas, created a single relation between them, and replied to a classification with two answers:
For more on what can be passed in 'answers', we recommend following the steps in the next section. Following that, consulting the page Ango Annotation Format will also help, as it details the format in which annotations are exported, which is the same as what you'll receive as parameter.
We developed a fast and efficient way to preview what will be passed to your function based on your needs:
Open the labeling editor and perform a test annotation on Hub with the tools and answers you need.
Without having to save or submit the annotation, from the three-dot menu in the top-right corner, click on Copy Answers:
You will have copied exactly what Ango Hub would have passed as parameter in your validation function based on the labels on the screen.
Your function will need to return a list of dictionaries, containing the ID of the object which is causing the error, an error message string, as well as whether the error should prevent the annotator from submitting the task or not.
This is what a sample return will look like:
From Ango Hub, you can test and debug your function without having to perform labeling and submitting test annotations every time.
Obtain a sample of what will be passed into your function by following the steps in this section.
From your project dashboard, enter the Settings tab, then the Label Validation section. In the code area, enter your validation function.
To test and debug your code, click on the Validate Code button below the code area:
A dialog will open:
5. Paste the input parameter you have copied in Step 1, and click on Run.
Ango Hub will scan your function for syntax errors, and show them to you if present.
If your function successfully returned errors based on the annotations JSON you've just passed it as parameter, Ango Hub will show them to you below the code area:
By moving back and forth between writing your function and the validation dialog, you can create a quick build-debug workflow allowing you to create and test your functions quickly.
Give an error if a point exists with its X coordinate under 100:
Give an error if an empty group relation exists:
Give an error if a bounding box is narrower than 100px:
Give an error if a group relation you specify contains objects with names different from the ones you specify:
Give an error if a group relation you specify contains more than one object from the ones you specify: