I have written a couple of custom validators, they are basically working.
However, with confirmInstancePath I have too test.
The value must start with another value. (working) and it must be longer that the other value indicating that it's been added too (working)
However I would like to give different error messages for each failure
confirmInstancePathText: 'Instance Root Path must start with the sites master path',
or
confirmInstancePathText: 'Please add directory path to the sites master path',
Code:
Ext.define('overrides.form.field.VTypes', {
override: 'Ext.form.field.VTypes',
confirmInstancePath: function(val, field) {
if (field.siteInfoField) {
var record = field.up('form').down('#' + field.siteInfoField).getSelectedRecord(),
rootPath = record.get('master_root_path');
return ( val.startsWith(rootPath) && (val.length > rootPath.length ) );
}
return true;
},
confirmInstancePathText: 'Instance Root Path must start with the sites master path',
confirmPassword: function(val, field) {
if (field.initialPassField) {
var pwd = field.up('form').down('#' + field.initialPassField);
return (val == pwd.getValue());
}
return true;
},
confirmPasswordText: 'Passwords do not match'
});
TIA
Harry