Files
explore/lib/validations/url.ts
T
2023-04-12 12:14:46 -03:00

13 lines
196 B
TypeScript

export const validator = (value: string | undefined) => {
if (!value) {
return true;
}
try {
new URL(value);
return true;
} catch (error) {
return 'Incorrect URL';
}
};