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

@devsun/vue3-validation-inputs

v0.0.1

Published

vue3-validation-input is very simple and tiny library for vue3.

Downloads

1

Readme

Vue3 Validation Input

vue3-validation-input is very simple and tiny library for vue3.

It was based on Vue3, typescript, and composition API with <setup>

Setup

npm i @devsun/vue3-validation-input

And dependencies to your main.ts:

import Vue3ValidationInput from '@devsun/vue3-validation-input';

const app = createApp({...});
app.use(Vue3ValidationInput);

Usage

Component

You can use <validtation-input />, <validtation-checkbox/>, <validtation-radio/> ,<validtation-select/>

use validation component:

<validation-input
  v-model="form.name"
  required
  invalid-required-msg="Please enter your name"
>
</validation-input>

Validation

You can validate data using API.

ref should be added for eash component.

use Composition API style:

<script lang="ts" setup>
import { IValidation } from '@devsun/vue3-validation-input';

const $validation = <IValidation>inject('$validation');
const nameRef = ref(null);

function validate() {
  const result = $validation.validate([nameRef]);
  // if the result is true, validation comleted, and if it is false, invalid.
}
</script>
<template>
  <validation-input
    ref="nameRef"
    v-model="form.name"
    required
    invalid-required-msg="Please enter your name"
  >
  </validation-input>
</template>

Attributes

| Name | Type | Default | Target | Description | | ------------------ | -------------------------------------------------------------------------------------------------------- | ------- | ------------------------------ | -------------------------------------------------------------------------- | | ref | String | | Input, Checkbox, Radio, Select | used for validation API call | | v-model | String, Number, Boolean, Array | | Input, Checkbox, Radio, Select | Required | | required | Boolean | false | Input, Checkbox, Radio, Select | | | disabled | Boolean | false | Input, Checkbox, Radio, Select | | | reactive | Boolean | true | Input, Checkbox, Radio, Select | Whether to validate when input, blur event occurs | | showInvalidMsg | Boolean | true | Input, Checkbox, Radio, Select | Whether to show invalid message under the input | | format | String, RegExp | | Input | | | invalidRequiredMsg | String | | Input, Checkbox, Radio, Select | Displayed message when required attribute is true and no value entered | | invalidFormatMsg | String | | Input | Displayed message when format attribute is exsits and invalid format | | type | 'text' | 'password' | 'number' | 'date' | 'datetime-local' | 'month' | 'week' | 'time' | 'color' | text | Input | | | placeholder | String | | Input, Select | | | maxlength | String, Number | | Input | | | min | String, Number | | Input | Minimum value when type is number, date, datetime-local, month, week, time | | max | String, Number | | Input | Maximum value when type is number, date, datetime-local, month, week, time | | options | Array | | Checkbox, Radio, Select | RequiredOptions of the checkbox, radio, select | | labelKey | String | | Checkbox, Radio, Select | RequiredKey used as label in the option | | valueKey | String | | Checkbox, Radio, Select | RequiredKey used as value in the option | | mode | 'default' | 'button' | default | Checkbox, Radio | |

API

validateData

(refs: Ref[]) => boolean

// if result is true, validation completed, if it is false, exist invalid data.
const result = $validation.validateData([nameRef, emailRef]);

validateDataRef

(refs: Ref[]) => boolean

// Return invalid refs
const invalidRefs = $validation.validateDataRef([nameRef, emailRef]);

// You can use the invalid message as a notification like alert
// and  focus on invalid form
if (invalidRefs.length > 0) {
  window.alert(invalidRefs[0].value.invalidMsg);
  invalidRefs[0].value.focus();
  return;
}

Plugin Options

Configure the plugin using a global options:

app.use(Vue3ValidationInput, {
  // provide / inject with this key.
  key: '$validation',

  // Whether to validate when `input, blur` event occurs
  reactive: true,

  // Whether to show invalid message under the input
  showInvalidMsg: true,
});