GithubHelp home page GithubHelp logo

m10rten / validatees Goto Github PK

View Code? Open in Web Editor NEW
6.0 1.0 2.0 821 KB

✅Validation library for ES6+ projects

Home Page: https://www.npmjs.com/package/validatees

License: MIT License

TypeScript 100.00%
ecmascript es6 javascript javascript-library node nodejs typescript validation falsy nullish

validatees's Introduction

validatees's People

Contributors

albertjannap avatar dependabot[bot] avatar m10rten avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

validatees's Issues

IsExtendable

Is your feature request related to a problem? Please describe.

A clear and concise description of what the problem is:
User input an Array or Object and check if it has been frozen / closed for modification.

Input

What parameters will be passed in or required?
And what is the prefered type of input?
Value: Array or Object or Object based instance like String or Number or Function.

Output

What will be the expected output?
And what type does it have?

Returns boolean.

Additional context

Add any other context or code-examples about the feature request here.

IsExtendable({}); // true.
Const obj = new Object()
obj.freeze(); // or equivalent
IsExtendable(obj); // false.

Incorrect version check CI

Whenever a version is on: lets say: 0.1.0 on NPM
And we try to push a package.json with 0.1.0, it will not fail because it is up to date with NPM.

To fix this: we need to make a new file in the root like we did with replace script file.
then run this in the CI file.

Port check

Is your feature request related to a problem? Please describe.

  • A clear and concise description of what the problem is.

check if a port is running on localhost

Input

  • What parameters will be passed in or required?
  • And what is the prefered type of input?

cli command

Output

  • What will be the expected output?
  • And what type does it have?

either called as function and returns boolean / throws on ci
Additional context

  • Add any other context or code-examples about the feature request here.

requires node

Callbacks to VListener

Option to add multiple callbacks for the VListener.
like this:

vListener.registerArrayListeners([
  { array: arr1, callbacks: [isTruthy, isValidDate], { strict: true } },
  { array: arr2, callback: isFalsyExtended, { condition: false } },
]);

IsValidDate

Check if the given date format in string or new Date type, is a valid date.
Returns boolean.
Input value: Date | string.
Optional input for format: default to dd-mm-yyyy.

Example:
IsValidDate("12-2-22"); // true

IsRegexMatch

Check if given input matches with a preset of regex sets, such as only string, only specialChars, only numbers, or mixed.
Input: text, string to check on regex.
Optional input with default: regex pattern.
Can be combined to test for text or/and numbers or/and special characters.

Like this:
isRegexMatch("abc", [PATTERNS.STRING, PATTERNS.SPECIALCHARS])

naming of optional parameters can be improved.

IsValidPassword

Checks if given string matches the given pattern.
Input: password
Optional input: password check parameters: numbers, specialChars, length.
Returns boolean.

validatees array validator

Is your feature request related to a problem? Please describe.

A clear and concise description of what the problem is.

Register a listener to changes on every array and validate the input, if input is not valid it should not be added to the array.
this way users do not have to validate each time they want to add something to the array, just add a listener and some patterns or functions(from validatees) and never touch it again.
Input

What parameters will be passed in or required?
And what is the prefered type of input?

patterns or callback functions, can be from validatees, can be user-made.
Output

What will be the expected output?
And what type does it have?

None, this is a "worker" like instance.
idea to throw error when validation fails.
idea to return full array when validation is OK.

Additional context

Add any other context or code-examples about the feature request here.

register the instance on startup, never touch it again.

