mmitechnic
New Member
Hello all, i am having a problem to understand how to use php validation in Fabrik. I saw some examples here and there in Google and forum but nothing to explain what to do.
In case we have the field imo and we would like to add the following validation
public static final boolean isImoValid(String imo) {
if (imo == null || imo.length() != 7) {
return false;
}
char[] a = imo.toCharArray();
int sum = 0;
for(int i = 0; i < 6; i++) {
sum += (a-48)*(a.length-i);
}
return sum % 10 == a[6]-48;
}
How is it possible to achieve this.
Or for example if we would like to say that the imo field would be equal to 7 digits how the syntax will be?
Thanks in advance
In case we have the field imo and we would like to add the following validation
public static final boolean isImoValid(String imo) {
if (imo == null || imo.length() != 7) {
return false;
}
char[] a = imo.toCharArray();
int sum = 0;
for(int i = 0; i < 6; i++) {
sum += (a-48)*(a.length-i);
}
return sum % 10 == a[6]-48;
}
How is it possible to achieve this.
Or for example if we would like to say that the imo field would be equal to 7 digits how the syntax will be?
Thanks in advance