API & Web Validators

API validators for HTTP methods, JSON schemas, request/response handling, and webhook verification.

19 code snippets available

URL (Strict)

api

HTTP/HTTPS required.

#web
ts
const isValid = (s: string): boolean => /^(https?:\/\/)?([\w-]+\.)+[\w-]+(\/[^\s]*)?$/.test(s);

JSON Pointer

api

RFC 6901 JSON pointer.

#json#pointer
ts
const isValid = (s: string): boolean => /^\/([^/~]|~[01])*$/.test(s);

Content-Type Header

api

HTTP Content-Type format.

#http#header
ts
const isValid = (s: string): boolean => /^[a-z]+\/[a-z0-9.+-]+(;\s*[a-z]+=\S+)*$/.test(s);

HTTP Method

api

Valid HTTP methods.

#http#method
ts
const isValid = (s: string): boolean => /^(GET|POST|PUT|PATCH|DELETE|HEAD|OPTIONS|TRACE|CONNECT)$/.test(s);

Accept Header

api

HTTP Accept format.

#http#header
ts
const isValid = (s: string): boolean => /^[a-z]+\/[a-z0-9*+.-]+(,\s*[a-z]+\/[a-z0-9*+.-]+)*$/.test(s);

Cookie Format

api

HTTP cookie format.

#http#cookie
ts
const isValid = (s: string): boolean => /^[a-zA-Z0-9_-]+=.+$/.test(s);

ETag

api

HTTP ETag format.

#http#cache
ts
const isValid = (s: string): boolean => /^(W\/)?"[^"]*"$/.test(s);

HTTP 200

api

Status code 200.

#http
ts
const isValid = (s: string): boolean => /^200$/.test(s);

HTTP 201

api

Status code 201.

#http
ts
const isValid = (s: string): boolean => /^201$/.test(s);

HTTP 204

api

Status code 204.

#http
ts
const isValid = (s: string): boolean => /^204$/.test(s);

HTTP 301

api

Status code 301.

#http
ts
const isValid = (s: string): boolean => /^301$/.test(s);

HTTP 302

api

Status code 302.

#http
ts
const isValid = (s: string): boolean => /^302$/.test(s);

HTTP 400

api

Status code 400.

#http
ts
const isValid = (s: string): boolean => /^400$/.test(s);

HTTP 401

api

Status code 401.

#http
ts
const isValid = (s: string): boolean => /^401$/.test(s);

HTTP 403

api

Status code 403.

#http
ts
const isValid = (s: string): boolean => /^403$/.test(s);

HTTP 404

api

Status code 404.

#http
ts
const isValid = (s: string): boolean => /^404$/.test(s);

HTTP 500

api

Status code 500.

#http
ts
const isValid = (s: string): boolean => /^500$/.test(s);

HTTP 502

api

Status code 502.

#http
ts
const isValid = (s: string): boolean => /^502$/.test(s);

HTTP 503

api

Status code 503.

#http
ts
const isValid = (s: string): boolean => /^503$/.test(s);

About API & Web Validators

Our api & web validation snippets are designed to handle the most common validation scenarios you'll encounter in modern software development. Each snippet is thoroughly tested, optimized for performance, and follows industry best practices.

All validators are available in multiple programming languages including JavaScript, TypeScript, Python, Go, PHP, C#, and Rust. Simply copy the code snippet, adapt it to your specific needs, and integrate it into your project. Every snippet is MIT licensed—free for personal and commercial use.

Browse Other Categories