validatees.registerListener([{array1, isTruthy},{array2, isString}, {object1, {password: isValidPassword, email: isValidEmail}]);
// for example, many ways to do this.

validatees.registerArrayListener(isTruthy);
// truthy values may get added in this example.
naming can be improved.

IsValidEmail

Check if given string object is a valid string for an email construction.
Input: string, like new String(), String and string.
Returns boolean

IsValidPhoneNumber

Validates a phone number based on the incoming input.
Input: number or string, begin with 0 means string.
Optional parameter for pattern/ length with an object, defaulted.

Returns boolean.

Example:
IsValidPhoneNumber("075123456"); // true

isRegExp

Is your feature request related to a problem? Please describe.

  • A clear and concise description of what the problem is.
    isRegExp should check if the input is a regex expression
    Input

  • What parameters will be passed in or required?

  • And what is the prefered type of input?
    any input is allowed

Output

  • What will be the expected output?
  • And what type does it have?
    returns boolean

Additional context

  • Add any other context or code-examples about the feature request here.
    it should check carefully that a string passed in, is not a regExp
    isRegExp("/0-9/"); //false

`isFalsyExtended` not working properly

When passing an object with values that are undefined or null, it should not return false because thats not how this function should work.

In that way an option parameter can be passed to tell the function to either do or do not behave a certain way.

IsUnique

Is your feature request related to a problem? Please describe.

A clear and concise description of what the problem is.

Checking if a variable is unique within an array can be a struggle.
That is why there will be this function: isUnique where users can pass any array and value equal to the arrays typed interface.

Input

What parameters will be passed in or required?
And what is the prefered type of input?

An array to check on.
A value to check with.

Output

What will be the expected output?
And what type does it have?

boolean

Additional context

Add any other context or code-examples about the feature request here.

When using this function, the user must know what the return type is, and what it will check on: whatever put in as array, the value given as 2nd.
Example:

isUnique([{a:1}, {b:2}], {c:3}); // true
isUnique(["hello", "world"], "hi"); // true
isUnique({a:1, b:"b"}, {a: "b"}); // true
isUnique({a:1, b:"b"}, {a: "1"}); // true
isUnique({a:1, b:"b"}, {b: "b"}); // false
// etc etc

Map validation listener

Is your feature request related to a problem? Please describe.

  • A clear and concise description of what the problem is.

Input

  • What parameters will be passed in or required?
  • And what is the prefered type of input?

same as array listener, add map listeners to validate on arrays

Output

  • What will be the expected output?
  • And what type does it have?

boolean value and .set when OK

Additional context

  • Add any other context or code-examples about the feature request here.

isDate

Is your feature request related to a problem? Please describe.

  • A clear and concise description of what the problem is.
    isDate, to check if an input is part of the Date type, or instanceof Date.

Input

  • What parameters will be passed in or required?
  • And what is the prefered type of input?
    any type should be allowed.

Output

  • What will be the expected output?
  • And what type does it have?
    returns boolean when input is date validated.

Additional context

  • Add any other context or code-examples about the feature request here.

Extended TS support

Is your feature request related to a problem? Please describe.

  • A clear and concise description of what the problem is.

The typescript compiler does not compute with the checks, so need to return valid return values other then boolean.

Input

  • What parameters will be passed in or required?
  • And what is the prefered type of input?

None
Output

  • What will be the expected output?
  • And what type does it have?

Variable is {} for example
Additional context

  • Add any other context or code-examples about the feature request here.

Naming of package

I'm thinking of renaming this package to something more catchy and easier to expand.
for example with CLI of more utils other then validation.

first thought: @jelly/core

packages then could contain: CLI, serverside config, test tools, validation, tree builder.
without having 1 massive package, users can choose what they need.

Testing the CLI functionality with jest

Currently the CLI is being tested by hand and good faith.

To improve this it should be tested with jest within the current test folder.

This most likely will require a folders structure change for the test folder since we now have lib and cli folders.

Remake to have /core and @types

Types take up a lot of space in the package.
To improve this, types need to moved to the @types/validatees package to be created seperately.

creation of a validatees/core package/folder is to split te core feature from the less relevant feature.

users should be able to choose either the validatees/core or the full validatees version.
@types/validatees should include all, and there will be no @types/validatees/core because it will be not worth it.

isSymbol

Is your feature request related to a problem? Please describe.

A clear and concise description of what the problem is.

isSymbol , even though not very well known, symbols are part of the node/javascript stack and mostly used in dated versions of EcmaScript.

Input

What parameters will be passed in or required?
And what is the prefered type of input?

any parameter

Output

What will be the expected output?
And what type does it have?

boolean

Additional context
Add any other context or code-examples about the feature request here.

CLI

The CLI for checking version, help command, etc etc

isValidUrl

Is your feature request related to a problem? Please describe.

  • A clear and concise description of what the problem is.

Input

  • What parameters will be passed in or required?
  • And what is the prefered type of input?
    any, string preffered, but URL allowed.

Output

  • What will be the expected output?
  • And what type does it have?
    boolean

Additional context

  • Add any other context or code-examples about the feature request here.
    should check on http or https and a valid TLD extension like .com
    www. is not required.

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.