npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

egkyron

v0.4.3

Published

A validation infrasrtructure library, with the goal of being capable to adapt to various kinds of Javascript model objects, e.g. plain JSON, Knockout etc and environments, e.g. Node, Browser+AngularJS, Browser+Knockout etc

Downloads

2

Readme

Egkyron

Egkyron is a validation infrastructure library, with the goal of being capable to adapt to various kinds of Javascript model objects, e.g. plain JSON, Knockout etc and environments, e.g. Node, Browser+AngularJS, Browser+React etc. The word egkyron means valid in Greek.

Egkyron undertakes the task of model validation in addition to form validation. Form validation has already been implemented for the targeted frameworks, such as AngularJS. This means that, given some data (the model) and a defined set of validation rules, it decides the validity of the overall model and individual parts of it. It provides infrastructure for error message generation of the invalid parts of the model. And it provides infrastructure for integrating with form validation, so that error messages can be displayed to the user as appropriate.

Egkyron tries to provide the infrastructure for validation up to the generation of a data structure containing detailed information about the errors of the model. It is up to the user how will these error be displayed. Look in the src/examples folder for sample implementations of the display logic.

Here is a plunk version of the Angular example.

Changes

  • (2017/08/10) Typings for using egkyron with Typescript
  • (2017/08/10) Incorporated the condition branch into master; it adds the condition constraint parameter to conditionally deactivate the validation
  • (2016/06/09) The React example is in the master.

Implementation state

Currently the core has been implemented, as well as Node and AngularJS integration. An example in React is also added, using the NPM package directly. Integration with React for this example is so simple, that no separate packaging project was made.

Use cases - what was it made for

  1. A single, large model, displayed in many views
  2. The need to separate business logic, in this case the validation rules, from the view
  3. No form validation (e.g. server-side)

Anti-use cases

  1. Simple forms

Design

The concerns in a validation solution addressed by Egkyron are:

  1. The core validation logic
  2. Model introspection strategies
  3. Adapting to different environments (e.g. Node, Browser)
  4. Common validators

Moreover Egkyron takes care of:

  1. Packaging its components for the supported environments

Example usage

// SETUP
//   all the following objects need to be created once and can then be reused
// the validatorRegistry knows the various validators
var validatorRegistry = makeValidatorRegistry();
// the introspector knows how to extract information from the model
var introspector = new ConstructorIntrospector();
// the validator implements the core logic
var validator = new Validator(validatorRegistry, introspector);

// VALIDATE
// the data to validate
var data = ...
// validate and get the results
var results = validator.validate(data);

// USE THE RESULTS
// the overall validity flag
var isValid = results._thisValid && results._childrenValid !== false;
// the error message for the `required` validator of the `data.name` field
var nameErrorMsg = results._children['name']._validity['required'].message;

Building

npm install
bower install
gulp

To clean, simply do:

rm -rf target

Installing to npm

The directory that will get installed is target/dist/node; it contains all the things needed. So, after building, do:

cd target/dist/node
npm publish

Alternatively, you may want to link for development purposes:

cd target/dist/node
npm link