title: How to apply required validation for checkbox using dynamically
body: <p>I'm setting <code>dynamic form validation</code> using the following <code>JSON</code>. base on these <code>JSON</code> i have create dynamically form field using the following <code>JSON</code> format.</p>
  
  <p><code>fields = [
      {
        type: 'text',
        name: 'firstName',
        label: 'First Name',
        value: '',
        required: true,
     },
     {
        type: 'checkbox',
        name: 'hobby',
        label: 'Hobby',
        required: true,
        options: [
          { key: 'f', label: 'Fishing' },
          { key: 'c', label: 'Cooking' }
        ]
      }
    ]</code></p>
  
  <p>My <code>commponent.ts</code> file is following</p>
  
  <pre><code>form: FormGroup;
  
  ngOnInit() {
    let fieldsCtrls = {};
      for (let f of this.fields) {
        if (f.type != 'checkbox') {
          fieldsCtrls[f.name] = new FormControl(f.value || '', 
            Validators.required)
        } else {
          let opts = {};
          for (let opt of f.options) {
            opts[opt.key] = new FormControl(opt.value);
          }
         fieldsCtrls[f.name] = new FormGroup(opts)
       }
     }
     this.form = new FormGroup(fieldsCtrls);
  }  
  </code></pre>
  
  <p>I have apply <code>required</code> validation for all input field exclude <code>checkbox</code>.   </p>
  
  <blockquote>
    <p>How can apply required validation for the checkbox in this code?</p>
  </blockquote>