1.1.0 • Published 3 years ago

@voire/eth-validation-rules v1.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

@voire/eth-validation-rules

A bunch of additional VeeValidate rules for eth addresses' validation.

Provided rules

exportdescription
hexIf value is a hex string, e.g. ab12AB
hexPrefixedIf value is a 0x-prefixed hex string, e.g. 0xab12AB
ethAddressIf value is a valid ethereum address, i.e. is a 0x-prefixed hex string and 42 symbols long
nullEthAddressIf value is an ethereum zero address, i.e. 0x000..00
notNullEthAddressIf value is an ethereum address, but not zero address, e.g. 0xABC..90

All checks are case-insensitive.

Usage

  1. Define validators for the app.

    import { defineRule } from 'vee-validate'
    import { ethAddress } from '@voire/eth-validation-rules'
    
    // Use any key you find suitable
    defineRule('eth_address', ethAddress)
  2. Use it within vee Field's rules

    <script setup lang="ts">
    import { Field } from 'vee-validate'
    </script>
    
    <template>
      <Field name="address" rules="eth_address" />
    </template>

See detailed VeeValidate docs about custom rules' defining and usage.