import { alpha , ReactiveFormConfig , RxFormBuilder } from '@rxweb/reactive-form-validators' ; export class AddressInfo { @ alpha ( ) countryName : string ; @ alpha ( { conditionalExpression : ( x , y ) => x . countryName == "India" } ) countryCode : string ; @ alpha ( { conditionalExpression : 'x => x.countryName =="India"' } ) cityName : string ; @ alpha ( { allowWhiteSpace : true } ) stateName : string ; @ alpha ( { message : 'You can enter only alphabets.' } ) stateCode : string ; } describe ( 'Decorator' , ( ) => { let formBuilder = new RxFormBuilder ( ) ; beforeEach ( ( ) => { ReactiveFormConfig . set ( { "validationMessage" : { "alpha" : "Only alphabets are allowed." , } } ) ; } ) ; describe ( 'alphaDecorator' , ( ) => { it ( 'should not error in countryName property with null value.' , ( ) => { let formGroup = formBuilder . formGroup ( AddressInfo ) ; expect ( formGroup . controls . countryName . errors ) . toBeNull ( ) ; } ) ; it ( 'should not error in countryName property with null value.' , ( ) => { let addressInfo = new AddressInfo ( ) ; addressInfo . countryName = undefined ; let formGroup = formBuilder . formGroup ( addressInfo ) ; expect ( formGroup . controls . countryName . errors ) . toBeNull ( ) ; } ) ; } ) ; } ) ;