Git Product home page Git Product logo

devsupporters / volder Goto Github PK

View Code? Open in Web Editor NEW
101.0 5.0 8.0 4.19 MB

volder is powerful Object schema validation lets you describe your data using a simple and readable schema and transform a value to match the requirements

Home Page: https://volder.vercel.app

License: Apache License 2.0

JavaScript 99.63% Shell 0.37%
testing-tools testing-tool npm object-checker validator schema schema-builder validation validation-library javascript

volder's People

Contributors

aditya14112006 avatar alguerocode avatar nikkuv avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

volder's Issues

pattern config and transform config in every type

pattern config that accept a function that validate any type and return boolean value; any type throw an error
transform config that accept a function that transform and change the value of that data and return it; use it in the end of validation

strict mode

strict mode option that wil throw an error when the validation is not true

startWith config

add start with the config to validate string starting with specific startWith value
like

const schema = new Volder({
name:{
type:String,
startWith:"D."
}
})

volder types

volder types should be a function that validate the data and return boolean

// all of this validate a string type
1 - Email => email value
2 - UUID => uuid value
3 - CreditCard => creditcard valuee
4 - Domain => domain value
5 - URI => uri value
6 - IPAddress => ipaddress value
7 - base64 => base64 value

volder events

add volder events
Volder.pre((input) => return input with edited);
Volder.after((input) => return input with edits);

this volder events trigger when run validate function volder.validate(input)

  • pre function trigger pre validating input
  • after function trigger after validating input

avoided

add avoided array of types for null case

includes option config

the new includes option

the includes option validate if string and array has the specifice thing in include property , and for object include that name of property

array type validation configs

1 - arrayOf(array of types) => array must contain in what you define
2 - unique(boolean) => should array to be unique or not
2 compat(function) => Removes falsey values from the array. Providing a rejecter function lets you specify the rejection criteria yourself.

write CONTRIBUTE.md

write contribute.MD file for new contributors to teach him the instruction and how to contribute

volder schema options

generate unique id
generate current data that the object is validate
generate timestamp

new major features

volder types

support volder types like Email, URL, UUID

import { Volder, Email } from 'volder'
const EmailSchema  = new Volder({email: { type:Email, min: 100, required:true}});

default config

specifies the default value of that option if not required
default(depend i what you define in the type config)

max and min

convert the options max and min in string and array
to min => minLength
to max => maxLength

trim

add trim function to string validating
the function trim the string before validating it

addErrorMessage function when validating data

whne you isValid feature function add the addErrorMessage function to add an error message by bassing

  • boolean . to execute adding error message
  • string it should regular message or custom
  • obeject and his key to add the message

custom error message

like
{
type: [Array, 'type should be array]
min: [2, 'should be at least 2']
}

String type validation

1 - alphanum(boolean) => requires to be the value cotains only [a-z] [A-Z] [0-9]
2 - convertCase(string) => 'lower' or 'upper'
3 - lowerecase(boolean) => should be in lowercase otherwise error
[] uppoerecase (boolean)=> should be in uppercase otherwise error
5 - matches (regex pattern)=> regex

boolean type validation

1 - switch(boolean) => convert the truthy to true
2 - sensible(boolean) => convert the truthy or falsy value to real boolean valueallow the unreal boolean value the advantage of the state
3 - state (boolean) => to check if the value is truthy or falsy
///////// mybe improve the boolean type

arrayOf config

add of property option to strict the array of (string or numbers or booleans, objects, array)

const schema = new Volder({
arrayOfString:{
type:Array,
arrayOf:String
})

example section

don't forget to add example section in volder docs that shows code example about Volder schema

Number type validation

1 - integer(boolean) => number should be an integer not float
2 - float(boolean) => number should be an float not integer
3 - round(boolean) => round the number to closest integer
4 - fixed(number) => fixed number of decimal value in a number
5 - precision(number) => specifies the maximum number of decimal places
6 - sign('nigative' | 'positive' ) => specifies the sign in the number should be

strict key property in input

sometimes we want to strict key property in input,
by that we remove the unused key validation issue
and you can fix
TypeError: Expected a number but received a undefined at maxLength property
when using min or max config in array or string

Object type validation config

1 - with(array of strings) => define the keys that required exist in object
2 - without(array of strings) => reversing the top config
3 - instance(constructor) => value should be an instance of that constructor

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.