-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c5bc0d1
commit 8c1d8fe
Showing
1 changed file
with
30 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,30 @@ | ||
# tdr-metadata-validation | ||
# TDR Metadata Validation | ||
|
||
This validation library is used to validate closure & descriptive metadata as per the provided metadata criteria. | ||
If the input values have any errors then it will return a list of error codes. You can use the error codes to render the client's specific error messages. | ||
|
||
## How to use? | ||
|
||
1. Create `MetadataCriteria` for closure or descriptive metadata | ||
2. Create a `MetadataValidation` object with the criteria | ||
3. Now call the validation method (closure or descriptive) with your metadata | ||
|
||
Example: | ||
```scala | ||
import uk.gov.nationalarchives.tdr.validation._ | ||
|
||
val closureMetadataCriteria = MetadataCriteria("ClosureType", Boolean, true, false, false, List("yes", "no")) | ||
val descriptiveMetadataCriteria = List( | ||
MetadataCriteria("Property1", Text, false, false, false, Nil, None, None), | ||
) | ||
val metadataValidation = new MetadataValidation(closureMetadataCriteria, descriptiveMetadataCriteria) | ||
|
||
val metadata = List( | ||
Metadata("Property1", ""), | ||
Metadata("Property2", ""), | ||
Metadata("Property3", "test") | ||
) | ||
|
||
val closureMetadataErrors = metadataValidation.validateClosureMetadata(metadata) | ||
val descriptiveMetadataErrors = metadataValidation.validateDescriptiveMetadata(metadata) | ||
``` |