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):UnitAdd a helper that will perform validation at the end of the block. |
| invoke | operator funMatrix<Double>.invoke(fn:ValidationContext.() ->Unit):ValidationContextExecute the given fn (which should contain validation rules) against the given matrix. operator funMatrix<Double>.invoke(name:String, fn:ValidationContext.() ->Unit):ValidationContextExecute 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():UnitCheck declared matrices against any rules that have been added with addValidator. fun validate(fn:ValidationContext.() ->Unit):UnitCheck declared matrices against any rules that have been added with addValidator, after running the given callback. |
| x | infix funInt.x(cols:Int):Unitinfix funInt.x(cols:Char):Unitinfix funChar.x(cols:Int):Unitinfix funChar.x(cols:Char):Unit |
Extension Properties
| Name | Summary |
|---|---|
| max | varValidationContext.max:DoubleMaximum value for individual elements in the matrix. |
| min | varValidationContext.min:DoubleMinimum value for individual elements in the matrix. |
| symmetric | valValidationContext.symmetric:ValidationContextRequire the current matrix to be symmetric. |
| transposable | valValidationContext.transposable:ValidationContextAccept 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):ValidationContextRequire the current matrix to have exactly the given number of rows and columns. funValidationContext.dim(rows:Int, cols:Char):ValidationContextRequire 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):ValidationContextRequire 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):ValidationContextRequire 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):ValidationContextEnsure all of the elements in the current matrix are >= the given value. |
| min | funValidationContext.min(value:Double):ValidationContextEnsure all of the elements in the current matrix are >= the given value. |
| symmetric | funValidationContext.symmetric(precision:Double= 1e-5):ValidationContext |