# validate — Input Validation > `import { validateUrl, validateEmail, validateDate, validateSpecialChar, SPECIAL_CHAR } from 'puffy-core/validate'` > CJS: `const { validate: { validateUrl, validateEmail, validateDate, validateSpecialChar, SPECIAL_CHAR } } = require('puffy-core')` > Also available in snake_case: `validate_url`, `validate_email`, `validate_date`, `validate_special_char` --- ## validateUrl Validates a URL string using regex. ### Signature ``` validateUrl(value?: string) → boolean ``` ### Examples ```js validateUrl('https://neap.co') // true validateUrl('http://localhost:3000') // true validateUrl('https://example.com/path') // true validateUrl('hello') // false validateUrl('') // false validateUrl() // false ``` GOTCHA: This validator rejects private/internal IP addresses (10.x.x.x, 127.x.x.x, 169.254.x.x, 192.168.x.x, 172.16-31.x.x). If you need to validate internal URLs, this function will return `false` for them. --- ## validateEmail Validates an email address string using regex. ### Signature ``` validateEmail(value?: string) → boolean ``` ### Examples ```js validateEmail('nic@neap.co') // true validateEmail('user@example.com') // true validateEmail('nic @neap.co') // false — space not allowed validateEmail('not-an-email') // false validateEmail('') // false validateEmail() // false ``` --- ## validateDate Checks if a value is a valid Date object. ### Signature ``` validateDate(d: any, options?: { exception?: { toggle?: boolean, message?: string } }) → boolean ``` Parameters: - `d`: Value to check - `options.exception.toggle`: If `true`, throws instead of returning `false` - `options.exception.message`: Custom error message when throwing ### Examples ```js validateDate(new Date()) // true validateDate(new Date('2021-10-12')) // true validateDate(new Date('invalid')) // false validateDate('2021-10-12') // false — string, not a Date // Throwing mode: validateDate(new Date('invalid'), { exception: { toggle:true, message:'Bad date' } }) // throws Error('Bad date') ``` --- ## validateSpecialChar Checks if a string contains any special character. ### Signature ``` validateSpecialChar(value?: string) → boolean ``` ### Examples ```js validateSpecialChar('hello!') // true — contains ! validateSpecialChar('hello@world') // true — contains @ validateSpecialChar('hello world') // true — space is a special character validateSpecialChar('hello') // false — no special characters validateSpecialChar('') // false validateSpecialChar() // false ``` --- ## SPECIAL_CHAR String constant containing all recognized special characters. ```js SPECIAL_CHAR // ' !"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~' ``` Note: Space is included as a special character.