Form Validation in ASP .Net MVC with Angular JS
<p>I am trying to migrate my demo project to Angular as I am learning the same. But I faced a dilemma as whether to opt for  a razor view form validation while adding or rather updating some info on the client side
or to opt for Angular JS ?</p>

<p>So In Angular How would I achieve the same. 
Suppose I have  a _AddDetails.cshtml partial view :</p>

<pre><code>@model MvcApplication4.Models.Student
@using (Html.BeginForm()) {
    @Html.AntiForgeryToken()
    @Html.ValidationSummary(true)

    &lt;fieldset&gt;
        &lt;legend&gt;&lt;strong&gt;Create a record&lt;/strong&gt;&lt;/legend&gt;

        &lt;div class="editor-label"&gt;
            @Html.LabelFor(model =&gt; model.LastName)
        &lt;/div&gt;
        &lt;div class="editor-field"&gt;
            @Html.EditorFor(model =&gt; model.LastName)
            @Html.ValidationMessageFor(model =&gt; model.LastName)
        &lt;/div&gt;

        &lt;div class="editor-label"&gt;
            @Html.LabelFor(model =&gt; model.FirstName)
        &lt;/div&gt;
        &lt;div class="editor-field"&gt;
            @Html.EditorFor(model =&gt; model.FirstName)
            @Html.ValidationMessageFor(model =&gt; model.FirstName)
        &lt;/div&gt;

        &lt;div class="editor-label"&gt;
            @Html.LabelFor(model =&gt; model.UserName)
        &lt;/div&gt;
        &lt;div class="editor-field"&gt;
            @Html.EditorFor(model =&gt; model.UserName)
            @Html.ValidationMessageFor(model =&gt; model.UserName)
        &lt;/div&gt;

        &lt;div class="editor-label"&gt;
            @Html.LabelFor(model =&gt; model.Password)
        &lt;/div&gt;
        &lt;div class="editor-field"&gt;
            @Html.EditorFor(model =&gt; model.Password)
            @Html.ValidationMessageFor(model =&gt; model.Password)
        &lt;/div&gt;

        &lt;div class="editor-label"&gt;
            @Html.LabelFor(model =&gt; model.DepartmentID)
        &lt;/div&gt;
        &lt;div class="editor-field"&gt;
            @Html.EditorFor(model =&gt; model.DepartmentID)
            @Html.ValidationMessageFor(model =&gt; model.DepartmentID)
        &lt;/div&gt;

        &lt;p&gt;
            &lt;input type="submit" class="createDetails" value="Create" /&gt;
        &lt;/p&gt;
    &lt;/fieldset&gt;
}

&lt;div&gt;
    @Html.ActionLink("Back to List", "Index")
&lt;/div&gt;
</code></pre>

<p>and in MVC I have opted for FluentValidation of the model.</p>

<p>The model looks like :</p>

<pre><code>[FluentValidation.Attributes.Validator(typeof(StudentViewModelValidator))]
public class Student
{
    [Key]
    [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
    public int StudentId { get; set; }
    public String LastName { get; set; }
    public String FirstName { get; set; }
    public String UserName { get; set; }
    public String Password { get; set; }

    [ForeignKey("Department")]
    public int DepartmentID { get; set; }

    //Department Navigational Property
    public Department Department { get; set; }
}
</code></pre>

<p>And the validation looks like :</p>

<pre><code>public class StudentViewModelValidator : AbstractValidator&lt;Student&gt;
{
    public StudentViewModelValidator()
    {
        RuleFor(m =&gt; m.FirstName)
            .NotEmpty().WithMessage("First Name is required.")
            .Matches(@"^\D*$").WithMessage("Numbers are not allowed in First Name");
        RuleFor(m =&gt; m.LastName)
            .NotEmpty().WithMessage("Last Name is required.")
            .Matches(@"^\D*$").WithMessage("Numbers are not allowed in Last Name");
        RuleFor(m =&gt; m.UserName)
            .NotEmpty().WithMessage("User Name is required.")
            .Matches(@"^[a-zA-Z0-9\.\$]*$").WithMessage("Only . and $ are allowed special characters in a user name");
        RuleFor(m =&gt; m.Password)
            .NotEmpty().WithMessage("Password is required.")
            .Length(4, 10).WithMessage("Password should be 4 to 10 characters long")
            .Matches(@"^(?=(\D*\d){2,})(?=([^a-zA-Z]*[a-zA-Z]))(?=[^\.\$\~\&amp;]*[\.\$\~\&amp;]).*").WithMessage("Password should contain at least 2 digits,a letter and at least a special character in it");

    }
</code></pre>

<p>But in angular if I re-build my view instead of this razor template how would I achieve these sort of complex regex validations ?
I know I have something like</p>

<pre><code>ng-required
ng-minlength
ng-maxlength
</code></pre>

<p>But how would I achieve like the above razor validations?</p>