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
Add validator for Lao (lo) #651
Merged
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
5259593
Create lo.js
wannaphong 5dde8f2
Update lo.js
wannaphong 6d80276
Update lo.js
wannaphong cf9cc15
Add lo to server/lib/validation/index.js
wannaphong 48ac385
Update lo.js
wannaphong a11f4d1
Change MAX_LENGTH in lo.js
wannaphong File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 = 100; | ||
|
||
const INVALIDATIONS = [{ | ||
fn: (sentence) => { | ||
return sentence.length < MIN_LENGTH || sentence.length > MAX_LENGTH; | ||
}, | ||
error: `Number of characters must be between ${MIN_LENGTH} and ${MAX_LENGTH} (inclusive)`, | ||
}, { | ||
// Lao digits and Thai digits | ||
regex: /[0-9໑໒໓໔໕໖໗໘໙໐๐-๙]/, | ||
error: 'Sentence should not contain numbers', | ||
}, { | ||
// English and Thai characters are not allowed | ||
regex: /[A-Za-zก-ฮ]/, | ||
error: 'Sentence should not contain latin alphabet characters or Thai characters', | ||
}, { | ||
// < > + * \ # @ ^ [ ] ( ) / | ||
// ellipsis: \u0EAF ຯ | ||
// repetition: \u0EC6 ໆ | ||
regex: /[<>+*\\#@^[\]()/\u0EAF\u0EC6]/, | ||
error: 'Sentence should not contain symbols, including ellipsis and repetition', | ||
}, { | ||
// 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: 'Sentence should not contain emojis or other special Unicode symbols', | ||
}]; | ||
|
||
module.exports = { | ||
INVALIDATIONS, | ||
}; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As with other languages, I think it would make sense to translate these error messages into Lao. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with you. I will translate these messages into Lao.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done