@@ -350,22 +350,39 @@ If you supply a `validationMessage` property in the form definition, and if its
350
350
string that will be used instead on any validation error.
351
351
352
352
If you need more fine grained control you can supply an object instead with keys matching the error
353
- codes of [tv4](https://github.com/geraintluff/tv4). See ` tv4 .errorCodes `
353
+ codes of [tv4](https://github.com/geraintluff/tv4). tv4 is available
354
+ globally in angular schema form along with it's error codes, they can be found in ` tv4 .errorCodes ` .
354
355
355
356
Ex.
356
357
` ` ` javascript
357
- {
358
- key: " address.street" ,
359
- validationMessage: {
360
- tv4 .errorCodes .STRING_LENGTH_SHORT : " Address is too short, man." ,
361
- " default" : " Just write a proper address, will you?" // Special catch all error message
358
+ var form = [
359
+ " address.zip" ,
360
+ {
361
+ key: " address.street" ,
362
+ validationMessage: {
363
+ " default" : " Just write a proper address, will you?"
364
+ }
362
365
}
363
- }
366
+ ];
367
+
368
+ form[1 ].validationMessage [tv4 .errorCodes .STRING_LENGTH_SHORT ] = " Address is too short, man." ;
364
369
` ` `
365
370
366
- You can also set a global ` validationMessage` in *formDefaults* see
367
- [Global Options](#global-options).
371
+ However, it can sometimes be clunky to use variables as keys so you can use the
372
+ [error codes](https://github.com/geraintluff/tv4/blob/master/source/api.js#L1) directly.
373
+ The example below also illustrates how to define validation messages globally. This uses
374
+ *formDefaults*, for more info on how to use it, see [Global Options](#global-options).
368
375
376
+ ` ` ` javascript
377
+ scope .options = {
378
+ formDefaults: {
379
+ validationMessage: {
380
+ 200 : " This string is too short, man." ,
381
+ 302 : " You can't just leave it blank, man."
382
+ }
383
+ }
384
+ }
385
+ ` ` `
369
386
370
387
### Inline feedback icons
371
388
*input* and *textarea* based fields get inline status icons by default. A check
0 commit comments