Use custom data in react native, but give the error `Metadata is required`
See original GitHub issueHi, 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:
- Created 5 years ago
- Comments:7 (4 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Version
1.1.11
has been published with more descriptive error message in case ofmetadata
argument being of incorrect type.Yes.