0.0.3 • Published 3 years ago

ngx-simpler-youtube-validator v0.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

NgxSimplerYoutubeValidator

How to:

  1. import module
import { 
    NgxSimplerYoutubeValidatorModule 
} from 'ngx-simpler-youtube-validator';

@NgModule({
  declarations: [
    AppComponent,
  ],
  imports: [
    BrowserModule,
    NgxSimplerYoutubeValidatorModule,
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }
  1. add youtube validatior directive to exist formControl
@Component({
  selector: 'app-root',
  template: `
    <div>
      <h1>Hello World</h1>

      <div>
        <form [formGroup]="form">
          <input
            type="text"
            [formControl]="url"
            [isYoutubeUrl]="true" <-- indicator that you want validate url 
                                        or youtube id, default is false
            [forceFixUrl]="true" <-- if true and isYoutubeUrl, 
                                        then your input will be updated become 
                                        proper format.
                                        ex:
                                            from: https://www.youtube.com/watch?v=w2y715XAmso&list=RDLlldWeUmwVY&index=2
                                            to: https://www.youtube.com/watch?v=w2y715XAmso
            simplerYoutubeValidator> <-- this

          <div>
            <button [disabled]="!form.valid">
              Submit
            </button>
          </div>
        </form>
      </div>
    </div>
  `,
})
export class AppComponent implements OnInit { }
  1. done :)

Contributes:

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago