Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed #452 #454

Merged
merged 5 commits into from
Jun 23, 2020
Merged

Fixed #452 #454

merged 5 commits into from
Jun 23, 2020

Conversation

bytestream
Copy link
Collaborator

Description

Uses $.each on array inputs. Array inputs are only returned on select-multiple elements.

This fix somewhat clashes with #453

In the case of ['domain' => 'array', 'domain.*' => 'max:2'] arrayRules overwrites the 'domain' rules.

validator.showErrors();
} else {
var errors = {};
errors[element.name] = previous.message = $.isFunction(message) ? message(value) : message;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is too long.

if (laravelValidation.methods[rule] !== undefined) {
$.each(values, function(index, value) {
validated = laravelValidation.methods[rule].call(validator, value, element, param[1], function(valid) {
validator.settings.messages[element.name].laravelValidationRemote = previous.originalMessage;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is too long.

validator.showErrors( errors );
if (laravelValidation.methods[rule] !== undefined) {
$.each(values, function(index, value) {
validated = laravelValidation.methods[rule].call(validator, value, element, param[1], function(valid) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is too long.

if ( !implicit && validator.optional( element ) ) {
validated="dependency-mismatch";
if (! implicit && validator.optional(element)) {
validated = "dependency-mismatch";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mixed double and single quotes.

$.each(rules, function (i, param) {
var implicit = param[3] || laravelValidation.implicitRules.indexOf(param[0])!== -1;
var implicit = param[3] || laravelValidation.implicitRules.indexOf(param[0]) !== -1;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is too long.

@bytestream
Copy link
Collaborator Author

If you use ['domain' => ['array', 'max:2']] then what previously worked may now fail. It would run max:2 on each array item instead of the whole array.

Ideally need to split it so rules without [*] do not use $.each and those with [*] use $.each

if (param[3] || laravelValidation.implicitRules.indexOf(param[0]) !== -1) {
isArrayRule ? arrayRules.unshift(param) : rules.unshift(param);
} else {
isArrayRule ? arrayRules.push(param) : rules.push(param);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expected an assignment or function call and instead saw an expression.

// put Implicit rules in front
var isArrayRule = param[4].indexOf('[') !== -1;
if (param[3] || laravelValidation.implicitRules.indexOf(param[0]) !== -1) {
isArrayRule ? arrayRules.unshift(param) : rules.unshift(param);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expected an assignment or function call and instead saw an expression.

$.each(params, function (i, param) {
// put Implicit rules in front
var isArrayRule = param[4].indexOf('[') !== -1;
if (param[3] || laravelValidation.implicitRules.indexOf(param[0]) !== -1) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is too long.

* Create JQueryValidation check to validate Laravel rules.
*/

$.validator.addMethod("laravelValidation", function (value, element, params) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mixed double and single quotes.

if (name in cache[element.name]) {
$.extend(rules, cache[element.name][name]);
rules = laravelValidation.helpers.mergeRules(rules, cache[element.name][name]);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is too long.

continue;
}

if (typeof rules[key] === "undefined") {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mixed double and single quotes.

'laravelValidationRemote': newRules.laravelValidationRemote || []
};

for (var key in rulesList) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The body of a for in should be wrapped in an if statement to filter unwanted properties from the prototype.

This was linked to issues Jun 22, 2020
@bytestream bytestream added the bug label Jun 22, 2020
var errors = {};
errors[ element.name ]
= previous.message
= typeof message === "function" ? message( value ) : message;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is too long.
Misleading line break before '='; readers may interpret this as an expression boundary.
Mixed double and single quotes.

} else {
var errors = {};
errors[ element.name ]
= previous.message

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Misleading line break before '='; readers may interpret this as an expression boundary.

@bytestream bytestream merged commit 6ee5097 into proengsoft:master Jun 23, 2020
@bytestream bytestream mentioned this pull request Jun 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

array field validation select-multiple validation error
2 participants