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

Add length validation to text input #3193

Merged
merged 1 commit into from Mar 1, 2018

Conversation

Projects
None yet
2 participants
@bpedersen2
Contributor

bpedersen2 commented Dec 21, 2017

This change allows to enforce minimum and maximum length
limit and/or pattern restrictions for regform text input fields.

@ThiefMaster ThiefMaster changed the base branch from v2.1-dev to master Jan 12, 2018

@bpedersen2 bpedersen2 force-pushed the bpedersen2:field_limits branch 3 times, most recently from 2e4bca3 to fcd1b69 Jan 26, 2018

</label>
<input type="text" name="validpattern"
ng-model="formData.validPattern"
>

This comment has been minimized.

@ThiefMaster

ThiefMaster Jan 29, 2018

Member

should go in the previous line (also two more times above)

This comment has been minimized.

@bpedersen2

bpedersen2 Jan 30, 2018

Contributor

done

<input type="text" name="validpattern"
ng-model="formData.validPattern"
>
<i class="info-helper" title="{{ 'Validation pattern for input , see https://www.w3schools.com/jsref/jsref_obj_regexp.asp }}' | i18n }}"></i>

This comment has been minimized.

@ThiefMaster

ThiefMaster Jan 29, 2018

Member

Even though w3schools isn't as awful as they used to be (but the still sell those phony "html certificates"), I don't want a link to them in Indico ;) (also, there shouldn't be a space before the ,).

Maybe letting users specify regex patterns here is a bit overkill anyway...

This comment has been minimized.

@bpedersen2

bpedersen2 Jan 30, 2018

Contributor

removed the link.

Using pattern validation can e.g. be used if you need special input from the registrants (e.g only uppercaser, no spaces, etc.)

<input type="number" name="maxlength"
ng-model="formData.maxLength"
>
<i class="info-helper" title="{{ 'Maximimum allowed length' | i18n }}"></i>

This comment has been minimized.

@ThiefMaster

ThiefMaster Jan 29, 2018

Member

to many spaces

This comment has been minimized.

@bpedersen2

bpedersen2 Jan 30, 2018

Contributor

done

@bpedersen2 bpedersen2 force-pushed the bpedersen2:field_limits branch from fcd1b69 to c85d19a Jan 30, 2018

{{ 'Validation pattern' | i18n }}
</label>
<input type="text" name="validpattern" ng-model="formData.validPattern">
<i class="info-helper" title="{{ 'Validation pattern(a javascript regualr expression) }}' | i18n }}"></i>

This comment has been minimized.

@ThiefMaster

ThiefMaster Feb 9, 2018

Member

missing space before ( and a typo (regualr).

Anyway, I still don't like the idea of having the pattern option. Yes, it is powerful, but eventually we want server-side validation for this stuff and except when restricting yourself to a common subset of the regex features of HTML5/JS and Python, that won't be guaranteed to work on both sides...

Also, having user-provided regexps run on the server may be risky - usually there are some ways to write regular expressions that result in horrible performance.

This comment has been minimized.

@bpedersen2

bpedersen2 Feb 9, 2018

Contributor

I splitted this part out, as regexp validation is not too important for now.

ng-class="{
hasError: validationStarted && nestedForm.$invalid
}"/>
<span ng-show="validationStarted && nestedForm.$invalid && nestedForm.$error.minlength" class="error-message-tag">

This comment has been minimized.

@ThiefMaster

ThiefMaster Feb 9, 2018

Member

double space before class (same below)

This comment has been minimized.

@bpedersen2

bpedersen2 Feb 9, 2018

Contributor

fixed

@bpedersen2 bpedersen2 force-pushed the bpedersen2:field_limits branch from c85d19a to 5ad5e30 Feb 9, 2018

@ThiefMaster ThiefMaster changed the title from Add length and pattern validation to text input to Add length validation to text input Feb 12, 2018

@bpedersen2 bpedersen2 force-pushed the bpedersen2:field_limits branch 3 times, most recently from 6e5cc39 to c213091 Feb 13, 2018

@bpedersen2

This comment has been minimized.

Contributor

bpedersen2 commented Feb 28, 2018

Ping...

@bpedersen2 bpedersen2 force-pushed the bpedersen2:field_limits branch from c213091 to 9ed5f8a Mar 1, 2018

@ThiefMaster ThiefMaster force-pushed the bpedersen2:field_limits branch from 9ed5f8a to 8e09652 Mar 1, 2018

Add length validation to text input
This change allows to enforce minimum and maximum length
limit for registration form text input fields.

@ThiefMaster ThiefMaster force-pushed the bpedersen2:field_limits branch from 8e09652 to 972375e Mar 1, 2018

@ThiefMaster ThiefMaster merged commit 972375e into indico:master Mar 1, 2018

1 check was pending

continuous-integration/travis-ci/pr The Travis CI build is in progress
Details
@ThiefMaster

This comment has been minimized.

Member

ThiefMaster commented Mar 1, 2018

Don't worry, we didn't forget about it - just busy with other things ;)

It's cleaned up (typos etc.) and merged now. Thanks for the PR!

@bpedersen2 bpedersen2 deleted the bpedersen2:field_limits branch Mar 2, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment