DataContainer

abstract class DataContainer<T>(val valueWithoutAuthorization: T)

These container classes server several purposes:

  1. this is where you place validation rules

  2. authorization rules are applied when you try to extract the value in the container

  3. it is possible to add labels and descriptions to containers (can be used by your UI)

  4. it is possible to add tags to containers. This enables authorization rules like 'Top secret facts can only be read by 2-star generals and above'. It also enables queries like 'Show me all info about user X but omit any Personally Identifiable Information (PII)'.

  5. they make it impossible to confuse parameters, e.g. a Username and a Password even though they are both Strings

  6. you can use types that adds meaning to the data. E.g. let's say you have a DistanceMeters : DoubleContainer. Instead of hoping that all parts in the code that accesses its value treats it as meters, you can add a function like fun DistanceMeters.toMeasure(): Measure = Measure(value, meters) Code that uses this function cannot misinterpret the unit.

Inheritors

Constructors

Link copied to clipboard
constructor(valueWithoutAuthorization: T)

Properties

Link copied to clipboard
open val tags: Set<String>
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard
open override fun toString(): String
Link copied to clipboard
abstract fun validate(fieldName: String): InvalidParametersProblem?