Docsity

form example ratingf, Schemes and Mind Maps of Administrative Law

Toggle sidebar
bg1
Validation th ng dùngườ
Rule Mô tảVD
accepted Dùng khi ki m tra các ể
đi u kho n s d ng.ề ả ử ụ 'option' =>'accepted'
active_url
D li u nh p ph i ph i ữ ệ ậ ả ả
là url theo function
checkdnsrr c a PHP.ủ'path' =>'active_url'
after:date Ngày nh p ph i sau ậ ả
ngày đã cho. 'start_date' => 'required|date|after:tomorrow'
after_or_equal:date Ngày nh p ph i sau ậ ả
ho c b ng ngày đã cho.ặ ằ 'start_date' => 'required|date|after_or_equal:tomorrow'
alpha D li u nh p ph i là ữ ệ ậ ả
ch .ữ'name' =>'alpha'
alpha_dash
D li u nh p ph i là ữ ệ ậ ả
ch ho c s , bao g m ữ ặ ố ồ
d u g ch ngang "-" và ấ ạ
g ch d i "_".ạ ướ
'address' =>'alpha_dash'
alpha_num D li u nh p ph i là s .ữ ệ ậ ả ố 'number' =>'alpha_num'
array D li u nh p ph i là ữ ệ ậ ả
m ng PHP.ả'my_array' =>'array'
bail
S d ng ki m tra n u 1 ẽ ừ ể ế
validate đ u tiên không ầ
th a mãn.ỏ'name' =>'bail|require|max:255'
before:date Ngày nh p ph i tr c ậ ả ướ
ngày đã cho. 'end_date' => 'required|date|before:today'
before_or_equal:date
Ngày nh p ph i tr c ậ ả ướ
ho c b ng v i ngày đã ặ ằ ớ
cho.
'end_date' => 'required|date|before_or_equal:today'
between:min,max
D li u nh p ph i n m ữ ệ ậ ả ằ
trong giá tr min và max, ị
giá tr có th là chu i, sị ể ỗ ố
và file.
'age' =>'between:18,30'
boolean
D li u nh p ph i là có ữ ệ ậ ả
giá tr boolean: true ị
ho c false, 1 ho c 0, "1"ặ ặ
ho c "0".ặ
'remember_me' =>'boolean'
confirmed
D li u nh p ph i trùng ữ ệ ậ ả
kh p v i ớ ớ
name_confirmation
VD có 2
field:name="password"vàname="password_confirmation"
tr Validation s là:ị ẽ
'password' =>'required|confirmed|min:8'
date
D li u nh p ph i là ữ ệ ậ ả
ngày tháng, phù h p v iợ ớ
hàm strtotime c a PHP.ủ'date' =>'date'
date_equals:date D li u nh p ph i b ng ữ ệ ậ ả ằ 'date' =>'date_equals:22/03/2019'
pf3
pf4
pf5

Partial preview of the text

Download form example ratingf and more Schemes and Mind Maps Administrative Law in PDF only on Docsity!

Validation th ường dùng Rule Mô tả VD accepted Dùng khi ki ểm tra các đi ều kho ản s ử d ụng. 'option' =>'accepted' active_url D ữ li ệu nh ập ph ải ph ải là url theo function checkdnsrr c ủa PHP. 'path' =>'active_url' after:date Ngày nh ập ph ải sau ngày đã cho. 'start_date' => 'required|date|after:tomorrow' after_or_equal:date Ngày nh ập ph ải sau ho ặc b ằng ngày đã cho. 'start_date' => 'required|date|after_or_equal:tomorrow' alpha D ữ li ệu nh ập ph ải là ch ữ. 'name' =>'alpha' alpha_dash D ữ li ệu nh ập ph ải là ch ữ ho ặc s ố, bao g ồm d ấu g ạch ngang "-" và g ạch d ưới "_". 'address' =>'alpha_dash' alpha_num D ữ li ệu nh ập ph ải là s ố. 'number' =>'alpha_num' array D ữ li ệu nh ập ph ải là m ảng PHP. 'my_array' =>'array' bail S ẽ d ừng ki ểm tra n ếu 1 validate đ ầu tiên không th ỏa mãn. 'name' =>'bail|require|max:255' before:date Ngày nh ập ph ải tr ước ngày đã cho. 'end_date' => 'required|date|before:today' before_or_equal:date Ngày nh ập ph ải tr ước ho ặc b ằng v ới ngày đã cho. 'end_date' => 'required|date|before_or_equal:today' between:min,max D ữ li ệu nh ập ph ải n ằm trong giá tr min và max,ị giá tr có thị ể là chu ỗi, s ố và file. 'age' =>'between:18,30' boolean D ữ li ệu nh ập ph ải là có giá tr boolean: trueị ho ặc false, 1 ho ặc 0, "1" ho ặc "0". 'remember_me' =>'boolean' confirmed D ữ li ệu nh ập ph ải trùng kh ớp v ới name_confirmation VD có 2 field: name="password" và name="password_confirmation" tr Validation sị ẽlà: 'password' =>'required|confirmed|min:8' date D ữ li ệu nh ập ph ải là ngày tháng, phù h ợp v ới hàm strtotime c ủa PHP. 'date' =>'date' date_equals:date D ữ li ệu nh ập ph ải b ằng 'date' =>'date_equals:22/03/2019'

