import { ValidationFailure } from "./" ; export class ValidationResult { private failures : Array < ValidationFailure > = [ ] ; isValid ( ) { return this . failures . length === 0 ; } isInvalid ( ) { return ! this . isValid ( ) ; } addFailures ( failures ) { if ( failures ) { this . failures = this . failures . concat ( failures ) ; } } getFailures ( ) { return this . failures . slice ( 0 ) ; } getFailureMessages ( ) { return this . failures . filter ( failure => failure . message ) . map ( failure => < string > failure . message ) ; } getFailureCodes ( ) { return this . failures . filter ( failure => failure . code ) . map ( failure => < string > failure . code ) ; } }