1.0.7 • Published 11 months ago

z-validify v1.0.7

Weekly downloads
-
License
-
Repository
-
Last release
11 months ago

z-validify

z-validify is a lightweight client-side payload validation library designed for React applications. This library ensures that your state objects are validated efficiently, minimizing load on the backend by performing validations on the client side.

Features

  • Lightweight: At just 1.1 kB, z-validify adds minimal impact to your bundle size.
  • Simple API: Provides a straightforward function to validate state objects.
  • Automatic Detection: Automatically detects and reports null, undefined, and empty string values in state objects.
  • Ease of Use: Quickly integrate into your project to enhance form validations.

Installation Install z-validify via npm: npm install z-validify

API

  • validatePayload(state)
  • Description: Validates a state object to ensure all fields are non-null, defined, and non-empty.

Parameters:

  • state (object): The state object to validate.
  • Returns: An object containing:
  • isValid (boolean): Indicates if the state object is valid.
  • message (string): A message indicating which fields, if any, are invalid.

Installation

npm install z-validify


Usage : 

import validatePayload from 'z-validify'

const state = {
    name: 'John Doe',
    age: 30,
    email: 'john.doe@example.com',
    address: '' // This field is empty
}

const validation = validatePayload(state);

if (!validation.isValid) {
    console.error(validation.message);
} else {
    console.log('State is valid!');
}
1.0.7

11 months ago

1.0.6

11 months ago

1.0.5

11 months ago

1.0.4

11 months ago

1.0.3

11 months ago

1.0.2

11 months ago

1.0.1

11 months ago

1.0.0

11 months ago