question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Use custom data in react native, but give the error `Metadata is required`

See original GitHub issue

Hi, really appreciate your library. I have a little problem in react native.

When I use the custom metadata in my project.

Since I use typescript, so I need to write a phonenumber.d.ts file to declare the function(And I have found there is no custom folder in node_modules/libphonenumber-js)

declare module "libphonenumber-js/custom" {
  export function isValidNumber(
    val: string,
    country?: string,
    metadata?: object
  ): boolean;
}

And then I use it as frontend validation

import { isValidNumber } from "libphonenumber-js/custom";
import metadata from "../metadata.min.json";

if (
      rules.isValidPhoneNumber &&
      !isValidNumber(valStr, "JP", metadata)
    ) {
      return "phone_number_invalid";
}

the code works well but the test cases give me the error

Error for phone: Error: Metadata is required

Each function related to phone validation will be broken due to this error, but I don’t know how to fixed it. Can you help me with that? thanks in advance : )

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
catamphetaminecommented, Apr 23, 2018

Version 1.1.11 has been published with more descriptive error message in case of metadata argument being of incorrect type.

0reactions
annewanghycommented, Apr 24, 2018

Yes.

Read more comments on GitHub >

github_iconTop Results From Across the Web

I have an error when I build react native - Stack Overflow
Unable to load Maven meta-data from https://jcenter.bintray.com/com/facebook/react/react-native/maven-metadata.xml.
Read more >
DOM Attributes in React 16
With the new approach, both of these problems are solved. With React 16, you can now pass custom attributes to all HTML and...
Read more >
Images - React Native
If you are building a hybrid app (some UIs in React Native, some UIs in platform code) you can still use images that...
Read more >
Customizing error reports - React - Bugsnag docs
Learn how to modify and send custom diagnostic data to JavaScript error reports. Automatically captured reports include a stacktrace, browser info, ...
Read more >
<Field /> | Formik
meta : An object containing metadata (i.e. value , touched , error , and initialValue ) about the field (see FieldMetaProps ). component...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found