We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pre - Validation Update
this.validator = this.validation.on(this) .ensure('baseContent.SettingId', (config) => {config.computedFrom(['IsDiscontinued'])}) .if(() => { return !this.IsDiscontinued }) .isNotEmpty() .isGreaterThan(0).withMessage('is required') .endIf()
Post - Validation Update
ValidationRules.ensure('SettingId').required().when(v => v.IsDiscontinued); @computedFrom('isDiscontinued') get IsDiscontinued() { this.readonly = this.isDiscontinued; return this.isDiscontinued; }
If the value of IsDiscontinued changes the validation rule is not affected and will stay either on or off depending on what it was on first loaded.
Is there a way to allow the conditional rule to be applied on the fly?
The text was updated successfully, but these errors were encountered:
@ClareBear85 we're tracking this in #279
As a workaround you could do something like this:
@computedFrom('isDiscontinued') get IsDiscontinued() { return this.isDiscontinued; } set IsDiscontinued(newValue) { if (newValue === this.isDiscontinued) { return; } this.controller.validate({ object: this, propertyName: `SettingId` }); this.isDiscontinued = newValue; }
(then make sure you never use isDiscontinued directly and instead use the IsDiscontinued property).
isDiscontinued
IsDiscontinued
Sorry, something went wrong.
@jdanyow -
Where do I actually put
.isNotEmpty() .isGreaterThan(0).withMessage('is required')
And if there is more than one property. Do I do this:
this.controller.validate({ object: this, propertyName: `SettingId` }); this.controller.validate({ object: this, propertyName: `SettingTwoId` }); or this.controller.validate({ object: this, propertyName: [`SettingId`, `SettingTwoId`] });
No branches or pull requests
Pre - Validation Update
Post - Validation Update
If the value of IsDiscontinued changes the validation rule is not affected and will stay either on or off depending on what it was on first loaded.
Is there a way to allow the conditional rule to be applied on the fly?
The text was updated successfully, but these errors were encountered: