Giter VIP home page Giter VIP logo

vuejs-validators's Introduction

LinkedIn Github Subscribers Views Twitter Followers Count Icon

Hi! My name's Zak & I'm a dev who's worked on startups, fast-growth series D, Fortune 500, and FAANG (Amazon dev) codebases.

  • Develops software across industries, teams, & has experience at just about every scale in which the software life cycle is utilized
  • Self-taught college dropout with a love for sharing the knowledge
  • All-in on Web 3

Zak’s github stats

Sr. Dev at Anaconda Inc.building out the world's most popular data science platform alongside a thriving open source community that empowers students, professionals, & enterprises alike to innovate in groundbreaking real-world business impacting ways thru the power of emerging Web 3 technologies like that of Machine Learning/Artificial Intelligence solutions.

Top Langs



Clean Code Studio

  • ☕️ Code Tips
  • ☕️ Career Advice
  • ☕️ Developer Memes

Join Clean Code Studio Newsletter



Self-Taught Dev Looking to make it a full-time career? Feel free to reach out!

I'm always down to hop on a call with any #codenewbies out there looking for some advice from a fellow self-taught engineer who's been through that journey and made it to some upper levels of tech without a degree. As a 28-day college dropout I can relate to how the information overload can knock you off course on your journey and make it feel like a daunting task to become a full-time dev - but I assure you, No degree is needed to become a full-time dev 😉

If I'm able to help others to better define that path towards becoming a full-time software dev, then I'd love to do so - feel free to reach out via anyone of my socials. I'm always down to hop on a call with #codenewbie's looking to break into the dev career as well as those experienced #webdev's looking to break into the #bigtech dev career. Can't make it an easy journey, but hopefully - if you give me the time - I can at the very least help to simplify the path so you're re-assured that your'e headed in the right direction within your career path.

vuejs-validators's People

Contributors

zhorton34 avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

vuejs-validators's Issues

Correct Validation hasErrors() method

Currently, the errors will return an object with an empty array for each value that has the possibility of holding errors.

The conditional/check needs to confirm that the errors aren't just empty. Currently, even if there are no errors, this check fails.

Update Failing IPv4 Rule

Hi zhorton34, I just found a case about IPv4
192.168.1.023 => Fail
192.168.1.23 => Pass
Last number cannot start with 0
You can consult this regex: /^(?!0)(?!.*.$)((1?\d?\d|25[0-5]|2[0-4]\d)(.|$)){4}$/ to fix this

Update Failing Not Within Rule

Update Failing Not Within Rule

import validator from 'vuejs-validators';

let form = { pencil: '2a'};
let rules = { pencil: 'not_within:notebook,pencil,marker,sharpie,whiteboard' };

validator(form, rules).validate();

Translations

  • Add Translations For Sites/Forms That Need To Display Multiple Languages
  • Add Translations For All Default Global Rule Messages

Rules Regex is wrong type (string)

image

typeof parameters[0] is string, must object

to fix this issue:
regex: ({ value, parameters }) => new RegExp(parameters[0]).test(value),

Add macro and forceMacro methods on Validator

Validator Macros

  • Validator Macro Method (May already exist)
  • Validator ForceMacro Method
  • Validator LocalMacro Method
  • Validator ForceLocalMacro Method

Error Message Macros

  • Macro
  • LocalMacro
  • ForceMacro
  • ForceLocalMacro

Detailed testing is a must!!!!

Validation Test Coverage

Validation Rules Test Coverage Is Solid

The Helper Functions, Validator itself, as well as Factory, and ParseRule test coverage is a little spotty.

--------------------|----------|----------|----------|----------|-------------------|

