Folks, I am trying to add a tv4 format, however, the following is not matching regex for whatever reason.
tv4.addFormat({
'year': function (data, schema) {
if (typeof data === 'string' && !/^(19|20)\d{2}$/.test(data)) {
return null;
}
return 'Year must be between 1900 - 2099';
}
});
Regex is supposed to match 1900-2099 for year validation. As per : https://github.com/geraintluff/tv4
Thoughts? :)
This might work better
tv4.addFormat({
'year': function (data, schema) {
var i = parseInt(data);
if (i.toString() === data && i >= 1900 && i <= 2099) {
return null;
}
return 'Year must be between 1900 - 2099';
}
});