Skip to content

Instantly share code, notes, and snippets.

Last active July 23, 2018 13:39
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save theotherdy/a51ed7cbbb63c2e288481614b9a288e6 to your computer and use it in GitHub Desktop.
import { isORCIDValidator } from '../../shared/index';
selector: 'user-edit-component',
templateUrl: './user-edit.component.html',
styleUrls: ['./user-edit.component.css']
export class UserEditComponent implements OnInit {
@Input() user:User;
urlRegexPattern: string = 'https:\/\/orcid\.org\/.*'; // Regex pattern to ensure URL starts with
// TODO Regex pattern for 16digit part following this
/* Creating form */
userForm: FormGroup;
// naming form controls as class properties means we can refer to them by name in the html template - see:
orcid: FormControl;
constructor(private userService: UserService) {
createFormControls() {
this.orcid = new FormControl(this.user.orcid,[Validators.pattern(this.urlRegexPattern),isORCIDValidator]);
createForm() {
this.userForm = new FormGroup({
orcid: this.orcid,
ngOnInit() {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment