Skip to content

feat: add CustomValidator#7051

Merged
cannikin merged 3 commits intoredwoodjs:mainfrom
tsugitta:feat/validate-with
Dec 12, 2022
Merged

feat: add CustomValidator#7051
cannikin merged 3 commits intoredwoodjs:mainfrom
tsugitta:feat/validate-with

Conversation

@tsugitta
Copy link
Copy Markdown
Contributor

@tsugitta tsugitta commented Dec 8, 2022

This adds a new validator CustomValidator, which works same as validateWith but throw ServiceValidationError associated with the field via substitutions as same as other validators.

Usage:

validate(input.value, 'Value', {
  custom: {
    with: () => {
      if (isInvalid) {
        throw new Error('Value is invalid')
      }
    },
    message: 'Please specify a different value'
  }
})

@tsugitta tsugitta marked this pull request as ready for review December 8, 2022 11:19
@cannikin cannikin added release:feature This PR introduces a new feature topic/services labels Dec 12, 2022
@cannikin cannikin merged commit bdea480 into redwoodjs:main Dec 12, 2022
@redwoodjs-bot redwoodjs-bot Bot added this to the next-release milestone Dec 12, 2022
@cannikin
Copy link
Copy Markdown
Contributor

Thank you!

github-actions Bot pushed a commit that referenced this pull request Dec 12, 2022
* feat: add CustomValidator

* docs: add docs about CustomValidator

Co-authored-by: Rob Cameron <[email protected]>
jtoar pushed a commit that referenced this pull request Dec 12, 2022
* feat: add CustomValidator

* docs: add docs about CustomValidator

Co-authored-by: Rob Cameron <[email protected]>
@tsugitta tsugitta deleted the feat/validate-with branch December 13, 2022 14:24
dac09 added a commit that referenced this pull request Dec 14, 2022
…xperimental-vite-optin

* 'main' of github.com:redwoodjs/redwood: (27 commits)
  fix(deps): update dependency @types/node to v16.18.9 (#7140)
  fix(deps): update dependency vscode-languageserver-textdocument to v1.0.8 (#7132)
  fix: add cli-helpers as dep (#7141)
  remove deprecated auth providers (#7138)
  chore: update test project fixture dbauth packages (#7139)
  NavLink not highlighting when on sub pages (#6939)
  Rename create auth functions (#7137)
  Export underlying cache client with Service Cache functions (#7062)
  fix(deps): update dependency @simplewebauthn/browser to v6.2.2 (#7103)
  fix(deps): update dependency msw to v0.49.2 (#7126)
  chore(deps): update dependency nx to v15.3.3 (#7125)
  fix(deps): update docusaurus monorepo to v2.2.0 (#7116)
  [docs] How to test in GitHub actions (#6921)
  fix(deps): update typescript-eslint monorepo to v5.46.1 (#7109)
  Codemod to include full-name in test-project signup (#7124)
  Rebuild test-project fixture (#7123)
  feat: add CustomValidator (#7051)
  dbAuthClient (#7111)
  chore(deps): update dependency nx to v15.3.2 (#7114)
  chore(deps): update dependency redis to v4.5.1 (#7115)
  ...
@jtoar jtoar modified the milestones: next-release, v3.8.0 Dec 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release:feature This PR introduces a new feature topic/services

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

[RFC]: validate accepts a function as same as validateWith

3 participants