api / koma.util.validation / ValidationContext

ValidationContext

class ValidationContext

A lambda receiver with state and convenience methods for validating a group of matrices.

In general there is no reason to instantiate this directly, instead @see validate(fn) for example usage.

Constructors

Name Summary
<init> ValidationContext()
A lambda receiver with state and convenience methods for validating a group of matrices.

Properties

Name Summary
currentMatrix val currentMatrix:Matrix<Double>
currentMatrixName val currentMatrixName:String
matrices val matrices:MutableList<Matrix<Double>>
matrixNames val matrixNames:MutableList<String>
metadataStorage val metadataStorage:MutableMap<String,Any>

Functions

Name Summary
addValidator fun addValidator(validator:Validator):Unit
Add a helper that will perform validation at the end of the block.
invoke operator funMatrix<Double>.invoke(fn:ValidationContext.() ->Unit):ValidationContext
Execute the given fn (which should contain validation rules) against the given matrix.operator funMatrix<Double>.invoke(name:String, fn:ValidationContext.() ->Unit):ValidationContext
Execute the given fn (which should contain validation rules) against the given matrix with the given name.operator fun invoke():ValidationContext
metadata fun <T> metadata(key:String, factory: () ->T):T
validate fun validate():Unit
Check declared matrices against any rules that have been added with addValidator.fun validate(fn:ValidationContext.() ->Unit):Unit
Check declared matrices against any rules that have been added with addValidator, after running the given callback.
x infix funInt.x(cols:Int):Unit
infix funInt.x(cols:Char):Unit
infix funChar.x(cols:Int):Unit
infix funChar.x(cols:Char):Unit

Extension Properties

Name Summary
max varValidationContext.max:Double
Maximum value for individual elements in the matrix.
min varValidationContext.min:Double
Minimum value for individual elements in the matrix.
symmetric valValidationContext.symmetric:ValidationContext
Require the current matrix to be symmetric.
transposable valValidationContext.transposable:ValidationContext
Accept a transposed version of the matrix as satisfying the dimensions check. For example, allow a 1 x 3 matrix when dimensions are declared as 3 x 1.

Extension Functions

Name Summary
dim funValidationContext.dim(rows:Int, cols:Int):ValidationContext
Require the current matrix to have exactly the given number of rows and columns.funValidationContext.dim(rows:Int, cols:Char):ValidationContext
Require the current matrix to have exactly the given number of rows and match the number of columns with other dimensions in other matrices based on the cols variable name.funValidationContext.dim(rows:Char, cols:Int):ValidationContext
Require the current matrix to have exactly the given number of columns and match the number of rows with other dimensions in other matrices based on the rows variable name.funValidationContext.dim(rows:Char, cols:Char):ValidationContext
Require the current matrix's dimensions to correspond to the given variable names. Compares with other dimensions in other matrices in the context that are assigned the same variable name and raises an error if they don't all match.
max funValidationContext.max(value:Double):ValidationContext
Ensure all of the elements in the current matrix are >= the given value.
min funValidationContext.min(value:Double):ValidationContext
Ensure all of the elements in the current matrix are >= the given value.
symmetric funValidationContext.symmetric(precision:Double= 1e-5):ValidationContext