0.5.0 • Published 4 years ago

@algonaut/algo-validation-agent v0.5.0

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

algo-validation-agent

algonaut codecov.io MIT License

A dead simple validation library for inputs into the Algorand JS SDK

Why use this library?

While the existing Algorand JS SDK validates address signatures well, it does not fully validate individual fields or payloads before sending them along to the chain. Integrated with your front-end framework and validation library of choice, you'll be able to prevent bad transactions from reaching the chain when collecting input from your users and give them feedback to course correct.

If you're building javascript SPAs, these validations are useful to offload the larger dependency cost to a backend SDK of your choosing without needing to pull the entire JS SDK into your browser-based app. Basically, you want to validate your form inputs so the chain doesn't have to!

Features

  • Field validators for common transaction actions
  • Payload object validators for asset transactions
  • Minimal dependencies
  • CommonJS, ESmodule, and browser import options

Documentation

API Documentation

Usage

npm install @algonaut/algo-validation-agent

Import the library in your client-side or node application to validate inputs:

import { core } from '@algonaut/algo-validation-agent/dist/algo-validation-agent.cjs';

core.isAlgorandAddress('FOO'); // -> false
core.isAlgorandAddress(
  'CINCNAPB2RLDUCS3EVDLURZZD742TMWRQEZ4CBEWF2QMOYXMH6RWRZEIEA'
); // -> true

Alternatively, you can use the browser-ready bundle provided in the package:

<!-- Minimized -->
<script src="dist/algo-validation-agent.iife.min.js"></script>

<!-- Standard -->
<script src="dist/algo-validation-agent.iife.js"></script>

Contributing

# install dependencies
npm install

# live preview documentation
npm run docs:dev

# run tests and watch file changes
npm run test:watch

# build all files and docs
npm run build:all

License

MIT