mirror of
https://github.com/hashicorp/vault.git
synced 2025-11-22 11:11:26 +01:00
* license: update headers to IBM Corp. * `make proto` * update offset because source file changed Signed-off-by: Ryan Cragun <me@ryan.ec> Co-authored-by: Ryan Cragun <me@ryan.ec>
28 lines
753 B
JavaScript
28 lines
753 B
JavaScript
/**
|
|
* Copyright IBM Corp. 2016, 2025
|
|
* SPDX-License-Identifier: BUSL-1.1
|
|
*/
|
|
|
|
import { validate } from 'vault/utils/forms/validate';
|
|
|
|
// see documentation at ui/docs/model-validations.md for detailed usage information
|
|
export function withModelValidations(validations) {
|
|
return function decorator(SuperClass) {
|
|
return class ModelValidations extends SuperClass {
|
|
static _validations;
|
|
|
|
constructor() {
|
|
super(...arguments);
|
|
if (!validations || typeof validations !== 'object') {
|
|
throw new Error('Validations object must be provided to constructor for setup');
|
|
}
|
|
this._validations = validations;
|
|
}
|
|
|
|
validate() {
|
|
return validate(this, this._validations);
|
|
}
|
|
};
|
|
};
|
|
}
|