Class: Wraith.Validator

Defined in: src/validator.coffee

Overview

The core validator used to validated Models. Really just supplies an interface, for now.

Defined on the model through the @field method like so:

Examples:

class App.Model extends Wraith.Model
  @field 'text', { default: '', type: new Wraith.Validators.String{ min: 2, max: 30 } }

Direct Known Subclasses

Wraith.Validators.Text, Wraith.Validators.Num

Instance Method Summary

Instance Method Details

- (Boolean|String) isValid(content)

Takes in a string|object and runs validation on it. Returns true if valid or a string containing the error description if false. Meant to be overridden.

Parameters:

  • content (String|Object) The string or object to be validated

Returns:

  • (Boolean|String) — True if valid or a string with an error message if not.