This repository has been archived by the owner on May 10, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add validator for Lao (lo) (#651)
- Loading branch information
1 parent
c79fcfe
commit f56d8a0
Showing
2 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Lao rules | ||
// use any rule from Thai rules https://github.com/common-voice/sentence-collector/blob/main/server/lib/validation/languages/th.js | ||
const MIN_LENGTH = 2; | ||
const MAX_LENGTH = 140; | ||
|
||
const INVALIDATIONS = [{ | ||
fn: (sentence) => { | ||
return sentence.length < MIN_LENGTH || sentence.length > MAX_LENGTH; | ||
}, | ||
error: `ຈຳນວນຕົວອັກສອນຕ້ອງຢູ່ລະຫວ່າງ ${MIN_LENGTH} ຫາ ${MAX_LENGTH} (ລວມ)`, | ||
}, { | ||
// Lao digits and Thai digits | ||
regex: /[0-9໑໒໓໔໕໖໗໘໙໐๐-๙]/, | ||
error: 'ປະໂຫຍກບໍ່ຄວນມີຕົວເລກ', | ||
}, { | ||
// English and Thai characters are not allowed | ||
regex: /[A-Za-z\u0E00-\u0E7F]/, | ||
error: 'ປະໂຫຍກບໍ່ຄວນມີຕົວອັກສອນລາຕິນ ຫຼືຕົວອັກສອນໄທ', | ||
}, { | ||
// < > + * \ # @ ^ [ ] ( ) / | ||
// ellipsis: \u0EAF ຯ | ||
// repetition: \u0EC6 ໆ | ||
regex: /[<>+*\\#@^[\]()/\u0EAF\u0EC6]/, | ||
error: 'ປະໂຫຍກບໍ່ຄວນມີສັນຍາລັກ, ລວມທັງ ຯ ແລະ ໆ', | ||
}, { | ||
// Emoji range from https://www.regextester.com/106421 and | ||
// https://stackoverflow.com/questions/10992921/how-to-remove-emoji-code-using-javascript | ||
regex: /(\u00a9|\u00ae|[\u2000-\u3300]|[\u2580-\u27bf]|\ud83c[\ud000-\udfff]|\ud83d[\ud000-\udfff]|\ud83e[\ud000-\udfff]|[\ue000-\uf8ff])/, | ||
error: 'ປະໂຫຍກບໍ່ຄວນມີ ອີໂມຈິ ຫຼືສັນຍາລັກຂອງ Unicode ພິເສດອື່ນໆ', | ||
}]; | ||
|
||
module.exports = { | ||
INVALIDATIONS, | ||
}; |