0.2.0 • Published 1 year ago

@cats-cradle/validation-decorators v0.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

@cats-cradle/validation-decorators

Contains standard class-validator decorators and custom decorators for use primarly in defining and validating data used in game design.

import {
  validateSync,
  ValidationError,
  IsDiceNotation,
} from '@cats-cradle/validation-decorators';

class Turn {
  @IsDiceNotation()
  public property: string;
}

let turn = new Turn();
turn.diceNotation = '1d6+4';

const errors: ValidationError[] = validateSync(testClass);

// outputs 0
console.log(errors.length);

All validation decorators should be supported by @cats-cradle/FakerFactory enabling automatic generation of fakes.

Documentation