Skip to content

Nested composed validators do not curry as expected. #54

Description

@jaridmargolin

Nested composed validators do not curry as expected.

* This may just be a misunderstanding of the lib is intended to work.

Expected:

// imagine I have created a validator `containsNoNumbers`
const isName = composeValidators(hasLengthBetween(2, 32), containsNoNumbers)
composeValidators(isRequired, isName)('First Name')
composeValidators(isRequired, isName)('Last Name')

isRerquired works as expected and allows the field to propagate through. isName however always returns a function. I can fix the issue by doing something like:

const isName = composeValidators(hasLengthBetween(2, 32), containsNoNumbers)
composeValidators(isRequired, isName('First Name'))('First Name')
composeValidators(isRequired, isName('Last Name'))('Last Name')

but it seems as though the composed validator should work exactly the same as a created validator.

The composed validator is also curried and takes the same arguments as an individual validator made with createValidator.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions