Example

Getting Help

Core Concepts

There are a lot of great libraries for testing code. We should use those same concepts for testing
data.

Performance and streaming are important

A data validation library should be able to handle large amounts of data quickly.

Invalid data is also important

Warnings and Errors need to be treated as first class objects.

Data Traces

Similar to a stack trace being used to debug a code path, a data trace can be used to debug a
path through data.

Don’t map data to Types too early.

Type safe code is great but if the data hasn’t been santized then it isn’t really typed.

Example Schema Definition

importcom.shoprunner.baleen.Baleen.describeAsimportcom.shoprunner.baleen.ValidationErrorimportcom.shoprunner.baleen.dataTraceimportcom.shoprunner.baleen.types.StringTypevaldepartments=listOf("Mens","Womens","Boys","Girls","Kids","Baby & Toddler")valproductDescription="Product".describeAs{"sku".type(StringType(min=1,max=500),required=true)"brand_manufacturer".type(StringType(min=1,max=500),required=true)"department".type(StringType(min=0,max=100)).describe{attr->attr.test{datatrace,value->valdepartment=value["department"]if(department!=null&&!departments.contains(department)){sequenceOf(ValidationError(dataTrace,"Department ($department) is not a valid value.",value))}else{sequenceOf()}}}}

Gotchas

Baleen does not assume that an attribute is not set and an attribute that is set with the value of null are the same thing.