0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-26 11:42:39 +00:00

add more robust lang code regexp.

This commit is contained in:
Gazook89
2022-11-20 11:42:01 -06:00
parent 9ce79fbe3f
commit c2d79bedb5

View File

@@ -25,7 +25,7 @@ module.exports = {
],
lang : [
(value)=>{
return new RegExp(/^[a-zA-z]{2,3}(-.*)?$/).test(value) === false && (value.length > 0) ? 'Invalid language code.' : null;
return new RegExp(/^([a-zA-Z]{2,3})(-[a-zA-Z]{4})?(-(?:[0-9]{3}|[a-zA-Z]{2}))?$/).test(value) === false && (value.length > 0) ? 'Invalid language code.' : null;
}
]
};