Hi Bhavya! I would rather communicate via https://github.com/servo/servo/issues/11444 rather than private email.

When I proposed the method that would accept an enum, I was basing it on how it would be used by the method in ValidityState, which are focused on checking a single kind of validation at a time. I realize now that a traditional Rust enum won't be a good fit for performing the static validation (which cares about all of the possible invalid states simultaneously).

I propose that instead of a Rust enum, we use the bitflags macro to declare types of validations that can be combined in the static validation, and used in isolation in the methods for ValidityState. https://dxr.mozilla.org/servo/rev/5a382989fc769bfb2c9ff9cc21a50f8ac024f712/components/net/bluetooth_thread.rs#41 is an example of how these can be defined, and https://dxr.mozilla.org/servo/rev/5a382989fc769bfb2c9ff9cc21a50f8ac024f712/components/net/bluetooth_thread.rs#388 is an example of how they can be used - start with empty flags, and insert additional ones as appropriate.

That means that the new method declared in Validatable will accept an argument of type ValidationFlags, and implementers will then use `flags.contains(TYPE_MISMATCH)` (for example) to determine if that validation should be performed. Does that make sense?

Cheers,
Josh

On 2016-11-02 5:26 PM, bban...@ncsu.edu wrote:
On Sunday, October 30, 2016 at 10:09:14 AM UTC-4, Josh Matthews wrote:
On 2016-10-28 1:01 PM, ysu...@ncsu.edu wrote:
Hi Josh, we are a little bit confused about the last initial step. "Use the newly-added 
JS<Element> member to call these new methods as appropriate in each of the stub methods 
in ValidityState". We tried to call the function we declared in the trait and try to print 
out something when it get called but nothing happened. Can you explain the work flow of this 
validation stuff?


The idea here is that:
* ValidityState has a JS<Element> member
* Element has a `as_maybe_validatable` method, that returns
Option<&Validatable>
* Validatable has a method that can perform validations

We can combine these to make each of the stub methods that exist in
ValidityState (ValueMissing, TypeMismatch, etc.) invoke the method on
Validatable. Does that make sense?

Cheers,
Josh

Hello Josh

Thanks for the explanation. So, when ever a form is submitted we call static 
validations and as we have pushed changes, for every element in the tree order, 
is that element is validatable, we have to invoke method is_validate which 
return either true or false.

So, initial steps say that we have to add a method which takes enum as an argument. We 
had a discussion with our teaching assistant here and we wanted to confirm that by saying 
"method takes enum as an argument", does we have to pass whole enum set or 
method will take individual elements inside an enum and validate over that value.

And is it possible to get your email id/ contact number so that we can discuss 
more about it.

Regards
Bhavya


_______________________________________________
dev-servo mailing list
dev-servo@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-servo

Reply via email to