Skip to content

Commit

Permalink
Merge branch 'davidreyg-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
amir9480 committed Apr 13, 2024
2 parents 1f450ac + b887d6e commit f48c594
Showing 1 changed file with 37 additions and 12 deletions.
49 changes: 37 additions & 12 deletions src/ValidationProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,33 @@ export default class ValidationProvider implements vscode.CompletionItemProvider
private rules: any = {
'accepted' : 'accepted',
'active_url' : 'active_url',
'after' : 'after:date',
'after_or_equal' : 'after_or_equal:${0:date}',
'alpha' : 'alpha',
'after' : 'after:date',
'alpha_dash' : 'alpha_dash',
'alpha_num' : 'alpha_num',
'alpha' : 'alpha',
'array' : 'array',
'ascii' : 'ascii',
'bail' : 'bail',
'before' : 'before:${1:date}',
'before_or_equal' : 'before_or_equal:${1:date}',
'before' : 'before:${1:date}',
'between' : 'between:${1:min},${2:max}',
'boolean' : 'boolean',
'confirmed' : 'confirmed',
'date' : 'date',
'current_password' : 'current_password:${1:api}',
'date_equals' : 'date_equals:${1:date}',
'date_format' : 'date_format:${1:format}',
'date' : 'date',
'decimal' : 'decimal:${1:min},${2:max}',
'declined_if' : 'declined_if:${1:anotherfield},${2:value}',
'declined' : 'declined',
'different' : 'different:${1:field}',
'digits' : 'digits:${1:value}',
'digits_between' : 'digits_between:${1:min},${2:max}',
'digits' : 'digits:${1:value}',
'dimensions' : 'dimensions',
'distinct' : 'distinct',
'doesnt_end_with' : 'doesnt_end_with:${1:foo},${2:bar}',
'doesnt_start_with' : 'doesnt_start_with:${1:foo},${2:bar}',
'email' : 'email',
'ends_with' : 'ends_with:${1}',
'exists' : 'exists:${2:table},${3:column}',
Expand All @@ -36,39 +43,50 @@ export default class ValidationProvider implements vscode.CompletionItemProvider
'gt' : 'gt:${1:field}',
'gte' : 'gte:${1:field}',
'image' : 'image',
'in' : 'in:${1:something},${2:something else}',
'in_array' : 'in_array:${1:anotherfield.*}',
'in' : 'in:${1:something},${2:something else}',
'integer' : 'integer',
'ip' : 'ip',
'ipv4' : 'ipv4',
'ipv6' : 'ipv6',
'json' : 'json',
'lowercase' : 'lowercase',
'lt' : 'lt:${1:field}',
'lte' : 'lte:${1:field}',
'mac_address' : 'mac_address',
'max_digits' : 'max_digits:${1:value}',
'max' : 'max:${1:value}',
'mimetypes' : 'mimetypes:${1:text/plain}',
'mimes' : 'mimes:${1:png,jpg}',
'mimetypes' : 'mimetypes:${1:text/plain}',
'min_digits' : 'min_digits:${1:value}',
'min' : 'min:${1:value}',
'multiple_of' : 'multiple_of:${1:value}',
'not_in' : 'not_in:${1:something},${2:something else}',
'not_regex' : 'not_regex:${1:pattern}',
'nullable' : 'nullable',
'numeric' : 'numeric',
'password' : 'password',
'present' : 'present',
'prohibited_if' : 'prohibited_if:${1:anotherfield},${2:value}',
'prohibited_unless' : 'prohibited_unless:${1:anotherfield},${2:value}',
'prohibited' : 'prohibited',
'regex' : 'regex:${1:pattern}',
'required' : 'required',
'required_array_keys' : 'required_array_keys:${1:foo},${2:bar}',
'required_if' : 'required_if:${1:anotherfield},${2:value}',
'required_unless' : 'required_unless:${1:anotherfield},${2:value}',
'required_with' : 'required_with:${1:anotherfield}',
'required_with_all' : 'required_with_all:${1:anotherfield},${2:anotherfield}',
'required_without' : 'required_without:${1:anotherfield}',
'required_with' : 'required_with:${1:anotherfield}',
'required_without_all' : 'required_without_all:${1:anotherfield},${2:anotherfield}',
'required_without' : 'required_without:${1:anotherfield}',
'required' : 'required',
'same' : 'same:${1:field}',
'size' : 'size:${1:value}',
'sometimes' : 'sometimes',
'starts_with' : 'starts_with:${1:foo},${2:bar}',
'string' : 'string',
'timezone' : 'timezone',
'unique' : 'unique:${1:table},${2:column},${3:except},${4:id}',
'uppercase' : 'uppercase',
'url' : 'url',
'uuid' : 'uuid',
};
Expand All @@ -80,7 +98,14 @@ export default class ValidationProvider implements vscode.CompletionItemProvider
if (
(func && func.paramIndex !== null && func.function && Helpers.tags.validation.functions.some((fn:string) => func.function.includes(fn))) ||
(func && func.paramIndex !== null && func.class && Helpers.tags.validation.classes.some((cls:string) => func.class.includes(cls))) ||
(document.getText().match(/class .* extends FormRequest/g) && document.getText().match(/use Illuminate\\Foundation\\Http\\FormRequest;/g))
(document
.getText()
.match(/class .* extends (\S+Request)/g) ||
document
.getText()
.match(
/use (Illuminate\\Foundation\\Http\\FormRequest)/g
))
) {
var rules = this.rules;
Object.assign(rules, vscode.workspace.getConfiguration("LaravelExtraIntellisense.customValidationRules"));
Expand All @@ -93,4 +118,4 @@ export default class ValidationProvider implements vscode.CompletionItemProvider
}
return out;
}
}
}

0 comments on commit f48c594

Please sign in to comment.