0.0.6 • Published 1 year ago

@harv46/valid-input v0.0.6

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

valid-input

This npm package includes an input box with built-in validation and displays errors.

Valid-Input demo

Installation

npm install @harv46/valid-input

You can import the library directly to components

<script>
import { VInput } from "@harv46/valid-input";
import "@harv46/valid-input/dist/style.css";
</script>

Basic usage

<template>
    <div>
        <VInput v-model="inputValue" :validationType="`email`">Email</VInput>
    </div>
</template>

<script>
import { VInput } from "@harv46/valid-input";
import "@harv46/valid-input/dist/style.css";

export default {
    components: {
        VInput,
    },

    data() {
        return {
            inputValue: "",
        };
    },
};
</script>

Props

PropDescriptionDefault
typeInput typetext
minLengthMinimum length validation0
maxLengthMaximum length validation500
requiredRequired validationfalse
validationTypeType of validation using
regexValidation regex - if validationType = 'regex' See usage
placeholderThe input placeholder attribute

validationType values

  • email - Accepts valid email addresses.
  • alpha -Accepts only alphabet characters.
  • alphaNum - Accepts only alphanumerics.
  • numeric - Accepts only numerics. String numbers are also numeric.
  • regex - Accepts valid regular expressions, also should provide :regex property.

Regex example

<template>
    <div>
        <VInput
            v-model="inputValue"
            :minLength="4"
            :maxLength="10"
            :placeholder="Username"
            :validationType="`regex`"
            :regex="/[a-z]+/g"
            >Username</VInput
        >
    </div>
</template>

<script>
import { VInput } from "../../src/main";
import "../../dist/style.css";

export default {
    components: {
        VInput,
    },

    data() {
        return {
            inputValue: "",
        };
    },
};
</script>
0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago