-
Notifications
You must be signed in to change notification settings - Fork 902
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core/presentation): Migrate form validation API to class-based API
This is an iteration on the form validation API. The primary changes are: - Migrate from `buildValidators(values)` to `new FormValidator(values)` - Make fields optional by default - Migrate from `.required([validator1, validator2], 'field is required')` to `.required('field is required').withValidators(validator1, validator2)` - Add `spelAware()` to ValidatableField which allows validation to pass when the value contains a SpEL expression, even if other validators would fail the validation. - Add a magic string that can be used to short circuit validation of a field - Used to implement optional() and spelAware()
- Loading branch information
1 parent
447d76f
commit 45f3c24
Showing
7 changed files
with
492 additions
and
153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
...ts/modules/core/src/pipeline/config/stages/googleCloudBuild/googleCloudBuildValidators.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import { buildValidators, IContextualValidator, IStage } from '@spinnaker/core'; | ||
import { FormValidator, IContextualValidator, IStage } from '@spinnaker/core'; | ||
|
||
export const validate: IContextualValidator = (stage: IStage) => { | ||
const validation = buildValidators(stage); | ||
validation.field('account', 'Account').required(); | ||
return validation.result(); | ||
const formValidator = new FormValidator(stage); | ||
formValidator.field('account', 'Account').required(); | ||
return formValidator.validateForm(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.