export abstract class EnumValueObject < T > { readonly value : T ; constructor ( value , public readonly validValues ) { this . value = value ; this . checkValueIsValid ( value ) ; } public checkValueIsValid ( value ) { if ( ! this . validValues . includes ( value ) ) { this . throwErrorForInvalidValue ( value ) ; } } protected abstract throwErrorForInvalidValue ( value ) ; }