Giter Club home page Giter Club logo

leaf-validator's People

Contributors

dependabot[bot] avatar stewartanderson3 avatar stewie1570 avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

daebowale

leaf-validator's Issues

Diff function modification

Diff currently builds complex objects by setting root properties to a whole complex object. Each diff should be scoped all the way to a single leaf.

Create useLoadingState

const [isLoading, doLoad] = useLoadingState(loadingFunction);

doLoad type definition from loadingFunction type def.

Remove jest-environment-jsdom-sixteen

After the next release of react-scripts you should be able to remove --env=jest-environment-jsdom-sixteen from scripts and remove jest-environment-jsdom-sixteen from devDependencies.

useValidationModel should useMountedStateOnly

Validators can be async. As such, they could resolve after the component is un-mounted and cause un-mounted state change warnings/errors.

export function useValidationModel(): ValidationModel {
const [validationModel, setValidationModel] = useState<any>({});
return {
set: setValidationModel,
get: (location: string) => validationModel[location] || [],
getAllErrorsForLocation: location => filteredObjectToArray(validationModel,
{
keyFilter: key => key.startsWith(location),
mapper: (key, value) => ({ location: key, messages: value })
})
.filter(error => error?.messages?.length)
}
}

useMountedOnlyState instead of useState.

Update link in readme

The link to example diff usage that navigates to the mongo/leaf-validator example should link directly to the line that calls the diff function:

Like this:
Example

getAllErrorsForLocation should group results by location

Example from the example app:

[
    {
        "location": "deferredAsyncValidation",
        "messages": [
            "Value is required"
        ]
    },
    {
        "location": "asyncValidation",
        "messages": [
            "\"undefined\" is not valid."
        ]
    },
    {
        "location": "deferredAsyncValidation",
        "messages": [
            "\"undefined\" is not valid."
        ]
    }
]

deferredAsyncValidation has two objects because there are two namespaces for those validators (deferred and not deferred).

README edits

  • Encourages normalization - link to Redux docs.

  • Encourages best practices documented by Redux (but without as much overhead since reducers are implemented declaratively).

  • Merge

  • Release (v3.6.2)

Add readme documentation

  • Include documentation about validation model queries.
  • Find some full stack examples to include.
  • Split-up the docs and organize readme files into the code file system.

Create useMountedOnlyState

Same as use state but state setters turn into No Ops when the component is not mounted.

useLoadingState should use this.

Async validation change

Validation could be called multiple times before the first validation resolves. Only the latest validation results should be applied to the validation model.

Refactor

async function start<T>(theOperation: Promise<T>): Promise<T> {
if (options?.defer) {
timer.current = setTimeout(() => setIsLoading(true), options.defer)
}
else {
setIsLoading(true);
}

This can just await the configured amount of time before setting loading to true since the operation promise is already inflight when the hook function is invoked.

  • Refactor to promise async composition instead of callbacks.

  • Merge

  • Release (v3.6.2)

Fix anchor link

[Get & Set pure functions](#get-&-set-pure-functions) works in VSCode but not GitHub or NPMJs.com

Documentation updates

  • Split-up the docs and organize readme files into the code file system.
  • Include documentation about validation model queries.

Replace Travic-CI with GitHub Actions

It would be nice to have source control & ci in one cohesive place. Plus the travis-ci badge is randomly showing failed even though its passing and it is starting to piss me off.

Create a separate deferredValidators property

This attribute should only run the validators after some fixed amount of time after the last target value change. The validators should not be run again until they've all resolved.

Create a diff function

Create (& export) a function that can take the current model, the original model and return a list of key-value-pairs. The keys being progressed value locations and the value being the current value for that location.

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.