Strickland
  • Readme
  • Introduction
    • Validators
    • Validation
    • Validation Results
  • Extensibility
    • Validator Factories
    • Validation Context
    • Validation Result Props
    • Extensibility Pattern
    • formatResult
  • Built-In Validators
    • required
    • compare
    • min
    • max
    • range
    • minLength
    • maxLength
    • length
  • Composition
    • Arrays of Validators
      • every
      • all
      • some
    • Validating Array Elements
      • arrayElements
    • Validating Objects
      • objectProps
      • Advanced Object Validation
      • Nested Objects
      • Arrays of Objects
    • Composition Conventions
    • Composition and formatResult
  • Async Validation
    • Resolving Async Validation
    • Deferred Async Validation
    • Async Validator Arrays and Objects
    • Two-Stage Sync/Async Validation
    • Race Conditions
    • Automatic Race Condition Handling
    • Async Validation and formatResult
  • Form Validation
    • form
    • Async Form Validation
    • validateFields
    • emptyResults
    • updateFieldResults
  • Inspiration
  • Design Goals
  • Wrap-Up
  • Change Log
  • NPM
  • GitHub
Powered by GitBook
On this page

Was this helpful?

Form Validation

Let's face it: we're trying to validate forms in the user interface. Yes, Strickland is decoupled from the UI and it can be used in other scenarios (like APIs), but form validation is the primary use case.

With the ability to validate an entire object with the objectProps validator, Strickland gets pretty close to providing form validation; it just falls short in one key way. The objectProps validator does not support validating field-by-field. You can dynamically build your objectProps validator to target specific fields and merge validation results after each validation, but there's a lot of orchestration code involved.

To simplify this scenario, Strickland provides a form validator that behaves similarly to objectProps, but it has additional features for field-by-field validation where a form's validation results are built up incrementally.

PreviousAsync Validation and formatResultNextform

Last updated 4 years ago

Was this helpful?