File % Stmts % Branch % Funcs % Lines Uncovered Line #s
All files 52.61 26.38 47.93 67.72
dist 49.08 29.15 47.25 63.16
factory.js 100 68.75 100 100 8,9,10,11
index.js 100 83.33 100 100 6,7
messages.js 100 100 100 100
parseRule.js 55.26 20 75 87.8 7,9,15,17,21
rules.js 18.03 5.08 9.68 26.19 ... 50,151,153,156
validator.js 63.13 36 59.46 76.24 ... 93,194,196,230
dist/helpers 59.04 26.67 36.67 71.19
isArray.js 50 100 0 50 10
isBigInt.js 50 0 0 50 10
isBool.js 50 100 0 50 10
isBooly.js 80 0 0 80 17
isEmpty.js 66.67 45.45 75 88.89 21
isFalsy.js 33.33 100 0 33.33 10,11
isNotEmpty.js 100 100 100 100
isNotNull.js 100 100 100 100
isNotNumeric.js 66.67 0 0 66.67 13
isNotUndefined.js 75 41.67 75 100 9
isNull.js 50 0 0 50 10
isNumber.js 100 100 100 100
isNumeric.js 100 66.67 100 100 15
isObject.js 30 0 0 60 3,17
isString.js 50 100 0 50 4
isTruthy.js 33.33 100 0 33.33 10,11
isUndefined.js 12.5 0 0 33.33 9,12
variadic.js 75 50 100 75 11
dist/methods 32.76 16.07 54.55 75
parseData.js 32.76 16.07 54.55 75 7,9,11,13,28
src 88.37 66.67 77.27 87.8
messages.js 100 100 100 100
rules.js 88.1 66.67 77.27 87.5 18,19,21,28,36
src/helpers 61.22 10 26.67 66.67
isBigInt.js 50 0 0 50 11
isBool.js 100 100 100 100
isBooly.js 100 100 100 100
isEmpty.js 25 0 0 37.5 14,15,16,18,20
isFalsy.js 100 100 100 100
isNotEmpty.js 66.67 100 0 66.67 12
isNotNull.js 50 0 0 50 11
isNotNumeric.js 66.67 0 0 66.67 9
isNotUndefined.js 50 0 0 50 11
isNull.js 50 0 0 50 11
isNumber.js 50 100 0 50 8
isNumeric.js 75 0 0 75 10
isString.js 50 100 0 50 2
isTruthy.js 100 100 100 100
isUndefined.js 50 0 0 50 11
-------------------- ---------- ---------- ---------- ---------- -------------------

Rule Prototype And Rules As Callbacks

  • Create Dedicated Rule Prototype
  • Clean Up src/parseRule.js to use dedicated Rule Prototype
  • Allow rules to be passed as callback functions
validator(data, {
   'title': [
       'min:5',
       'required', 
       (attribute, value, parameters, validator) => ({
               rule: value => value.toUpperCase() === value,
               message: `${attribute} must be uppercase`
        })
   ]
}, messages);

Add macro method to errors prototype and setup docs for extending errors api with custom error component instance and methods.

form.errors().macro(
'setComponent',
function (is) {
this.is = is;
this.hasComponent = fn();

 this.component = function(...args) {

       if (typeof args === undefined) {
            return this.list().map(message => `<component :is="${this.is}" :message="message" />`)
       Let properties = args;
  }

// else group of items if multiple params passed.

// else one error component if single param passed
});

Common & Flow Of Control Rules

  • Bail
    (Don't validate all rules, after the first failure simply fail and return)

  • Sometimes
    -(Only validate the given field if it is present)_

  • Filled
    (If present, confirm that the given field is not empty)

  • Present
    (Field can be empty, but must exist within the form)

  • Nullable
    (Field is allowed to be null)

  • Size
    The field under validation must have a size matching the given value. For string data, value corresponds to the number of characters. For numeric data, value corresponds to a given integer value (the attribute must also have the numeric or integer rule). For an array, size corresponds to the count of the array. For files, size corresponds to the file size in kilobytes.

  • Exclude If

  • Exclude Unless
    Examples:

{
   // Validate that a string is exactly 12 characters long...
   title:  'size:12',
   

   // Validate that a provided integer equals 10...
  seats: 'integer|size:10',

  
  // Validate that an array has exactly 5 elements...
  tags: 'array|size:5',

  // Validate that an uploaded file is exactly 512 kilobytes...
  'image': 'file|size:512',
}

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.