import { Directive , Input , OnInit } from '@angular/core' ; import { ValidationErrors } from '@angular/forms' ; import { ObSchemaValidationService } from './schema-validation.service' ; @ Directive ( { selector : '[obSchemaValidation]' , exportAs : 'obSchemaValidation' , providers : [ ObSchemaValidationService ] , host : { class : 'ob-schema-validation' } } ) export class ObSchemaValidationDirective implements OnInit { @ Input ( 'obSchemaValidation' ) private readonly schema : any ; private validator ; constructor ( private readonly schemaValidationService ) { } ngOnInit ( ) { this . validator = this . schemaValidationService . compileSchema ( this . schema ) ; } isRequired ( propertyName , path ) { return this . validator . isRequired ( propertyName , path ) ; } validate ( propertyPath , value ) { return this . validator . validate ( propertyPath , value ) ; } }