Skip to content
This repository was archived by the owner on Jun 6, 2021. It is now read-only.
This repository was archived by the owner on Jun 6, 2021. It is now read-only.

Adding preconstructed condition checks. #7

@sudojunior

Description

@sudojunior

It's understandable if the declaration of types is sometimes quite tricky, so making use of predefined checks from the module itself would be quite handy. But the choice is to either include it with the root export or create a new file which the dependant can import themselves...

This issue is intended for a first time contributor.

  • If you want to contribute by adding any of these methods, please do not feel pressured to adding all of them at once. I would appreciate it if you gave others the opportunity. ❤️
  • And if you do add one or more, you may reference it but please do not use the fix or closes keywords. I will handle that on my own accord.

Copied from the README.md located on dev branch at the time of writing.

  • validate.checks[key: string](value?: any) => boolean
  • validate.checks.exists(value?: any) => boolean
  • validate.checks.optional(value?: any) => boolean - Possiblity to move options.optional to this predicate...
  • validate.checks.truthy(value?: any) => boolean
  • validate.checks.int(value: int?) => boolean

Type bound

This would make use of predicate construction by passing the context of the previous scope through to the child.

  • validate.checks.min<T>(n: T) => (value: T?) => boolean
  • validate.checks.max<T>(n: T) => (value: T?) => boolean
  • validate.checks.between<T>(low: T, high: T) => (value: T?) => boolean

    The generic of T would infer that the accepted type has already been checked or is yet to be checked, but will default to that of primative number.

    • Could also be applied to string or Array when making use of the .length property. Either would work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions