How can we improve Breeze.js?

Breeze + Knockout validation -> new features

If App uses breeze and ko validation, I suggest to

add knockout validation rules for every fetched entity as showed in code example (here coffee code implementation for dataPropeties):

addRules = (breezeEntity) ->
return if breezeEntity.koValidationRulesAdded
entityType = breezeEntity.entityType
for property in entityType.dataProperties
continue unless property.validators.length > 0
do (property) ->
displayName = property.displayName or property.custom?.displayName or
validator: (value) ->
if breezeEntity.entityAspect.validateProperty, {displayName: displayName, entity: breezeEntity}
@message = ""
return true
@message = breezeEntity.entityAspect.getValidationErrors([0].errorMessage
return false
message: ""
breezeEntity.koValidationRulesAdded = true

this code allows:
1) to validate single property with usage of all entity properties and triggers property validation on changes in any properties that validation depends on. For example I can extend entity with fields like password and passwordConfirmation and add custom breeze validator for passwordConfirmation that checks equality of fields.
2) to show validation messages separately for each property in html form using ko binding.

5 votes
Sign in
Sign in with: facebook google
Signed in as (Sign out)
You have left! (?) (thinking…)
Anna shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →


Sign in
Sign in with: facebook google
Signed in as (Sign out)

Feedback and Knowledge Base