Skip to content

Instantly share code, notes, and snippets.

@jmarnold
Last active December 21, 2015 04:39
Show Gist options
  • Save jmarnold/6250861 to your computer and use it in GitHub Desktop.
Save jmarnold/6250861 to your computer and use it in GitHub Desktop.
Validation Demo

Standard form (Create Account)

  • Attributes first
  • Drop in authentication, re-style the form, and use OverridesFor to add validation
  • Add custom validation keys class (show how easy localization is)
  • Create the PastDateRule (show how easy testing can be)

Switch to ClassValidationRules (this helps enforce rule order)

Define the rules for the DateOfBirth property:

  1. Required
  2. RegEx (use a custom InvalidDateFormat key) => [0-9]{2}/[0-9]{2}/[0-9]{4}
  3. PastDateRule

Then...

  • Show off the property matching rule (password => confirm password, email => confirm email)
  • Make the endpoint actually persist the account
  • Remote rule (email uniqueness)
  • Live vs. triggered validation (mix and match properties)
  • Switch up the rendering strategies (turn off summary and use inline)
  • Change the element timeout
  • Switch to an ajax form?

Quick Diagnostics Demo

Custom rendering strategies

  • Create the bootstrap strategy
  • Show how to conventionally wire it up

Angular usage:

  • Basic todo list
  • Modal for creating a new item
  • Apply validation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment