-
-
Notifications
You must be signed in to change notification settings - Fork 0
Adding preconstructed condition checks. #7
Comments
|
String specific
|
Logical expressions
|
|
The use of custom and composit types in the native conversion method of This is not helpful when forming complex options, if turned out to be wrong would be drastically different to what the function explains at a baseline. (min, max) => (value) => min < value && value < max
// ~.predicate.inRange(min, max) -> value -> boolean # theoretical implementation
// (min, max) -> (value) -> min < value < max There may be a possibility to provide a predicate class builder instead of the structure intended, but in doing so would make the library itself much harder to understand and implement. |
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...
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 moveoptions.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 text was updated successfully, but these errors were encountered: