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

Subsequent step for implementing HTML form validation #14566

Closed
wants to merge 1 commit into from

Conversation

@xilaili
Copy link

xilaili commented Dec 13, 2016

Form validation project. NCSU M1653 student project.


  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes fix #__ (github issue number if applicable).
  • There are tests for these changes OR
  • These changes do not require tests because _____

This change is Reviewable

@highfive
Copy link

highfive commented Dec 13, 2016

Thanks for the pull request, and welcome! The Servo team is excited to review your changes, and you should hear from @Manishearth (or someone else) soon.

@highfive
Copy link

highfive commented Dec 13, 2016

Heads up! This PR modifies the following files:

  • @fitzgen: components/script/dom/htmlformelement.rs, components/script/dom/htmlinputelement.rs, components/script/dom/validitystate.rs
  • @KiChjang: components/script/dom/htmlformelement.rs, components/script/dom/htmlinputelement.rs, components/script/dom/validitystate.rs
@highfive
Copy link

highfive commented Dec 13, 2016

warning Warning warning

  • These commits modify script code, but no tests are modified. Please consider adding a test!
Err(err) => {
match err[0] {
FormSubmittableElement::InputElement(ref i) =>
println!("First element didn't pass: {}",

This comment has been minimized.

@Manishearth

Manishearth Dec 13, 2016

Member

Please don't print to stdout.

@jdm Thought on how this should be reported?

This comment has been minimized.

@jdm

jdm Dec 15, 2016

Member

Stdout is all we've got at the moment. We should be calling Focus() on the element, however.

@Manishearth
Copy link
Member

Manishearth commented Dec 13, 2016

r? @jdm

@highfive highfive assigned jdm and unassigned Manishearth Dec 13, 2016
Copy link
Member

jdm left a comment

This is a good start! Please let us know if you intend to continue working on this or if we should find someone else to take over this work, now that the term is over!

Err(err) => {
match err[0] {
FormSubmittableElement::InputElement(ref i) =>
println!("First element didn't pass: {}",

This comment has been minimized.

@jdm

jdm Dec 15, 2016

Member

Stdout is all we've got at the moment. We should be calling Focus() on the element, however.

i.upcast::<Element>().get_string_attribute(&local_name!("name"))),
FormSubmittableElement::ObjectElement(ref i) =>
println!("First element didn't pass: {}",
i.upcast::<Element>().get_string_attribute(&local_name!("name"))),

This comment has been minimized.

@jdm

jdm Dec 15, 2016

Member

As discussed in the evaluation, we should find a way to reduce code duplication here. The reporting belongs in the code beneath here, where it should replace the TODO.

let window = window_from_node(self);
let el = self.upcast::<Element>();
let vs = ValidityState::new(&window, el);
if vs.ValueMissing() {

This comment has been minimized.

@jdm

jdm Dec 15, 2016

Member

I know the comment above says to call methods in validityState, and I apologize for missing that in the previous group's work. However, the model in this PR is backwards - validation code for a particular element type belongs in this validate method, and the methods in ValidityState should be calling this method and passing appropriate ValidationFlags. This method should be checking the state of validate_flags and performing the appropriate validation checks that are requested.

"email" => Regex::new(r"^\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,3}$").unwrap(),
"url" => Regex::new(r"^[a-zA-Z0-9\-\.]+\.(com|org|net|mil|edu|COM|ORG|NET|MIL|EDU)$").unwrap(),
"date" => Regex::new(r"^\d{1,2}\/\d{1,2}\/\d{4}$").unwrap(),
"tel" => Regex::new(r"^\d{3}-\d{2}-\d{4}$").unwrap(),

This comment has been minimized.

@jdm

jdm Dec 15, 2016

Member

Unfortunately these regexes need to be either much more complex, or much less strict. I lean towards much less strict - URLs can check if there's a period present; emails can check if there's an @; telephone numbers should not contain letters.

if l > Max.parse::<i32>().unwrap() {
println!("{} is too long for {}, maxlength is {} characters.", v, n, Max);
return true;
}

This comment has been minimized.

@jdm

jdm Dec 15, 2016

Member

HTMLInputElement already contains the maxlength information in a field, so this check will be more straightforward in HTMLInputElement::validate.

@xilaili
Copy link
Author

xilaili commented Dec 15, 2016

@xilaili
Copy link
Author

xilaili commented Dec 19, 2016

@jdm
Copy link
Member

jdm commented Dec 19, 2016

Wonderful! I look forward to seeing the changes!

@jdm jdm removed the S-awaiting-answer label Dec 19, 2016
@xilaili
Copy link
Author

xilaili commented Dec 19, 2016

@jdm
Copy link
Member

jdm commented Dec 19, 2016

That's fine! I'm not sure what you mean about accessing the comments, though. They should appear in the github UI for anybody to view them and/or respond.

@KiChjang
Copy link
Member

KiChjang commented Dec 19, 2016

I suppose they're using the email interface instead of the GitHub UI? If so, the URL link to the pull request is #14566. It's possible that they do not have a GitHub account, barring them from commenting on this PR using the GitHub UI.

@bors-servo
Copy link
Contributor

bors-servo commented Jan 11, 2017

The latest upstream changes (presumably #14291) made this pull request unmergeable. Please resolve the merge conflicts.

@jdm
Copy link
Member

jdm commented Jan 27, 2017

@xilaili Are you still planning to finish this work?

@xilaili
Copy link
Author

xilaili commented Jan 27, 2017

@jdm
Copy link
Member

jdm commented Jan 27, 2017

Ok! We'll keep tracking the efforts to finish this work in #11444.

@jdm jdm closed this Jan 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

6 participants
You can’t perform that action at this time.