I'm facing a problem while validating an Email in react-native.
Currently I'm using email-validator and it's working fine. I'm not using email verification in my App, so I need to check precisely whether input is email or not.
I'm looking for a technique which can identify following as an invalid email because it has a word more then once after #
User#mail.com
User#mail.mail.com
User#mail.com.com.uk
User#mail.com.com
Valid email should be like this.
User#mail.com
User#mail.com.uk
User#mail.com.edu.uk
A regular expression would probably be more efficient if anyone else want's to provide one, but here's one way to do it in a function:
var email = "User#mail.mail.com";
let findDuplicates = (arr) => arr.filter((item, index) => arr.indexOf(item) != index);
let hasDuplicate = (test) => findDuplicates(test.split("#")[1].split(".")).length > 0
console.log(hasDuplicate(email));
Related
I'm trying to embed a Zoho CRM by iframe into an application that knows only a phone number.
(Ramble: Originally I intended to call the Zoho api to lookup the Contact by phone number and redirect to or load the Contact's Zoho page - but the hosting app doesn't seem to support enough features to accommodate Zoho's OAuth2-only authentication - so I think I'm stuck with Zoho Deluge which I'm finding to be an ATROCIOUS language)
I'm hoping to GET navigate to this Zoho Function with the phone number as a parameter, have it find the unique match, and redirect to the customer details.
response = zoho.crm.searchRecords(
"Contacts",
"", // no criteria - I hope the later parameter
// normalizes better than this would?
1, // first page
2, // of two max results - just to verify uniqueness
"{ phone: '" + phoneNumber + "'}"); // Docs are terrible. Is this the format?
// I also tried "phone:equal:..."
//if (1 < response.size()) { // script errors show up on nonsense line
// return "[Ambiguous]"; // numbers, but this seems to work until later
//} // lines are included - then errors point here
return response; // Works, but useless string output
return response.firstName; // "Invalid collection object found" - but not expected to work
return response.get(0); // 'TEXT' can not be cast to '[KEY-VALUE, TEXT, LIST]' for the function 'get'
return response.get('firstName'); // 'TEXT' can not be cast to '[KEY-VALUE, TEXT, LIST]' for the function 'get'
return response.get(0).firstName; // Improper Statement Error might be due to missing ';' at end of the line or incomplete expression
// openUrl( <string>, <window_type> ); // hoping to get here
I've also tried variations on returning from inside a for each element loop, no luck.
I THINK I've successfully found the user by phone number because I think I indeed get one match, but I can't verify it and I don't know how to derive the url of the customer detail page for the openUrl() call. Do you know how to make progress on this?
The criteria is malformed, and function searchRecords returns a list of maps.
To access the first element of al list you must use .get(0) and get an element of a map .get("First_Name")
The fields are malformed, you must get the API name of the field form crm.zoho.com->setup->API->API names->Contacts
You can use info to debug the response (info response;)
Zoho CRM API Search records
toReturn = "";
response = zoho.crm.searchRecords("Contacts", "Phone:equals:" + phoneNumber, 1, 2);
if (1 < response.size()) {
toReturn = "[Ambiguous]";
} else if (0 == response.size()) {//error triggered if use get(0) of emty list
toReturn = "[None]";
}else {
toReturn = reponse.get(0).get("First_Name");
openUrl("https://crm.zoho.com/crm/org[yourOrgID]/tab/Contacts/" + reponse.get(0).get("id"), "new window");
}
return toReturn;
i have a field in Laravel with the name "company_url". and its stored like this.
$post['company_url'] = "http://example.org";
and then i have a rule string which i have stored for validation which must be applied on this individual field. which is stored like this
$post['rule'] = "required|max:24";
now i am trying this code to get validation errors. which is not working.
$validator = Validator::make([$post['name']], [$post['rules']]);
tell me what is the way to get errors on this validation?
The data you're passing to make() is in incorrect format. It should be in key-value pair format.
Also I don't know where the $post['name'] coming from. I assume it is company_url not name.
$post['rules'] is also undefined. It should be $post['rule']
The following should work:
$validator = Validator::make(['company_url' => $post['company_url']], ['company_url' => $post['rule']]);
For a specific use case, we need to add external users to our AD and allow these to login through AD FS to an external service.
Everything was set up with only internal users in mind, so we wrote a claim rule as follows:
c:[Type == "http://schemas.microsoft.com/ws/2008/06/identity/claims/windowsaccountname", Issuer == "AD AUTHORITY"]
=> issue(store = "Active Directory", types = ("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname"), query = ";sAMAccountName;{0}", param = c.Value);
Basically, this is LDAP Attribute "SAM-Account-Name", and Outgoing Claim Type "Given Name". This works well for internal users.
For external users, there's a use case where the user name in the external site should be the email address used in AD. The easiest thing would be to fill in the email address in the sAMAccountName, but it doesn't allow # symbols.
So I was messing around with claim transformation rules, and figured I could try to add two conditional claim rules, as follows:
Internal users:
c:[Type == "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress", Value =~ "domain.com$"]
=> issue(store = "Active Directory", types = ("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname"), query = ";sAMAccountName;{0}", param = c.Value);
External users:
c:[Type == "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress", Value !=~ "domain.com$"]
=> issue(store = "Active Directory", types = ("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname"), query = ";mail;{0}", param = c.Value);
The first claim rule checks if the email address ends with "domain.com", and if so, it will use the sAmAccountName (internal users).
The second claim rule does the reverse: if it doesn't end with "domain.com", it will use the mail attribute (external users).
But pity, it's not working (either one tested separately).
What's wrong with my approach?
Obvious attempt here is to get phone calls by a specific account ID, and ONLY phonecalls which have a regardingobject type of "account" (this is only a basic part of the full call, but even this fails).
var linqPhonecalls = from pc in svcContext.PhoneCallSet
where ((pc.RegardingObjectId.Id == account.Id) && (pc.RegardingObjectId.LogicalName == "account"))
select new
{
subj = pc.Subject,
stateCD = pc.StateCode,
};
Through research on the net I ran into this idea ( http://informeddynamicscrm.blogspot.com/2012/01/linq-restrictions-with-crm-2011-xrm.html ) and tried the following:
pc.RegardingObjectId.LogicalName.Equals("account") == true
As well as using Contains() and any other comparison operations I could try. It seems like the major problem here is the use of .LogicalName (also tried .Name)
Because I can't get it to work, I'm going to leave that check out of the equation for now, but I'd really like to put it in there because I'm going to be joining against other regarding types and want to sort things out.
I'm trying to build a custom form for a joomla website that allows users to complete some fields and attach a document that will be sent to an email address I can specify.
Does anyone know of any good components or plugins for accomplishing this ?
$from: This is the the email address that the email will look like it is coming from.
$fromname: This is the name of the person or organization this email is coming from.
$recipient: This is the email address (or array of email addresses) that the email will be going to.
$subject: This is the Subject of the email.
$body: The is the message body of the email.
$mode: Set this to 1 for HTML email, set it to 0 for text email. This field is optional.
$cc: This is the email address (or array of email addresses) that the email will be Carbon Copied to. This field is optional.
$bcc: This is the email address (or array of email addresses) that the email will be Blind Carbon Copied to. This field is optional.
$attachment: This is the full path and filename (or array of full paths and filenames) of the files that you wish to attach to the email. This field is optional.
$replyto: This is the the email address that the email will go to if the recipient clicks reply. This field is optional.
$replytoname: This is the name of the person or organization this email will go to if the recipient clicks reply. This field is optional.
Now that you know how that works, let's look at an example!
$from = 'admin#somewhere.com';
$fromname = 'BIGSHOT Blog';
$recipient[] = 'john#somewhere.com';
$recipient[] = 'jane#somewhere.com';
$subject = 'Want to learn about BIGSHOT Blog';
$body = '<p>Check us out!</p><p>http://www.somewhere.com</p>';
$mode = 1;
$cc = 'bob#somewhereelse.com';
$bcc[] = 'simon#somewhereelse.com';
$bcc[] = 'nick#somewhereelse.com';
$attachment[] = '/home/my_site/public_html/images/stories/food/coffee.jpg';
$attachment[] = '/home/my_site/public_html/images/stories/food/milk.jpg';
$replyto = 'no_reply#somewhere.com';
$replytoname = 'NO REPLY - BIGSHOT Blog';
JUtility::sendMail($from, $fromname, $recipient, $subject, $body, $mode, $cc, $bcc, $attachment, $replyto, $replytoname);
You can use JUtility::sendMail to send an email in Joomla with attachment.For more information how to use go to this link.
JUtility/sendMail
A little more digging on the joomla extensions directory and I think I found what I need: http://extensions.joomla.org/extensions/contacts-and-feedback/contact-forms/11494