LLaraNode
Validator Package

Validation Rules

LaraNode provides 50+ validation rules matching Laravel's API.

Validation Rules

LaraNode provides 50+ validation rules matching Laravel's API.

String Rules

RuleDescription
stringMust be a string
max:NMaximum length
min:NMinimum length
size:NExact length
between:min,maxLength between range
regex:patternMatch regex pattern
starts_with:valueStarts with value
ends_with:valueEnds with value
contains:valueContains value

Numeric Rules

RuleDescription
integerMust be an integer
numericMust be a number
min:NMinimum value
max:NMaximum value
size:NExact value
between:min,maxValue between range
gt:fieldGreater than field
gte:fieldGreater than or equal
lt:fieldLess than field
lte:fieldLess than or equal

Type Rules

RuleDescription
requiredMust be present and not empty
nullableCan be null
sometimesOnly validate if present
presentMust be present (can be empty)
booleanMust be boolean
arrayMust be an array
jsonMust be valid JSON

Format Rules

RuleDescription
emailValid email address
urlValid URL
uuidValid UUID
phoneValid phone number
credit_cardValid credit card
dateValid date
timeValid time
datetimeValid datetime
date_format:formatMatch date format
timezoneValid timezone

Date Comparison

RuleDescription
before:dateBefore date
before_or_equal:dateBefore or equal
after:dateAfter date
after_or_equal:dateAfter or equal
date_equals:dateEquals date

Value Rules

RuleDescription
in:a,b,cMust be in list
not_in:a,b,cMust not be in list
same:fieldMust match field
different:fieldMust differ from field
acceptedMust be yes/on/1/true
declinedMust be no/off/0/false
confirmedMust match field_confirmation

Database Rules

RuleDescription
exists:table,columnMust exist in database
unique:table,columnMust be unique in database

Conditional Rules

RuleDescription
required_if:field,valueRequired if field equals value
required_unless:field,valueRequired unless field equals value
required_with:fieldsRequired if any fields present
required_with_all:fieldsRequired if all fields present
required_without:fieldsRequired if any fields missing
required_without_all:fieldsRequired if all fields missing

File Rules

RuleDescription
fileMust be a file
mimes:jpg,pngAllowed MIME types
max_file_size:mbMaximum file size in MB

Examples

{
  name: 'required|string|max:255',
  email: 'required|email|unique:users,email',
  password: 'required|min:8|confirmed',
  age: 'required|integer|between:18,100',
  role: 'required|in:admin,user,moderator',
  website: 'nullable|url',
  birthday: 'required|date|before:2006-01-01',
  terms: 'required|accepted',
  tags: 'required|array',
  'tags.*': 'string|max:50',
}

Next Steps