Skip to content

Commit b017d7f

Browse files
Portugal, MarceloPortugal, Marcelo
Portugal, Marcelo
authored and
Portugal, Marcelo
committed
fix(5515): Fix validation documentation
Correcting issue with incorrect usage of the setValidator function in the validation tutorial. Issue #5515
1 parent eec9067 commit b017d7f

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

misc/tutorial/322_validation.ngdoc

+11-11
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
@name Tutorial: 322 Validation
33
@description
44

5-
<div class="alert alert-warning" role="alert"><strong>Alpha</strong> This feature is in development.
5+
<div class="alert alert-warning" role="alert"><strong>Alpha</strong> This feature is in development.
66
There will almost certainly be breaking api changes, or there are major outstanding bugs.</div>
77

88
Feature ui.grid.validate allows validating cells after they are changed. To enable, you must include the
@@ -27,8 +27,8 @@ Some custom validators come with the feature and are:
2727
To define a new validator you should use the {@link
2828
api/ui.grid.validate.service:uiGridValidateService#methods_setValidator setValidator} method.
2929

30-
To add a validator to a column you just need to add a `validators` property to its `colDef`
31-
object, containing a property for each validator you want to add. The name of the property
30+
To add a validator to a column you just need to add a `validators` property to its `colDef`
31+
object, containing a property for each validator you want to add. The name of the property
3232
will set the validator and the value of the property will be treated as an argument by the validator function.
3333

3434
When a field does not pass validation it gets a `invalid` class so you can customize it via css.
@@ -40,12 +40,12 @@ The feature adds 2 templates to ui-grid:
4040

4141
## External Factory
4242

43-
In case you have an external service providing validators, you can add a function calling said service
43+
In case you have an external service providing validators, you can add a function calling said service
4444
by setting an external validator factory function via {@link
4545
api/ui.grid.validate.service:uiGridValidateService#methods_setExternalFactoryFunction setExternalFactoryFunction}.
4646

4747
Please be advised that external validators should accept the same parameters (or at least an ordered subset) as
48-
our validators do (`newValue`, `oldValue`, `rowEntity`, `colDef`);
48+
our validators do (`oldValue`, `newValue`, `rowEntity`, `colDef`);
4949

5050
@example
5151
<example module="app">
@@ -59,10 +59,10 @@ our validators do (`newValue`, `oldValue`, `rowEntity`, `colDef`);
5959
});
6060

6161
app.controller('MainCtrl', ['$scope', '$http', '$window', 'uiGridValidateService', function ($scope, $http, $window, uiGridValidateService) {
62-
62+
6363
uiGridValidateService.setValidator('startWith',
6464
function(argument) {
65-
return function(newValue, oldValue, rowEntity, colDef) {
65+
return function(oldValue, newValue, rowEntity, colDef) {
6666
if (!newValue) {
6767
return true; // We should not test for existence here
6868
} else {
@@ -74,12 +74,12 @@ our validators do (`newValue`, `oldValue`, `rowEntity`, `colDef`);
7474
return 'You can only insert names starting with: "' + argument + '"';
7575
}
7676
);
77-
77+
7878
$scope.gridOptions = { enableCellEditOnFocus: true };
7979

8080
$scope.gridOptions.columnDefs = [
8181
{ name: 'id', enableCellEdit: false, width: '10%' },
82-
{ name: 'name', displayName: 'Name (editable)', width: '20%',
82+
{ name: 'name', displayName: 'Name (editable)', width: '20%',
8383
validators: {required: true, startWith: 'M'}, cellTemplate: 'ui-grid/cellTitleValidator' }
8484
];
8585

@@ -92,7 +92,7 @@ our validators do (`newValue`, `oldValue`, `rowEntity`, `colDef`);
9292
$scope.gridApi = gridApi;
9393
gridApi.validate.on.validationFailed($scope,function(rowEntity, colDef, newValue, oldValue){
9494
$window.alert('rowEntity: '+ rowEntity + '\n' +
95-
'colDef: ' + colDef + '\n' +
95+
'colDef: ' + colDef + '\n' +
9696
'newValue: ' + newValue + '\n' +
9797
'oldValue: ' + oldValue);
9898
});
@@ -116,4 +116,4 @@ our validators do (`newValue`, `oldValue`, `rowEntity`, `colDef`);
116116
height: 450px;
117117
}
118118
</file>
119-
</example>
119+
</example>

0 commit comments

Comments
 (0)