Core

AField<T>

Core abstract class for all possible fields. Configs present in its initialization context can be applied to any field and will work the same.

const field: AField<number> = new NumberField({
   /* Marks field as getter which should not be expected in data during conversion */
   isCalculated: false,
   /* Marks that field can have null or undefined as value
      and this should NOT be considered as corruption*/
   isNullable: false,
   /* Validates provided value based on field validation settings */
   validators: [
      value => {
         if (value % 2 === 0) return; // #Return#
         return { code: 666, message: `Odd number`, value };
      }
   ]
});

Calculated

Marks that value is calculated by getter and will NOT be present in data.

Nullable

Marks that value can be null or undefined and this should NOT be considered as corruption.

circle-info

If provided data doesn't contain value under nullable key value setted during instance creation will be used.

Validators

Array of functions which check incoming value and returns nothing if it is valid or object with info describing invalidity.

Last updated