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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@splitty-test/validation

v0.2.9

Published

This is a validation library for Vue 3 that is both simple but powerful.

Downloads

68

Readme

Splitty Test Form Validation

This is a validation library for Vue 3 that is both simple but powerful.

Install

Install with NPM:

$ npm install @splitty-test/validation

Usage

Using Composition API...

In the script:

<script setup>
import { ref } from 'vue';
import { FieldValidation, useFormValidator, rules } from '@splitty-test/validation';

const login_form_validator = useFormValidator();
const email = ref('');
const password = ref('');

async function handleFormSubmit() {
    // Validate the form fields
    const is_valid = await login_form_validator.validate();

    if (is_valid) {
        // DO THE REST OF THE FORM SUBMIT STUFF
    }
}

export {
    email,
    password,
    rules,
    handleFormSubmit
}
</script>

In the template:

<template>
    <div class='login-form'>
        <div class='email-field'>
            <FieldValidation name="email" v-model="email" :validator="login_form_validator" :rules="[rules.required, rules.email]">
                <input name="email" v-model="email">
            </FieldValidation>
        </div>
        <div class='password-field'>
            <FieldValidation name="password" v-model="password" :validator="login_form_validator" :rules="[rules.required]">
                <input name="password" v-model="password">
            </FieldValidation>
        </div>
        <div class='submit-button'>
            <input type="button" @click="handleFormSubmit()">Login</input>
        </div>
    </div>
</template>

FieldValidation Component Properties

  • name (String) - Required: A unique name for the field that is used intenally to reference the field being validated.
  • v-model (any) - Required: The value that is being validated.
  • validator (FormValidator) - Required: The instance of the FormValidator that the field is attached to.
  • rules (Rule[]): - Conditionally Required Rules are a list of functions used to validated the value in the v-model. It is only required on the FieldValidation component if they weren't defined when creating the FormValidator.

Making Custom Rules

Each rule is a simple function that takes the v-model value as the first argument and returns an error message string if there is an issue or null if the value passes validation. If a string message is returned, it will be added to the errors array. You can create custom rules with arguments as long as the function then returns a function with the value passed as the first argument. Make sure you are passing the rule definition (without parenthesis) to the rules array. You can use async functions as well.

Example:

<script setup>
// The value has to equal 'foo'
function myCustomRule(value: string) {
    if (value !== 'foo') {
        return 'The value MUST equal foo!';
    }
    return null;
}

// The value must be with a range
function myCustomRuleWithArguments(min: number, max: number) {
    return (value: number) => {
        if (value < min || value > max) {
            return `The value must be between ${min} and ${max}`;
        }
        return null;
    };
}

export {
    myCustomRule,
    myCustomRuleWithArguments
}
</script>

Then in the template:

<FieldValidation name="pity" v-model="who_do_i_pity" :validator="myValidator" :rules="[myCustomRule]">...</FieldVaidation>
<FieldValidation name="age" v-model="age" :validator="myValidator" :rules="[myCustomRuleWithArguments(18, 50)]">...</FieldVaidation>