Can I get breeze.js validation errors without sending the transaction to the server

StackOverflow https://stackoverflow.com//questions/21026719

  •  21-12-2019
  •  | 
  •  

I know as part of SaveChanges breeze will run the validation rules, and if valid will then send the transaction to the server. I would like to have breeze perform its validations (that it got from the metadata), and then I would like to perform some additional validations before the transaction is sent (more complex, value-based validations like date range, number range, etc). My goal is to have the metadata validations combined with my custom validations so that any errors can be presented to the user all together. Thanks

有帮助吗?

解决方案

Check the docs -

http://www.breezejs.com/documentation/validation

Automatic validation The Breeze EntityManager can validate an entity in cache at four predetermined times:

the entity enters cache as a result of a query an entity is added or attached to the EntityManager an entity property value is changed an entity is about to be saved The manager’s ValidationOptions determines whether the manager will or will not validate at those times. The default options are:

Option

Default

validateOnQuery

false

validateOnAttach

true

validateOnPropertyChange

true

validateOnSave

true

// copy options, changing only "validateOnAttach"
var valOpts = em.validationOptions.using({ validateOnAttach: false });

// reset manager's options
manager.setProperties({ validationOptions: valOpts });
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top