Custom validation in Business Console

Hello,

We are in a process of developing the gadgets for some business requirements. As per documentation, we have to use the bc-validate directive for form validation. But how can we achieve some sort of custom validation like,

  1. Date Range Check
  2. Special character check etc. ?

Is there any way to customize/overried the default validation framework ?

Any help would be much appreciated.

Regards,
Anish

You can try to do something like this with a custom function to invoke it. Invoke your custom function on an event like ng-change

have your validation rules in the function and bind a respective user friendly validation message. Let us know if its suffice.

$scope.isValidDate = function(startDate,endDate) {
$scope.errorMessage = ‘’;
var curDate = new Date();

if(new Date(startDate) > new Date(endDate)){
  $scope.errorMessage = 'End Date should be greater than start date';
  return false;
}
if(new Date(startDate) < curDate){
   $scope.errorMessage = 'Start date should not be before today.';
   return false;
}

};

Start Date:

End Date:

{{errorMessage}}