// myCardValidator.ts
const MyCardValidatorType = new CardValidatorType(
'9a32e86b-7c82-4413-9c83-882a516abada',
'MyCardValidator'
);
const MyValidationKey = new ValidationKey(
'd57ef1a1-cfcd-0852-8a2c-ce527bc02aac',
'MyValidationKey',
'Card is not valid'
);
@injectable()
export class MyCardValidator implements ICardValidator {
async validate(context: CardValidationContext, validator: CardTypeValidator): Promise<void> {
if (/*some expr*/) {
ValidationSequence
.begin(context.getCardValidator())
.setObjectType('MyCardValidator')
.error(MyValidationKey)
.end();
}
}
}
// registrator.ts
export const Registrator: ExtensionRegistrator = {
async registerTypes(container) {
CardValidatorTypeRegistry.instance.register(MyCardValidatorType);
ValidationKeyRegistry.instance.register(key);
container
.bind(ICardValidator$)
.to(MyCardValidator)
.whenTargetNamed(MyCardValidatorType.id);
}
}
Generated using TypeDoc