-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RegEx messages #2276
RegEx messages #2276
Conversation
core/lib/simple_schema_config.js
Outdated
{ exp: SimpleSchema.RegEx.Email, msg: '[label] must be a valid e-mail address' }, | ||
{ exp: proxyBasePathRegEx, msg: '[label] allowed characters: A-Z' }, | ||
{ exp: apiBasePathRegEx, msg: '[label] allowed characters: A-Z' }, | ||
{ exp: contactPhone, msg: '[label] allowed characters: A-Z' }, |
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.
This does not correspond with the contactPhone
regex.
I see this is a work-in-progress, so I will wait till it is closer for comments. It is looking good for a work-in-progress, though. |
organizations/collection/regex.js
Outdated
@@ -0,0 +1,3 @@ | |||
// all numbers (0-9) , + , - , space ,/ are allowed and can appear anywhere in the phone numbers | |||
// e.g. 754-3010,(541) 754-3010,1-541-754-3010,1-541-754-3010,191 541 754 3010,(089) / 636-48018 | |||
export const contactPhone = new RegExp(/^[0-9-+()/\s.]+$/); |
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.
Use export default
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.
Using export default
as
const contactPhone = new RegExp(/^[0-9-+()/\s.]+$/);
export default contactPhone
gives me:
Error: Invalid definition for contact.phone field.
W20170313-13:04:17.232(2)? (STDERR) at packages/aldeed_simple-schema.js:1429:13
W20170313-13:04:17.233(2)? (STDERR) at Function._.each._.forEach (packages/underscore.js:147:22)
W20170313-13:04:17.233(2)? (STDERR) at [object Object].SimpleSchema (packages/aldeed_simple-schema.js:1426:5)
W20170313-13:04:17.234(2)? (STDERR) at meteorInstall.organizations.collection.schema.js (organizations/collection/schema.js:12:24)
W20170313-13:04:17.234(2)? (STDERR) at fileEvaluate (packages/modules-runtime.js:197:9)
W20170313-13:04:17.235(2)? (STDERR) at require (packages/modules-runtime.js:120:16)
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.
Of course, it gave. Use the correct import structure:
import contactPhone from '/path-to-library/';
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.
Oh, thanks. Missed that.
@apinf/developers can anybody help me with these regExs:
What are allowed characters here? |
Basically, anything with a @matleppa could you add a comment before those lines of code, to explain them in plain English? |
@brylie May be will be useful http://scriptular.com/ |
|
Open for suggestion on i18n token names and messages text. Otherwise, ready for review. |
core/lib/simple_schema_config.js
Outdated
@@ -12,8 +12,8 @@ SimpleSchema.messages({ | |||
{ exp: SimpleSchema.RegEx.Id, msg: '[label] must be a valid alphanumeric ID' }, | |||
{ exp: SimpleSchema.RegEx.Domain, msg: '[label] must be a valid domain' }, | |||
{ exp: SimpleSchema.RegEx.Email, msg: '[label] must be a valid e-mail address' }, | |||
{ exp: proxyBasePathRegEx, msg: 'Allowed characters for [label]: A-Z' }, | |||
{ exp: apiBasePathRegEx, msg: 'Allowed characters for [label]: A-Z' }, | |||
{ exp: proxyBasePathRegEx, msg: '[label] must begin and end with "/"' }, |
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 can't recall if it is difficult/impossible to internationalize these regex validation messages. Since they are defined in a common folder, rather than a client
folder, we may have encountered difficulties in the past.
@matleppa would you like to finish this PR review? |
Allowed alphanumeric characters and-.?$*+'() There should also be mentioned underscore _ |
The end of my earlier comment was misleading. -.?$*+'()/:#@!&,;= |
@matleppa done |
@matleppa it does not appear that this PR included code comments for the |
Closes #2160