Validation Rules

One of the most important features in Delia is its validation. All values are validated according to the rules you define. Delia will not store invalid data into the database.

Scalar Validation

A custom scalar type can have validation rules. Let's define a school grade type that holds value 0..100 (inclusive).

 type int Grade int 
  value >= 0
  value <= 100
 end

Delia will validate all Grade values according to its rules

 let grade Grade = 80; //OK

If you attempt to assign an incorrect grade, an error will occur and Delia execution will halt.

 let grade2 Grade = 101; //ERROR - will fail

If you use the Grade type as a field in a struct type, Delia will validate before insert or update.

type StudentReport struct {
	name string
	grade Grade
} end

insert StudentReport { name: 'sue jones', grade: 92} //OK

If there are validation errors, the insert will not be performed and Delia execution will terminate with an error.