Skip to content
This repository was archived by the owner on Feb 6, 2023. It is now read-only.

Latest commit

 

History

8 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

Simple Validation

Build Status

Core meteor validation package for checking data, nothing more

Installation

meteor add simple-validation

Validate Helper Object

This package provides two helper functions for doing validation:

Validate.check

Validate.check( validator, args... );

Provide a validator and any additional arguments that validator may require

Example:

Validate.check( VadliateIsString, 1 ) === 'Please enter a string';

Validate.chain

Validate.chain( checks... );

Provide a series of Validate.check responses, this will then merge the results of those checks into an array of messages, or true on success of all checks.

Example:

Validate.chain(
    Validate.check(ValidateIsString, 1),
    Validate.check(ValidateIsString, 1, 'my message')
) === [ "Please enter a string", "my message" ];

Validators

All validators included, and any validators you write should adhere to the following:

  • Return true on success.
  • Return a string with an appropriate error meessage on failure.

This package comes with 3 validatos for your convenience:

ValidateIsNumeric

ValidateIsNumeric.validate( data, optionalMessage )

ValidateIsString

ValidateIsString.validate( data, optionalMessage )

ValidateNotEmpty

ValidateNotEmpty.validate( data, optionalMessage )

Running Tests

cd src
meteor test-packages ./

Publishing

cd src
meteor publish

About

Core meteor validation package for checking data, nothing more

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages