Skip to content

CustomValidator return type adjusted in typescript#2454

Merged
hueniverse merged 1 commit intohapijs:masterfrom
zuozp8:custom-validator-type
Oct 24, 2020
Merged

CustomValidator return type adjusted in typescript#2454
hueniverse merged 1 commit intohapijs:masterfrom
zuozp8:custom-validator-type

Conversation

@zuozp8
Copy link

@zuozp8 zuozp8 commented Aug 25, 2020

trying to do

const xValidator: CustomValidator<string> = (value, helpers) => {
  if (!value.startsWith('x')) {
    return helpers.error('string.x')
  }
  return value
}

results in error

TS2322: Type '(value: string, helpers: CustomHelpers<any>) => string | ErrorReport' is not assignable to type 'CustomValidator<string>'.

@hueniverse hueniverse self-assigned this Oct 24, 2020
@hueniverse hueniverse added bug Bug or defect types TypeScript type definitions labels Oct 24, 2020
@hueniverse hueniverse added this to the 17.2.2 milestone Oct 24, 2020
@hueniverse hueniverse merged commit 760273b into hapijs:master Oct 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Bug or defect types TypeScript type definitions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants