breeze-client 2.2.2 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (299) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +83 -63
  3. package/adapters/abstract-data-service-adapter.d.ts +120 -0
  4. package/adapters/abstract-data-service-adapter.js +395 -0
  5. package/adapters/abstract-data-service-adapter.js.map +1 -0
  6. package/adapters/adapter-ajax-fetch.d.ts +12 -0
  7. package/adapters/adapter-ajax-fetch.js +13 -0
  8. package/adapters/adapter-ajax-fetch.js.map +1 -0
  9. package/{adapter-ajax-post → adapters}/adapter-ajax-post.d.ts +40 -36
  10. package/{fesm2022/breeze-client-adapter-ajax-post.mjs → adapters/adapter-ajax-post.js} +80 -82
  11. package/adapters/adapter-ajax-post.js.map +1 -0
  12. package/{adapter-ajax-fetch → adapters}/adapter-core.d.ts +4 -4
  13. package/{fesm2022/breeze-client-adapter-uri-builder-json.mjs → adapters/adapter-core.js} +48 -91
  14. package/adapters/adapter-core.js.map +1 -0
  15. package/adapters/adapter-data-service-webapi.d.ts +9 -0
  16. package/{fesm2022/breeze-client-adapter-data-service-webapi.mjs → adapters/adapter-data-service-webapi.js} +105 -107
  17. package/adapters/adapter-data-service-webapi.js.map +1 -0
  18. package/adapters/adapter-model-library-backing-store.d.ts +32 -0
  19. package/adapters/adapter-model-library-backing-store.js +321 -0
  20. package/adapters/adapter-model-library-backing-store.js.map +1 -0
  21. package/adapters/adapter-uri-builder-json.d.ts +11 -0
  22. package/adapters/adapter-uri-builder-json.js +40 -0
  23. package/adapters/adapter-uri-builder-json.js.map +1 -0
  24. package/adapters/http.d.ts +52 -0
  25. package/adapters/http.js +202 -0
  26. package/adapters/http.js.map +1 -0
  27. package/angular/adapter-angular-httpclient.d.ts +21 -0
  28. package/angular/adapter-angular-httpclient.js +70 -0
  29. package/angular/adapter-angular-httpclient.js.map +1 -0
  30. package/breeze.d.ts +215 -0
  31. package/breeze.js +141 -0
  32. package/breeze.js.map +1 -0
  33. package/config/config.d.ts +212 -0
  34. package/config/config.js +392 -0
  35. package/config/config.js.map +1 -0
  36. package/config/configure.d.ts +66 -0
  37. package/config/configure.js +46 -0
  38. package/config/configure.js.map +1 -0
  39. package/config/default-adapters.d.ts +1 -0
  40. package/config/default-adapters.js +40 -0
  41. package/config/default-adapters.js.map +1 -0
  42. package/config/interface-registry.d.ts +191 -0
  43. package/config/interface-registry.js +5 -0
  44. package/config/interface-registry.js.map +1 -0
  45. package/{src → core}/assert-param.d.ts +52 -60
  46. package/core/assert-param.js +390 -0
  47. package/core/assert-param.js.map +1 -0
  48. package/core/core.d.ts +285 -0
  49. package/core/core.js +772 -0
  50. package/core/core.js.map +1 -0
  51. package/core/enum.d.ts +116 -0
  52. package/core/enum.js +167 -0
  53. package/core/enum.js.map +1 -0
  54. package/core/event.d.ts +169 -0
  55. package/core/event.js +338 -0
  56. package/core/event.js.map +1 -0
  57. package/entity/array.d.ts +3 -0
  58. package/entity/array.js +4 -0
  59. package/entity/array.js.map +1 -0
  60. package/entity/complex-array.d.ts +17 -0
  61. package/entity/complex-array.js +104 -0
  62. package/entity/complex-array.js.map +1 -0
  63. package/entity/default-property-interceptor.d.ts +1 -0
  64. package/entity/default-property-interceptor.js +496 -0
  65. package/entity/default-property-interceptor.js.map +1 -0
  66. package/{src → entity}/entity-action.d.ts +36 -42
  67. package/entity/entity-action.js +45 -0
  68. package/entity/entity-action.js.map +1 -0
  69. package/entity/entity-aspect.d.ts +457 -0
  70. package/entity/entity-aspect.js +1262 -0
  71. package/entity/entity-aspect.js.map +1 -0
  72. package/entity/entity-base.d.ts +55 -0
  73. package/entity/entity-base.js +41 -0
  74. package/entity/entity-base.js.map +1 -0
  75. package/entity/entity-group.d.ts +1 -0
  76. package/entity/entity-group.js +224 -0
  77. package/entity/entity-group.js.map +1 -0
  78. package/entity/entity-key.d.ts +95 -0
  79. package/entity/entity-key.js +189 -0
  80. package/entity/entity-key.js.map +1 -0
  81. package/{src → entity}/entity-state.d.ts +112 -84
  82. package/entity/entity-state.js +135 -0
  83. package/entity/entity-state.js.map +1 -0
  84. package/entity/key-generator.d.ts +57 -0
  85. package/entity/key-generator.js +155 -0
  86. package/entity/key-generator.js.map +1 -0
  87. package/entity/observable-array.d.ts +25 -0
  88. package/entity/observable-array.js +230 -0
  89. package/entity/observable-array.js.map +1 -0
  90. package/entity/primitive-array.d.ts +12 -0
  91. package/entity/primitive-array.js +71 -0
  92. package/entity/primitive-array.js.map +1 -0
  93. package/entity/relation-array.d.ts +24 -0
  94. package/entity/relation-array.js +176 -0
  95. package/entity/relation-array.js.map +1 -0
  96. package/entity/unattached-children-map.d.ts +1 -0
  97. package/entity/unattached-children-map.js +105 -0
  98. package/entity/unattached-children-map.js.map +1 -0
  99. package/generate-entity-classes.js +1176 -0
  100. package/manager/entity-manager.d.ts +801 -0
  101. package/manager/entity-manager.js +2395 -0
  102. package/manager/entity-manager.js.map +1 -0
  103. package/{src → manager}/save-options.d.ts +48 -42
  104. package/manager/save-options.js +51 -0
  105. package/manager/save-options.js.map +1 -0
  106. package/{src → metadata}/data-service.d.ts +229 -184
  107. package/metadata/data-service.js +246 -0
  108. package/metadata/data-service.js.map +1 -0
  109. package/metadata/data-type.d.ts +122 -0
  110. package/metadata/data-type.js +465 -0
  111. package/metadata/data-type.js.map +1 -0
  112. package/metadata/entity-metadata.d.ts +1193 -0
  113. package/metadata/entity-metadata.js +2502 -0
  114. package/metadata/entity-metadata.js.map +1 -0
  115. package/{src → metadata}/local-query-comparison-options.d.ts +65 -59
  116. package/metadata/local-query-comparison-options.js +69 -0
  117. package/metadata/local-query-comparison-options.js.map +1 -0
  118. package/{src → metadata}/naming-convention.d.ts +75 -72
  119. package/metadata/naming-convention.js +97 -0
  120. package/metadata/naming-convention.js.map +1 -0
  121. package/mixins/mixin-get-entity-graph.d.ts +63 -0
  122. package/{fesm2022/breeze-client-mixin-get-entity-graph.mjs → mixins/mixin-get-entity-graph.js} +331 -253
  123. package/mixins/mixin-get-entity-graph.js.map +1 -0
  124. package/mixins/mixin-save-queuing.d.ts +98 -0
  125. package/{fesm2022/breeze-client-mixin-save-queuing.mjs → mixins/mixin-save-queuing.js} +493 -365
  126. package/mixins/mixin-save-queuing.js.map +1 -0
  127. package/package.json +63 -94
  128. package/query/entity-query.d.ts +521 -0
  129. package/query/entity-query.js +1149 -0
  130. package/query/entity-query.js.map +1 -0
  131. package/{src → query}/mapping-context.d.ts +44 -46
  132. package/query/mapping-context.js +412 -0
  133. package/query/mapping-context.js.map +1 -0
  134. package/query/predicate.d.ts +394 -0
  135. package/query/predicate.js +1294 -0
  136. package/query/predicate.js.map +1 -0
  137. package/query/property-path.d.ts +252 -0
  138. package/query/property-path.js +2 -0
  139. package/query/property-path.js.map +1 -0
  140. package/{src → query}/query-options.d.ts +143 -119
  141. package/query/query-options.js +180 -0
  142. package/query/query-options.js.map +1 -0
  143. package/rxjs/breeze-rxjs.d.ts +72 -0
  144. package/rxjs/breeze-rxjs.js +117 -0
  145. package/rxjs/breeze-rxjs.js.map +1 -0
  146. package/validation/validate.d.ts +583 -0
  147. package/validation/validate.js +961 -0
  148. package/validation/validate.js.map +1 -0
  149. package/{src → validation}/validation-options.d.ts +67 -63
  150. package/validation/validation-options.js +70 -0
  151. package/validation/validation-options.js.map +1 -0
  152. package/adapter-ajax-angularjs/adapter-ajax-angularjs.d.ts +0 -17
  153. package/adapter-ajax-angularjs/adapter-core.d.ts +0 -4
  154. package/adapter-ajax-angularjs/index.d.ts +0 -5
  155. package/adapter-ajax-fetch/adapter-ajax-fetch.d.ts +0 -18
  156. package/adapter-ajax-fetch/index.d.ts +0 -5
  157. package/adapter-ajax-httpclient/adapter-ajax-httpclient.d.ts +0 -13
  158. package/adapter-ajax-httpclient/adapter-core.d.ts +0 -4
  159. package/adapter-ajax-httpclient/index.d.ts +0 -5
  160. package/adapter-ajax-jquery/adapter-ajax-jquery.d.ts +0 -15
  161. package/adapter-ajax-jquery/index.d.ts +0 -5
  162. package/adapter-ajax-post/index.d.ts +0 -5
  163. package/adapter-data-service-odata/adapter-core.d.ts +0 -4
  164. package/adapter-data-service-odata/adapter-data-service-odata.d.ts +0 -17
  165. package/adapter-data-service-odata/index.d.ts +0 -5
  166. package/adapter-data-service-webapi/adapter-data-service-webapi.d.ts +0 -15
  167. package/adapter-data-service-webapi/index.d.ts +0 -5
  168. package/adapter-model-library-backing-store/adapter-model-library-backing-store.d.ts +0 -10
  169. package/adapter-model-library-backing-store/index.d.ts +0 -5
  170. package/adapter-model-library-ko/adapter-model-library-ko.d.ts +0 -10
  171. package/adapter-model-library-ko/index.d.ts +0 -5
  172. package/adapter-uri-builder-json/adapter-core.d.ts +0 -4
  173. package/adapter-uri-builder-json/adapter-uri-builder-json.d.ts +0 -8
  174. package/adapter-uri-builder-json/index.d.ts +0 -5
  175. package/adapter-uri-builder-odata/adapter-core.d.ts +0 -4
  176. package/adapter-uri-builder-odata/adapter-uri-builder-odata.d.ts +0 -8
  177. package/adapter-uri-builder-odata/index.d.ts +0 -5
  178. package/esm2022/adapter-ajax-angularjs/adapter-ajax-angularjs.mjs +0 -135
  179. package/esm2022/adapter-ajax-angularjs/adapter-core.mjs +0 -49
  180. package/esm2022/adapter-ajax-angularjs/breeze-client-adapter-ajax-angularjs.mjs +0 -5
  181. package/esm2022/adapter-ajax-fetch/adapter-ajax-fetch.mjs +0 -135
  182. package/esm2022/adapter-ajax-fetch/adapter-core.mjs +0 -49
  183. package/esm2022/adapter-ajax-fetch/breeze-client-adapter-ajax-fetch.mjs +0 -5
  184. package/esm2022/adapter-ajax-httpclient/adapter-ajax-httpclient.mjs +0 -139
  185. package/esm2022/adapter-ajax-httpclient/adapter-core.mjs +0 -49
  186. package/esm2022/adapter-ajax-httpclient/breeze-client-adapter-ajax-httpclient.mjs +0 -5
  187. package/esm2022/adapter-ajax-jquery/adapter-ajax-jquery.mjs +0 -107
  188. package/esm2022/adapter-ajax-jquery/breeze-client-adapter-ajax-jquery.mjs +0 -5
  189. package/esm2022/adapter-ajax-post/adapter-ajax-post.mjs +0 -77
  190. package/esm2022/adapter-ajax-post/breeze-client-adapter-ajax-post.mjs +0 -5
  191. package/esm2022/adapter-data-service-odata/adapter-core.mjs +0 -49
  192. package/esm2022/adapter-data-service-odata/adapter-data-service-odata.mjs +0 -461
  193. package/esm2022/adapter-data-service-odata/breeze-client-adapter-data-service-odata.mjs +0 -5
  194. package/esm2022/adapter-data-service-webapi/adapter-data-service-webapi.mjs +0 -100
  195. package/esm2022/adapter-data-service-webapi/breeze-client-adapter-data-service-webapi.mjs +0 -5
  196. package/esm2022/adapter-model-library-backing-store/adapter-model-library-backing-store.mjs +0 -269
  197. package/esm2022/adapter-model-library-backing-store/breeze-client-adapter-model-library-backing-store.mjs +0 -5
  198. package/esm2022/adapter-model-library-ko/adapter-model-library-ko.mjs +0 -241
  199. package/esm2022/adapter-model-library-ko/breeze-client-adapter-model-library-ko.mjs +0 -5
  200. package/esm2022/adapter-uri-builder-json/adapter-core.mjs +0 -49
  201. package/esm2022/adapter-uri-builder-json/adapter-uri-builder-json.mjs +0 -37
  202. package/esm2022/adapter-uri-builder-json/breeze-client-adapter-uri-builder-json.mjs +0 -5
  203. package/esm2022/adapter-uri-builder-odata/adapter-core.mjs +0 -49
  204. package/esm2022/adapter-uri-builder-odata/adapter-uri-builder-odata.mjs +0 -191
  205. package/esm2022/adapter-uri-builder-odata/breeze-client-adapter-uri-builder-odata.mjs +0 -5
  206. package/esm2022/breeze-client.mjs +0 -5
  207. package/esm2022/index.mjs +0 -2
  208. package/esm2022/mixin-get-entity-graph/breeze-client-mixin-get-entity-graph.mjs +0 -5
  209. package/esm2022/mixin-get-entity-graph/mixin-get-entity-graph.mjs +0 -269
  210. package/esm2022/mixin-save-queuing/breeze-client-mixin-save-queuing.mjs +0 -5
  211. package/esm2022/mixin-save-queuing/mixin-save-queuing.mjs +0 -421
  212. package/esm2022/src/abstract-data-service-adapter.mjs +0 -325
  213. package/esm2022/src/array.mjs +0 -4
  214. package/esm2022/src/assert-param.mjs +0 -330
  215. package/esm2022/src/breeze.mjs +0 -85
  216. package/esm2022/src/complex-array.mjs +0 -117
  217. package/esm2022/src/config.mjs +0 -232
  218. package/esm2022/src/core.mjs +0 -712
  219. package/esm2022/src/csdl-metadata-parser.mjs +0 -385
  220. package/esm2022/src/data-service.mjs +0 -221
  221. package/esm2022/src/data-type.mjs +0 -510
  222. package/esm2022/src/default-property-interceptor.mjs +0 -460
  223. package/esm2022/src/entity-action.mjs +0 -45
  224. package/esm2022/src/entity-aspect.mjs +0 -897
  225. package/esm2022/src/entity-group.mjs +0 -192
  226. package/esm2022/src/entity-key.mjs +0 -125
  227. package/esm2022/src/entity-manager.mjs +0 -2163
  228. package/esm2022/src/entity-metadata.mjs +0 -2242
  229. package/esm2022/src/entity-query.mjs +0 -1024
  230. package/esm2022/src/entity-state.mjs +0 -107
  231. package/esm2022/src/enum.mjs +0 -143
  232. package/esm2022/src/event.mjs +0 -264
  233. package/esm2022/src/interface-registry.mjs +0 -39
  234. package/esm2022/src/key-generator.mjs +0 -110
  235. package/esm2022/src/local-query-comparison-options.mjs +0 -65
  236. package/esm2022/src/mapping-context.mjs +0 -411
  237. package/esm2022/src/naming-convention.mjs +0 -92
  238. package/esm2022/src/observable-array.mjs +0 -183
  239. package/esm2022/src/predicate.mjs +0 -1259
  240. package/esm2022/src/primitive-array.mjs +0 -85
  241. package/esm2022/src/query-options.mjs +0 -152
  242. package/esm2022/src/relation-array.mjs +0 -173
  243. package/esm2022/src/save-options.mjs +0 -41
  244. package/esm2022/src/unattached-children-map.mjs +0 -56
  245. package/esm2022/src/validate.mjs +0 -995
  246. package/esm2022/src/validation-options.mjs +0 -64
  247. package/fesm2022/breeze-client-adapter-ajax-angularjs.mjs +0 -190
  248. package/fesm2022/breeze-client-adapter-ajax-angularjs.mjs.map +0 -1
  249. package/fesm2022/breeze-client-adapter-ajax-fetch.mjs +0 -190
  250. package/fesm2022/breeze-client-adapter-ajax-fetch.mjs.map +0 -1
  251. package/fesm2022/breeze-client-adapter-ajax-httpclient.mjs +0 -194
  252. package/fesm2022/breeze-client-adapter-ajax-httpclient.mjs.map +0 -1
  253. package/fesm2022/breeze-client-adapter-ajax-jquery.mjs +0 -114
  254. package/fesm2022/breeze-client-adapter-ajax-jquery.mjs.map +0 -1
  255. package/fesm2022/breeze-client-adapter-ajax-post.mjs.map +0 -1
  256. package/fesm2022/breeze-client-adapter-data-service-odata.mjs +0 -516
  257. package/fesm2022/breeze-client-adapter-data-service-odata.mjs.map +0 -1
  258. package/fesm2022/breeze-client-adapter-data-service-webapi.mjs.map +0 -1
  259. package/fesm2022/breeze-client-adapter-model-library-backing-store.mjs +0 -276
  260. package/fesm2022/breeze-client-adapter-model-library-backing-store.mjs.map +0 -1
  261. package/fesm2022/breeze-client-adapter-model-library-ko.mjs +0 -248
  262. package/fesm2022/breeze-client-adapter-model-library-ko.mjs.map +0 -1
  263. package/fesm2022/breeze-client-adapter-uri-builder-json.mjs.map +0 -1
  264. package/fesm2022/breeze-client-adapter-uri-builder-odata.mjs +0 -246
  265. package/fesm2022/breeze-client-adapter-uri-builder-odata.mjs.map +0 -1
  266. package/fesm2022/breeze-client-mixin-get-entity-graph.mjs.map +0 -1
  267. package/fesm2022/breeze-client-mixin-save-queuing.mjs.map +0 -1
  268. package/fesm2022/breeze-client.mjs +0 -14144
  269. package/fesm2022/breeze-client.mjs.map +0 -1
  270. package/index.d.ts +0 -1
  271. package/mixin-get-entity-graph/index.d.ts +0 -5
  272. package/mixin-get-entity-graph/mixin-get-entity-graph.d.ts +0 -31
  273. package/mixin-save-queuing/index.d.ts +0 -5
  274. package/mixin-save-queuing/mixin-save-queuing.d.ts +0 -32
  275. package/src/abstract-data-service-adapter.d.ts +0 -84
  276. package/src/array.d.ts +0 -3
  277. package/src/breeze.d.ts +0 -139
  278. package/src/complex-array.d.ts +0 -13
  279. package/src/config.d.ts +0 -104
  280. package/src/core.d.ts +0 -164
  281. package/src/csdl-metadata-parser.d.ts +0 -7
  282. package/src/data-type.d.ts +0 -89
  283. package/src/default-property-interceptor.d.ts +0 -4
  284. package/src/entity-aspect.d.ts +0 -332
  285. package/src/entity-group.d.ts +0 -28
  286. package/src/entity-key.d.ts +0 -77
  287. package/src/entity-manager.d.ts +0 -680
  288. package/src/entity-metadata.d.ts +0 -988
  289. package/src/entity-query.d.ts +0 -444
  290. package/src/enum.d.ts +0 -100
  291. package/src/event.d.ts +0 -142
  292. package/src/interface-registry.d.ts +0 -150
  293. package/src/key-generator.d.ts +0 -12
  294. package/src/observable-array.d.ts +0 -52
  295. package/src/predicate.d.ts +0 -376
  296. package/src/primitive-array.d.ts +0 -7
  297. package/src/relation-array.d.ts +0 -18
  298. package/src/unattached-children-map.d.ts +0 -19
  299. package/src/validate.d.ts +0 -650
@@ -0,0 +1,583 @@
1
+ import { NavigationProperty, DataProperty } from '../metadata/entity-metadata.js';
2
+ import { Entity } from '../entity/entity-aspect.js';
3
+ export declare const INT16_MIN = -32768;
4
+ export declare const INT16_MAX = 32767;
5
+ export declare const INT32_MIN = -2147483648;
6
+ export declare const INT32_MAX = 2147483647;
7
+ export declare const BYTE_MIN = 0;
8
+ export declare const BYTE_MAX = 255;
9
+ /** The entity and property being validated. The {@link ValidationMessageContext} passed to a {@link ValidationFn} extends it with the validator's settings. */
10
+ export interface ValidationContext {
11
+ /** The entity whose property is being validated. Set when Breeze validates a property of an entity; an entity-level validator gets the entity as its value instead. */
12
+ entity?: Entity;
13
+ /** The {@link DataProperty} or {@link NavigationProperty} being validated. Set when Breeze validates a property. */
14
+ property?: DataProperty | NavigationProperty;
15
+ /** The name of the property being validated: a property path, such as `address.city`, for a property of a complex object. */
16
+ propertyName?: string;
17
+ /** The value that failed validation, so that a message template can show it as `%value%`. Set by {@link Validator.validate} when validation fails. */
18
+ value?: any;
19
+ }
20
+ /** Used by Validator to compose messages */
21
+ export interface ValidationMessageContext extends ValidationContext {
22
+ /** The name of the validator. Set by the {@link Validator} constructor. */
23
+ name?: string;
24
+ /** The name to show for the property in messages, as `%displayName%`. When it is not set, Breeze uses the property's `displayName`, or else `propertyName`, or `"Value"` when there is no property. */
25
+ displayName?: string;
26
+ /** The error message template. Each `%token%` is replaced with the context property of that name, calling it with the context if it is a function. Defaults to the entry for the validator's name in {@link Validator.messageTemplates}. */
27
+ messageTemplate?: string;
28
+ /** A message to use instead of `messageTemplate`: a string, or a function that returns one from the context. */
29
+ message?: string | ((vc: ValidationContext) => string);
30
+ /** Marks the validator as async when its function returns a promise without being declared
31
+ `async`, which Breeze cannot see. An `async` function needs no marking. See {@link Validator.isAsync}. */
32
+ isAsync?: boolean;
33
+ /** For an async validator, aborted when its result will no longer be used - another run of the
34
+ same check started, or the entity was detached. Pass it on to `fetch` to cancel the request. */
35
+ signal?: AbortSignal;
36
+ [key: string]: any;
37
+ }
38
+ /** Function called to validate an entity or property. Breeze always passes a context: the
39
+ validator's own, with its settings, extended for each call with the entity and property being
40
+ validated - so a validator reads its settings from it, as `ctx.min`.
41
+
42
+ It may return a promise, for a check that has to ask a server - see {@link Validator.isAsync}. */
43
+ export interface ValidationFn {
44
+ (value: any, context: ValidationMessageContext): boolean | Promise<boolean>;
45
+ }
46
+ /**
47
+ Instances of the Validator class provide the logic to validate another object and provide a description of any errors
48
+ encountered during the validation process. They are typically associated with a 'validators' property on the following types: {@link EntityType},
49
+ {@link DataProperty} or {@link NavigationProperty}.
50
+
51
+ Property-level validators normally arrive with the metadata. The Breeze server sends a
52
+ `validators` array for each data property - for example `required` for a non-nullable
53
+ property, `maxLength` for a string with a maximum length, and a data-type validator such as
54
+ `int32` or `date`. They are not inferred on the client, so metadata written by hand has
55
+ none unless you add them.
56
+
57
+ To write your own, construct one with a name, a validation function and a context. Several
58
+ basic "Validator" construction methods are also provided as static methods to this class. These methods
59
+ provide a simpler syntax for creating basic validations.
60
+
61
+ Many of these stock validators are inspired by and implemented to conform to the validators defined at
62
+ http://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations.aspx
63
+
64
+ Sometimes a custom validator will be required.
65
+ @example
66
+ Most validators will be 'property' level validators, like this.
67
+ @example
68
+ // v in this function is the value to be validated, in this case a "country" string.
69
+ const valFn = (v: string | null) => v == null || v.startsWith("US");
70
+ const countryValidator = new Validator("countryIsUS", valFn, {
71
+ displayName: "Country",
72
+ messageTemplate: "'%displayName%' must start with 'US'"
73
+ });
74
+
75
+ // Now plug it into Breeze.
76
+ // Assume em1 is a preexisting EntityManager.
77
+ const custType = em1.metadataStore.getAsEntityType("Customer");
78
+ const countryProp = custType.getProperty("country");
79
+ // Note that validator is added to a 'DataProperty' validators collection.
80
+ countryProp.validators.push(countryValidator);
81
+ Entity level validators are also possible
82
+ @example
83
+ function isValidZipCode(value: string) {
84
+ const re = /^\d{5}([\-]\d{4})?$/;
85
+ return re.test(value);
86
+ }
87
+
88
+ // the value in this case will be a Customer entity
89
+ const valFn = (cust: Customer) => {
90
+ // This validator only validates US Zip Codes.
91
+ if (cust.country === "USA") {
92
+ return isValidZipCode(cust.postalCode);
93
+ }
94
+ return true;
95
+ };
96
+ const zipCodeValidator = new Validator("zipCodeValidator", valFn,
97
+ { messageTemplate: "For the US, this is not a valid PostalCode" });
98
+
99
+ // Now plug it into Breeze.
100
+ // Assume em1 is a preexisting EntityManager.
101
+ const custType = em1.metadataStore.getAsEntityType("Customer");
102
+ // Note that validator is added to an 'EntityType' validators collection.
103
+ custType.validators.push(zipCodeValidator);
104
+ What is commonly needed is a way of creating a parameterized function that will itself
105
+ return a new Validator. This requires the use of a 'context' object.
106
+ @example
107
+ // create a function that will take in a config object
108
+ // and will return a validator
109
+ const numericRangeValidator = (context: { min?: number, max?: number }) => {
110
+ const valFn = (v: any, ctx: ValidationMessageContext) => {
111
+ if (v == null) return true;
112
+ if (typeof v !== "number") return false;
113
+ if (ctx.min != null && v < ctx.min) return false;
114
+ if (ctx.max != null && v > ctx.max) return false;
115
+ return true;
116
+ };
117
+ // The last parameter below is the 'context' object that will be passed into the 'ctx' parameter above
118
+ // when this validator executes. Several other properties, such as displayName will get added to this object as well.
119
+ return new Validator("numericRange", valFn, {
120
+ messageTemplate: "'%displayName%' must be a number between the values of %min% and %max%",
121
+ min: context.min,
122
+ max: context.max
123
+ });
124
+ };
125
+ // Assume that freightProperty is a DataEntityProperty that describes numeric values.
126
+ // register the validator
127
+ freightProperty.validators.push(numericRangeValidator({ min: 100, max: 500 }));
128
+
129
+ Breeze substitutes context values and functions for the tokens in the messageTemplate when preparing the runtime error message;
130
+ 'displayName' is a pre-defined context function that is always available.
131
+
132
+ Please note that Breeze substitutes the empty string for falsey parameters. That usually works in your favor.
133
+ Sometimes it doesn't as when the 'min' value is zero in which case the message text would have a hole
134
+ where the 'min' value goes, saying: "... an integer between the values of and ...". That is not what you want.
135
+
136
+ To avoid this effect, you may can bake certain of the context values into the 'messageTemplate' itself
137
+ as shown in this revision to the pertinent part of the previous example:
138
+ @example
139
+ // ... as before
140
+ // ... but bake the min/max values into the message template.
141
+ const template = core.formatString(
142
+ "'%displayName%' must be a number between the values of %1 and %2",
143
+ context.min, context.max);
144
+ return new Validator("numericRange", valFn, {
145
+ messageTemplate: template,
146
+ min: context.min,
147
+ max: context.max
148
+ });
149
+
150
+ @param name {String} The name of this validator.
151
+ @param validatorFn {Function} A function to perform validation.
152
+
153
+ validatorFn(value, context)
154
+ @param validatorFn.value {Object} Value to be validated
155
+ @param validatorFn.context {Object} The same context object passed into the constructor with the following additional properties if not
156
+ otherwise specified.
157
+ @param validatorFn.context.value {Object} The value being validated.
158
+ @param validatorFn.context.name {String} The name of the validator being executed.
159
+ @param validatorFn.context.displayName {String} This will be either the value of the property's 'displayName' property or
160
+ the value of its 'name' property or the string 'Value'
161
+ @param validatorFn.context.messageTemplate {String} This will either be the value of Validator.messageTemplates[ {this validators name}] or null. Validator.messageTemplates
162
+ is an object that is keyed by validator name and that can be added to in order to 'register' your own message for a given validator.
163
+ The following property can also be specified for any validator to force a specific errorMessage string
164
+ @param [validatorFn.context.message] {String} If this property is set it will be used instead of the 'messageTemplate' property when an
165
+ error message is generated.
166
+
167
+ @param [context] {Object} A free form object whose properties will made available during the validation and error message creation process.
168
+ This object will be passed into the Validator's validation function whenever 'validate' is called. See above for a description
169
+ of additional properties that will be automatically added to this object if not otherwise specified.
170
+ */
171
+ export declare class Validator {
172
+ /** The name of this validator, such as `required` or `maxLength`. It picks the default message template and forms part of each {@link ValidationError}'s key. __Read Only__ */
173
+ name: string;
174
+ /** The function that performs the validation. It returns `true` if the value is valid. __Read Only__ */
175
+ valFn: ValidationFn;
176
+ /** The context this validator was created with, plus `name`, `messageTemplate` and a `displayName` function. It is passed to `valFn` and used to compose error messages. __Read Only__ */
177
+ context: ValidationMessageContext;
178
+ /** The context of the most recent call to {@link Validator.validate}: `context` extended with any additional context passed to it. {@link Validator.getMessage} reads it. After a validation that passed, it is `context` again. __Read Only__ */
179
+ currentContext: ValidationMessageContext;
180
+ private _baseContext;
181
+ /**
182
+ Whether this validator's function returns a promise: an `async` function, or one created with
183
+ `isAsync: true` in its context. Breeze runs an async validator only when it can wait for the
184
+ answer - when an entity is saved, and from {@link EntityAspect.validateEntityAsync} and
185
+ {@link EntityAspect.validatePropertyAsync}. It does not run on a property change, an attach or
186
+ a query, where nothing could wait for it; editing the property clears its error instead, as it
187
+ clears the server's. __Read Only__
188
+ */
189
+ isAsync: boolean;
190
+ /** Creates a validator. See the class description for examples.
191
+ @param name - The validator's name. Also the default `key` of the errors it produces.
192
+ @param valFn - The function that validates: called with the value (or, for an entity-level
193
+ validator, the entity) and the context, it returns whether the value is valid.
194
+ @param context - Settings for the validator and its messages, such as `displayName` and
195
+ `messageTemplate`. They are available to `valFn` and to the error message template.
196
+ */
197
+ constructor(name: string, valFn: ValidationFn, context?: ValidationMessageContext);
198
+ /**
199
+ Run this validator against the specified value. This method will usually be called internally either
200
+ automatically by an property change, entity attach, query or save operation, or manually as a result of
201
+ a validateEntity call on the EntityAspect. The resulting ValidationResults are available via the
202
+ EntityAspect.getValidationErrors method.
203
+
204
+ However, you can also call a validator directly either for testing purposes or some other reason if needed.
205
+ @example
206
+ // using one of the predefined validators
207
+ const validator = Validator.maxLength({ maxLength: 5, displayName: "City" });
208
+ // null, because "asdf".length <= 5
209
+ const noError = validator.validate("asdf");
210
+ const result = validator.validate("adasdfasdf");
211
+ // extract all of the properties of the 'result'
212
+ const errMsg = result.errorMessage;
213
+ const context = result.context;
214
+ const sameValidator = result.validator;
215
+ @param value {Object} Value to validate
216
+ @param additionalContext {Object} Any additional contextual information that the Validator
217
+ can make use of.
218
+ @returns {ValidationError|null} A ValidationError if validation fails, null otherwise
219
+ */
220
+ validate(value: any, additionalContext?: ValidationMessageContext): ValidationError | null;
221
+ /**
222
+ Runs this validator, sync or async, and resolves with a {@link ValidationError} if the value is
223
+ invalid, or null. Each call has a context of its own, so calls may overlap; unlike
224
+ {@link Validator.validate}, it does not set {@link Validator.currentContext}.
225
+ ```ts
226
+ const ve = await Validator.maxLength({ maxLength: 5 }).validateAsync("adasdfasdf");
227
+ ```
228
+ A function that throws or rejects gives an error, as it does in `validate`.
229
+ @param value - The value to validate.
230
+ @param additionalContext - Anything else the validator can use, such as the entity and property.
231
+ */
232
+ validateAsync(value: any, additionalContext?: ValidationMessageContext): Promise<ValidationError | null>;
233
+ /**
234
+ Returns the message generated by the most recent execution of this Validator.
235
+ @example
236
+ const v0 = Validator.maxLength({ maxLength: 5, displayName: "City" });
237
+ v0.validate("adasdfasdf");
238
+ const errMessage = v0.getMessage();
239
+ @returns {String}
240
+ */
241
+ getMessage(): string;
242
+ /**
243
+ Returns the serializable form of this validator: its `name` plus the context it was created with,
244
+ such as `{ name: "maxLength", maxLength: 50 }`. Breeze uses it when it exports metadata;
245
+ {@link Validator.fromJSON} reads it back through the factory registered under that name.
246
+ */
247
+ toJSON(): ValidationMessageContext;
248
+ /**
249
+ Creates a validator instance from a JSON object or an array of instances from an array of JSON objects.
250
+ @param json {Object} JSON object that represents the serialized version of a validator.
251
+ */
252
+ static fromJSON(json: any): any;
253
+ /**
254
+ Register a validator instance so that any deserialized metadata can reference it.
255
+ @param validator {Validator} Validator to register.
256
+ */
257
+ static register(validator: Validator): void;
258
+ /**
259
+ Register a validator factory so that any deserialized metadata can reference it.
260
+ @param validatorFactory {Function} A function that optionally takes a context property and returns a Validator instance.
261
+ @param name {String} The name of the validator.
262
+ */
263
+ static registerFactory(validatorFactory: (options?: any) => Validator, name: string): void;
264
+ /**
265
+ Map of standard error message templates keyed by validator name.
266
+ You can add to or modify this object to customize the template used for any validation error message.
267
+ @example
268
+ // v in this function is the value to be validated, in this case a "country" string.
269
+ const valFn = (v: string | null) => v == null || v.startsWith("US");
270
+ const countryValidator = new Validator("countryIsUS", valFn, { displayName: "Country" });
271
+ Validator.messageTemplates.countryIsUS = "'%displayName%' must start with 'US'";
272
+ // This will have a similar effect to this
273
+ const countryValidator2 = new Validator("countryIsUS", valFn, {
274
+ displayName: "Country",
275
+ messageTemplate: "'%displayName%' must start with 'US'"
276
+ });
277
+ @property messageTemplates {Object}
278
+ */
279
+ static messageTemplates: Record<string, any>;
280
+ /**
281
+ Returns a standard 'required value' Validator
282
+ @example
283
+ // Assume em1 is a preexisting EntityManager.
284
+ const custType = em1.metadataStore.getAsEntityType("Customer");
285
+ const regionProperty = custType.getProperty("region");
286
+ // Makes "region" on Customer a required property.
287
+ regionProperty.validators.push(Validator.required());
288
+ // or to allow empty strings
289
+ regionProperty.validators.push(Validator.required({ allowEmptyStrings: true }));
290
+ @param context - An object with `allowEmptyStrings` (boolean) - If this parameter is omitted or false then empty strings do NOT pass validation.
291
+ @returns {Validator} A new Validator
292
+ */
293
+ static required: (context?: any) => Validator;
294
+ /**
295
+ Returns a standard maximum string length Validator; the maximum length must be specified
296
+ @example
297
+ // Assume em1 is a preexisting EntityManager.
298
+ const custType = em1.metadataStore.getAsEntityType("Customer");
299
+ const regionProperty = custType.getProperty("region");
300
+ // Validates that the value of the region property on Customer will be less than or equal to 5 characters.
301
+ regionProperty.validators.push(Validator.maxLength({ maxLength: 5 }));
302
+ @param context - An object with `maxLength` (number).
303
+ @returns {Validator} A new Validator
304
+ */
305
+ static maxLength: (context: any) => Validator;
306
+ /**
307
+ Returns a standard string length Validator; both minimum and maximum lengths must be specified.
308
+ @example
309
+ // Assume em1 is a preexisting EntityManager.
310
+ const custType = em1.metadataStore.getAsEntityType("Customer");
311
+ const regionProperty = custType.getProperty("region");
312
+ // Validates that the value of the region property on Customer will be
313
+ // between 2 and 5 characters
314
+ regionProperty.validators.push(Validator.stringLength({ minLength: 2, maxLength: 5 }));
315
+ @param context - An object with `maxLength` (number); `minLength` (number).
316
+ @returns {Validator} A new Validator
317
+ */
318
+ static stringLength: (context: any) => Validator;
319
+ /**
320
+ Returns a standard string dataType Validator.
321
+ @example
322
+ // Assume em1 is a preexisting EntityManager.
323
+ const custType = em1.metadataStore.getAsEntityType("Customer");
324
+ const regionProperty = custType.getProperty("region");
325
+ // Validates that the value of the region property on Customer is a string.
326
+ regionProperty.validators.push(Validator.string());
327
+ @returns {Validator} A new Validator
328
+ */
329
+ static string: () => Validator;
330
+ /**
331
+ Returns a Guid data type Validator.
332
+ @example
333
+ // Assume em1 is a preexisting EntityManager.
334
+ const custType = em1.metadataStore.getAsEntityType("Customer");
335
+ const customerIdProperty = custType.getProperty("customerID");
336
+ // Validates that the value of the customerID property on Customer is a Guid.
337
+ customerIdProperty.validators.push(Validator.guid());
338
+ @returns {Validator} A new Validator
339
+ */
340
+ static guid: () => Validator;
341
+ /**
342
+ Returns a ISO 8601 duration string Validator.
343
+ @example
344
+ // Assume em1 is a preexisting EntityManager.
345
+ const timeLimitType = em1.metadataStore.getAsEntityType("TimeLimit");
346
+ const maxTimeProperty = timeLimitType.getProperty("maxTime");
347
+ // Validates that the value of the maxTime property on TimeLimit is a duration.
348
+ maxTimeProperty.validators.push(Validator.duration());
349
+ @returns {Validator} A new Validator
350
+ */
351
+ static duration: () => Validator;
352
+ /**
353
+ Returns a standard numeric data type Validator.
354
+ @example
355
+ // Assume em1 is a preexisting EntityManager.
356
+ const orderType = em1.metadataStore.getAsEntityType("Order");
357
+ const freightProperty = orderType.getProperty("freight");
358
+ // Validates that the value of the freight property on Order is a number.
359
+ freightProperty.validators.push(Validator.number());
360
+ @returns {Validator} A new Validator
361
+ */
362
+ static number: (context?: any) => Validator;
363
+ /** Another name for {@link Validator.number}, registered as `double` so that metadata naming it imports. The validator it returns is named `number`. */
364
+ static double: (context?: any) => Validator;
365
+ /** Another name for {@link Validator.number}, registered as `single` so that metadata naming it imports. The validator it returns is named `number`. */
366
+ static single: (context?: any) => Validator;
367
+ /**
368
+ Returns a standard large integer data type - 64 bit - Validator.
369
+ @example
370
+ // Assume em1 is a preexisting EntityManager.
371
+ const orderType = em1.metadataStore.getAsEntityType("Order");
372
+ const freightProperty = orderType.getProperty("freight");
373
+ // Validates that the value of the freight property on Order is within the range of a 64 bit integer.
374
+ freightProperty.validators.push(Validator.int64());
375
+ @returns {Validator} A new Validator
376
+ */
377
+ static integer: (context?: any) => Validator;
378
+ /** Another name for {@link Validator.integer}, and the data-type validator for {@link DataType.Int64}: it checks that the value is a whole number, with no range check. The validator it returns is named `integer`. */
379
+ static int64: (context?: any) => Validator;
380
+ /**
381
+ Returns a standard 32 bit integer data type Validator.
382
+ @example
383
+ // Assume em1 is a preexisting EntityManager.
384
+ const orderType = em1.metadataStore.getAsEntityType("Order");
385
+ const freightProperty = orderType.getProperty("freight");
386
+ freightProperty.validators.push(Validator.int32());
387
+ @returns {Validator} A new Validator
388
+ */
389
+ static int32: (context?: any) => Validator;
390
+ /**
391
+ Returns a standard 16 bit integer data type Validator.
392
+ @example
393
+ // Assume em1 is a preexisting EntityManager.
394
+ const orderType = em1.metadataStore.getAsEntityType("Order");
395
+ const freightProperty = orderType.getProperty("freight");
396
+ // Validates that the value of the freight property on Order is within the range of a 16 bit integer.
397
+ freightProperty.validators.push(Validator.int16());
398
+ @returns {Validator} A new Validator
399
+ */
400
+ static int16: (context?: any) => Validator;
401
+ /**
402
+ Returns a standard byte data type Validator. (This is a integer between 0 and 255 inclusive for js purposes).
403
+ @example
404
+ // Assume em1 is a preexisting EntityManager.
405
+ const orderType = em1.metadataStore.getAsEntityType("Order");
406
+ const freightProperty = orderType.getProperty("freight");
407
+ // Validates that the value of the freight property on Order is a byte: an integer from 0 to 255.
408
+ // Probably not a very good validation to place on the freight property.
409
+ freightProperty.validators.push(Validator.byte());
410
+ @returns {Validator} A new Validator
411
+ */
412
+ static byte: (context?: any) => Validator;
413
+ /**
414
+ Returns a standard boolean data type Validator.
415
+ @example
416
+ // Assume em1 is a preexisting EntityManager.
417
+ const productType = em1.metadataStore.getAsEntityType("Product");
418
+ const discontinuedProperty = productType.getProperty("isDiscontinued");
419
+ // Validates that the value of the isDiscontinued property on Product is a boolean
420
+ discontinuedProperty.validators.push(Validator.bool());
421
+ @returns {Validator} A new Validator
422
+ */
423
+ static bool: () => Validator;
424
+ /** Returns a Validator named `none` that accepts every value. It is the data-type validator for {@link DataType.Binary} and {@link DataType.Undefined}. */
425
+ static none: () => Validator;
426
+ /**
427
+ Returns a standard date data type Validator.
428
+ @example
429
+ // Assume em1 is a preexisting EntityManager.
430
+ const orderType = em1.metadataStore.getAsEntityType("Order");
431
+ const orderDateProperty = orderType.getProperty("orderDate");
432
+ // Validates that the value of the orderDate property on Order is a date
433
+ orderDateProperty.validators.push(Validator.date());
434
+ @returns {Validator} A new Validator
435
+ */
436
+ static date: () => Validator;
437
+ /**
438
+ Returns a credit card number validator
439
+ Performs a luhn algorithm checksum test for plausability
440
+ catches simple mistakes; only service knows for sure
441
+ @example
442
+ // Assume em is a preexisting EntityManager.
443
+ const personType = em.metadataStore.getAsEntityType("Person");
444
+ const creditCardProperty = personType.getProperty("creditCard");
445
+ // Validates that the value of the Person.creditCard property is credit card.
446
+ creditCardProperty.validators.push(Validator.creditCard());
447
+ @param [context] {Object} optional parameters to pass through to validation constructor
448
+ @returns {Validator} A new Validator
449
+ */
450
+ static creditCard: (context?: any) => Validator;
451
+ /**
452
+ Returns a regular expression validator; the expression must be specified
453
+ @example
454
+ // Add validator to a property. Assume em is a preexisting EntityManager.
455
+ const customerType = em.metadataStore.getAsEntityType("Customer");
456
+ const regionProperty = customerType.getProperty("region");
457
+ // Validates that the value of Customer.region is 2 char uppercase alpha.
458
+ regionProperty.validators.push(Validator.regularExpression({ expression: '^[A-Z]{2}$' }));
459
+ @param context - An object with `expression` (string) - String form of the regular expression to apply.
460
+ @returns {Validator} A new Validator
461
+ */
462
+ static regularExpression: (context?: any) => Validator;
463
+ /**
464
+ Returns the email address validator
465
+ @example
466
+ // Assume em is a preexisting EntityManager.
467
+ const userType = em.metadataStore.getAsEntityType("User");
468
+ const emailProperty = userType.getProperty("email");
469
+ // Validates that the value of the User.email property is an email address.
470
+ emailProperty.validators.push(Validator.emailAddress());
471
+ @param [context] {Object} optional parameters to pass through to validation constructor
472
+ @returns {Validator} A new Validator
473
+ */
474
+ static emailAddress: (context?: any) => Validator;
475
+ /**
476
+ Returns the phone validator
477
+ Provides basic assertions on the format and will help to eliminate most nonsense input
478
+ Matches:
479
+ International dialing prefix: one of nothing, `+`, `0` or `0000` (with or without a trailing break character, if not '+': [-/. ])
480
+ ```ts
481
+ ((\+)|(0(\d+)?[-/.\s]))
482
+ ```
483
+ Country code: nothing, or `1` to `999` (with or without a trailing break character: [-/. ])
484
+ ```ts
485
+ [1-9]\d{,2}[-/.\s]?
486
+ ```
487
+ Area code: `(0)` to `(000000)`, or `0` to `000000` (with or without a trailing break character: [-/. ])
488
+ ```ts
489
+ ((\(\d{1,6}\)|\d{1,6})[-/.\s]?)?
490
+ ```
491
+ Local: one or more digits (with or without a trailing break character: [-/. ])
492
+ ```ts
493
+ (\d+[-/.\s]?)+\d+
494
+ ```
495
+ @example
496
+ // Assume em is a preexisting EntityManager.
497
+ const customerType = em.metadataStore.getAsEntityType("Customer");
498
+ const phoneProperty = customerType.getProperty("phone");
499
+ // Validates that the value of the Customer.phone property is phone.
500
+ phoneProperty.validators.push(Validator.phone());
501
+ @param [context] {Object} optional parameters to pass through to validation constructor
502
+ @returns {Validator} A new Validator
503
+ */
504
+ static phone: (context?: any) => Validator;
505
+ /**
506
+ Returns the URL (protocol required) validator
507
+ @example
508
+ // Assume em is a preexisting EntityManager.
509
+ const supplierType = em.metadataStore.getAsEntityType("Supplier");
510
+ const homePageProperty = supplierType.getProperty("homePage");
511
+ // Validates that the value of the Supplier.homePage property is a URL.
512
+ homePageProperty.validators.push(Validator.url());
513
+ @param [context] {Object} optional parameters to pass through to validation constructor
514
+ @returns {Validator} A new Validator
515
+ */
516
+ static url: (context?: any) => Validator;
517
+ /**
518
+ Creates a regular expression validator with a fixed expression.
519
+ Many of the stock validators are built with this factory method.
520
+ Their expressions are often derived from
521
+ https://github.com/srkirkland/DataAnnotationsExtensions/blob/master/DataAnnotationsExtensions
522
+ You can try many of them at http://dataannotationsextensions.org/
523
+ @example
524
+ // Make a zipcode validator
525
+ const zipValidator = Validator.makeRegExpValidator(
526
+ "zipVal",
527
+ /^\d{5}([\-]\d{4})?$/,
528
+ "The %displayName% '%value%' is not a valid U.S. zipcode");
529
+ // Register it.
530
+ Validator.register(zipValidator);
531
+ // Add it to a data property. Assume em is a preexisting EntityManager.
532
+ const custType = em.metadataStore.getAsEntityType("Customer");
533
+ const zipProperty = custType.getProperty("postalCode");
534
+ zipProperty.validators.push(zipValidator);
535
+ @param validatorName {String} name of this validator
536
+ @param expression {String | RegExp} regular expression to apply
537
+ @param [defaultMessage] {String} default message for failed validations
538
+ @param [context] {Object} optional parameters to pass through to validation constructor
539
+ @returns {Validator} A new Validator
540
+ */
541
+ static makeRegExpValidator: typeof makeRegExpValidator;
542
+ }
543
+ export declare function makeRegExpValidator(validatorName: string, expression: RegExp, defaultMessage?: string | null, context?: any): Validator;
544
+ /**
545
+ Describes one failed validation: which validator failed, on which property, and the message to
546
+ show. An entity's current errors are in {@link EntityAspect.getValidationErrors}. The errors a
547
+ server reports for a failed save are added there too, with {@link ValidationError.isServerError} set.
548
+ */
549
+ export declare class ValidationError {
550
+ /** The {@link Validator} that produced this error. `undefined` for an error from the server or one created without a validator. __Read Only__ */
551
+ validator?: Validator;
552
+ /** The key that identifies this error among an entity's validation errors: the validator's name (or the error name), then `:` and the property name if there is one. Adding an error with the same key replaces the old one. __Read Only__ */
553
+ key: string;
554
+ /** The context the error was created with - for a validator, its context when it ran, which for a property error includes `entity`, `property`, `propertyName` and `value`. __Read Only__ */
555
+ context: any;
556
+ /** The error message. __Read Only__ */
557
+ errorMessage: string;
558
+ /** The {@link DataProperty} or {@link NavigationProperty} this error is about, or `undefined` for an entity-level error. __Read Only__ */
559
+ property: any;
560
+ /** The name of the property this error is about - a property path, such as `address.city`, for a property of a complex object - or `undefined` for an entity-level error. __Read Only__ */
561
+ propertyName?: string;
562
+ /** Whether this error came from the server in a failed save. Server errors do not block a save, and are cleared when the property is changed or the entity is saved again. __Read Only__ */
563
+ isServerError: boolean;
564
+ /**
565
+ Creates a validation error. Applications usually add one with
566
+ {@link EntityAspect.addValidationError} after creating it here.
567
+ @param validator - The Validator that found the error, or `null` for an error found some other way.
568
+ @param context - The context to record with the error: for a property, its `entity`, `property`,
569
+ `propertyName` and `value`.
570
+ @param errorMessage - The message to show.
571
+ @param key - Identifies the error among the entity's errors. If not given, it is built from the
572
+ validator's name - or, without a validator, the error message - and the property name; see
573
+ {@link ValidationError.getKey}.
574
+ */
575
+ constructor(validator: Validator | null, context: ValidationContext, errorMessage: string, key?: string);
576
+ /**
577
+ Composes a ValidationError 'key' given a validator or an errorName and an optional propertyName
578
+ @param validatorOrErrorName - A Validator, or an "error name" if no validator is available.
579
+ @param [propertyName] A property name
580
+ @returns {String} A ValidationError 'key'
581
+ */
582
+ static getKey(validatorOrErrorName: Validator | string, propertyName?: string): string;
583
+ }