Validator component

Using the o-validator component allows to define a validator function that will be applied to its parent input. It also allows to define a single error message.

Example

   <o-text-input attr="input" label="{{ 'INPUT.BUTTON.TEXT' | oTranslate }}">
  <o-validator error-name="requiredB" error-text="Must contain a 'b'"
    [validator-function]="bValidator">
  </o-validator>
</o-text-input>
  ...

  import { ValidationErrors, FormControl } from '@angular/forms';

  bValidator(control: FormControl): ValidationErrors {
    if (control.value && control.value.toString().indexOf('b') === -1) {
      return {
        'requiredB': true
      };
    }
    return {};
  }

  ...

If the new validator has more than one possible error result, user must use the o-error component to define the multiple errors messages.