v ới ngày tháng đã cho, phù h ợp v ới hàm strtotime c ủa PHP. date_format: format D ữ li ệu nh ập ph ải gi ống đ nh dị ạng v ới format , đ nh dị ạng ph ải phù h ợp v ới hàm date_parse_from_format c ủa PHP. 'date' =>'date_format:d/m/Y' different:field D ữ li ệu nh ập ph ải khác v ới giá tr ị field.

VD: giá trị name="Nguy ễ n Văn A" , chúng ta mu ốn giá tr ị oth

vào khác v ới name, khi đó ta vi ết: 'other' =>'name' digits:value D ữ li ệu nh ập ph ải là s ố, có đ ộ dài b ằng value. 'code' =>'digits:3' digits_between:min,max D ữ li ệu nh ập ph ải là s ố, n ằm trong kho ảng min và max. 'code' =>'digits:3,8' dimensions D ữ li ệu nh ập ph ải là m ộ ảt nh, có kích th ước theo quy đ nh, có thị ểlà: min_width, max_width, min_height, max_height, width, height, ratio. 'image' =>'dimensions:min_width=50, min_height=100' distinct D ữ li ệu nh ập ph ải là mãng, và không có giá tr lị ặ p l ại. 'foo.*.id' => 'distinct' email D ữ li ệu nh ập ph ải là đ a ị ch email.ỉ 'email' =>'email' exists:table,column D ữ li ệu nh ập ph ải là c ột có trong b ảng t ồn t ại trong Database. 'column' =>'exists:news,title' file D ữ li ệu nh ập ph ải là m ột file t ải lên thành công. 'file' =>'file' filled D ữ li ệu nh ập không đ ược tr ống. 'name' =>'filled' gt:field D ữ li ệu nh ập ph ải l ớn h ơn tr ường field, và gi ống ki ểu d ữ li ệu nh ư: Strings, numerics, arrays. 'number' =>'gt:200' gte:field D ữ li ệu nh ập ph ải l ớn h ơn ho ặc b ằng tr ường field, và gi ống ki ểu d ữ li ệu nh ư: Strings, numerics, arrays. 'number' =>'gte:200' image D ữ li ệu nh ập ph ải là 'photo' =>'image'

regex:pattern D ữ li ệu nh ập ph ải gi ống v ới d ạng th ức cung c ấp. 'email' =>'regex:/^.+@.+$/i' required D ữ li ệu b ắt bu ộc ph ải đ ược nh ập, không đ ược đ ể tr ống. 'name' =>'required' required_if:anotherfield, value,... D ữ li ệu nh ập là b ắt bu ộc và th ỏa mãn đi ều ki ện nào đó. 'role_id' => Rule::requiredIf($request->user()->is_admin) required_unless:anotherfield , value,... D ữ li ệu nh ập là b ắt bu ộc và không đ ược theo đi ều ki ện nào đó 'role_id' => Rule::requiredIf($request->user()->is_guess) required_with:foo, bar, ... D ữ li ệu nh ập là b ắt bu ộc và ph ải ch ứa ít nh ất các giá tr cho ị tr ước. 'number' => 'required_with:3,5,7' required_with_all:foo, bar,... D ữ li ệu nh ập là b ắt bu ộc và ph ải ch ứa t ất c ả các giá tr cho trị ước. 'number' => 'required_with_all:3,5,7' required_without:foo, bar, ... D ữ li ệu nh ập là b ắt bu ộc và không đ ược ch ứa ít nh ất các giá tr ị cho tr ước. 'number' => 'required_without:3,5,7' required_without_all:foo, bar, ... D ữ li ệu nh ập là b ắt bu ộc và không đ ược ch ứa t ất c ả các giá trị cho tr ước. 'number' => 'required_without_all:3,5,7' same:field D ữ li ệu nh ập ph ải trùng kh ớp v ới field. 'email' =>'same:old_email' size:value D ữ li ệu nh ập ph ải cùng ki ểu v ới value, chu ỗi thì là string, s ốthì là integer,... 'file' =>'size:300' starts_with:foo,bar,... D ữ li ệu nh ập ph ải b ắt đ ầu m ột giá tr đ ị ưa tr ước. 'number' =>'starts_with:5' string D ữ li ệu nh ập ph ải là string, n ếu mu ốn d ữ li ệu nh ập có th ểmang giá trị null , thì c ần thêm đi ều ki ện nullable. 'title' =>'string' timezone D ữ li ệu nh ập ph ải có giá tr timezone đị ược xác đ nh theo functionị timezone_identifiers_list c ủa PHP. 'time' =>'timezone' unique:table, column, except, idColumn D ữ li ệu nh ập ph ải là duy nh ất trong b ảng CSDL, 'email' =>'unique:users,email_address'

n ếu tên colum không đ ược s ử d ụng thì tr ường name s ẽ đ ược dùng. unique:()->ignore() D ữ li ệu nh ập ph ải là duy nh ất và b ỏ qua tr ường nào đó. 'email' =>Rule::unique('users')->ignore($user->id) unique:()->where() D ữ li ệu nh ập ph ải là duy nh ất và th ỏa mãn ph ương th ức where. 'email' =>Rule::unique('users') ->where(function ($query) { return $query->where('account_id', 1); }) url D ữ li ệu nh ập ph ải là d ạng url. 'path' =>'url' uuid D ữ li ệu nh ập ph ải mang giá tr RFC 4122 (phiênị b ản 1,3,4 ho ặc 5) đ nh ị danh duy nh ất trên toàn c ầu (UUID). 'uuid' =>'uuid'