Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    aurelia-next
    @aurelia-next
    const racfRules = ValidationRules
          .ensure('addNewRacfId').required()
          .then().satisfies(racfIdValidated).withMessage('user not found').rules;
    i used .then() instead of ensureObject() and done the trick :)
    cheers
    Jürgen Wenzel
    @jwx
    Are there any decorators available for validations or is ensure the only way to go?
    Matthias
    @mredl

    hi! i have a question how to make a validation rules with objects which contains nested objects because i always get an error when the rules get parsed:

    export class PartnerItemViewModel  {
       id: number;
       name1: string;
       name2: string;
       address: AddressViewModel;
    }
    
    export class AddressViewModel{
      id: number;
      street: string;
      houseNo: string;
      location: string;
      zipCode: string;
      countryCode: string;
    
    }
    
    ValidationRules
          .ensure((p: PartnerItemViewModel) => p.name1)
            .required().withMessageKey('please_enter')
          .ensure((p: PartnerItemViewModel) => p.name2)
            .required().withMessageKey('please_enter')
          .ensureObject().satisfies(p => p.address).withMessageKey('please_enter')
            .required().withMessageKey('please_enter')
            .then()
              .ensure((p: PartnerItemViewModel) => p.address.street)
              .required().withMessageKey('please_enter')
          .on(this)
          .rules;

    the error is

    Message: Unable to parse accessor function:
    function (p) { return p.address.street; }
    srfabio
    @srfabio
    Hi there, has anyone managed to get aurelia-validation working with the latest webpack skeleton?
    Joel Niklaus
    @JoelNiklaus
    Hi there, I have a big form with cusom form input components each containing its own validation controller. The form does not have any validation controller. When I had one validation controller only in the form it dit not work because of name clashes. How can I check in the form class if the entire form is valid? Any help is greatly appreciated
    Max
    @MaximBalaganskiy
    This is because a validation renderer does not know how to handle your custom controls. For the materialise bridge I wrote a custom renderer which looks for specific methods on custom elements and uses them to render errors. Each control just need to define those couple of methods
    @JoelNiklaus have a look at this price to get an idea aurelia-ui-toolkits/aurelia-materialize-bridge#432
    *PR
    I believe that Aurelia validation should have provided something similar, instead of an ability to register custom renderers
    Eagle94T
    @Eagle94T
    Hi everyone, I have a problem with the validation.
    I have a model with multiple validationRules, which work correctly. This model is used for a view in an array. In the view, I know need to trigger the validation on each of the objects in my array. Is there any way to call the ".required()" on each array-item?
    srfabio
    @srfabio
    @Eagle94T That's a bit confusing to follow, can you share a bit of code?
    Eagle94T
    @Eagle94T
    @srfabio I have a form where multiple persons can be added. The validation of a person, is inside the model of the person. But since the validation is triggered manually in the form-view, I need a require on each person to trigger the validation each time. Something like ensureForEach. But as much as I know, there isn't a method like this.
    Vladimir Georgiev
    @vladimirgeorgiev
    hi guys some help with validation
    i have this code
    constructor(movieData: MovieData, router: Router, validator: Validator, validationRules: ValidationRules) {
    this.data = movieData;
    this.router = router;
    this.validator = validator;
    this.validationRules = validationRules;
        ValidationRules.ensure(this.movie.title).required();
    }
    Tyler J Presley
    @TylerJPresley
    I'm not sure what's going on. Version 1.1.2. I have errors displayed on the page. I can keep clicking the submit button and it keeps adding errors under the fields. It looks like nothing is coming back for instruction.unrender in the render method even if errors already exist.
    meash-nrel
    @meash-nrel
    i'm using Aurelia Validation on change and blur. cursor is on a required text field . user hits a button on the page -- the blur triggers the validation error, however it seems to prevent the button's change event from happening. user has to click the button again to trigger the change event. is there a workaround beyond doing away with blur validation trigger?
    smigielns
    @smigielns

    Hello all. Does anyone know how to use validation on generated inputs inside repeat.for? I would like to validate dynamic form based on Arrays and Maps.
    Examples:

    <div repeat.for="double of doubles"> <!-- doubles is an array -->
        <input placeholder="double ${$index + 1}" value.bind="double & validate">
    </div>
    <div repeat.for="[key,value] of stringDoubleMap"> <!-- stringDoubleMap is a map -->
        <input placeholder="${key}" value.bind="value $ validate">
    </div>

    I need to use similar form to generate XML in output. I would like to validate each generated input separatly.

    Brandon Burciaga
    @bmb0205
    Is there a way to use aurelia validation on regular variables? Use case using redux to manage state of multiple child components. Instead of setting all validation properties in the parent and two way binding into the CEs or something along those lines, can I create local variables of my child component state and validate them without them being class props? As in getState() in the validate() call and check the local vars follow rules? I dont want to make 15+ props on my parent vm and use two way binding everywhere
    lkossis
    @lkossis

    hi! i have a question how to make a validation rules with objects which contains nested objects because i always get an error when the rules get parsed:

    export class PartnerItemViewModel  {
       id: number;
       name1: string;
       name2: string;
       address: AddressViewModel;
    }
    
    export class AddressViewModel{
      id: number;
      street: string;
      houseNo: string;
      location: string;
      zipCode: string;
      countryCode: string;
    
    }
    
    ValidationRules
          .ensure((p: PartnerItemViewModel) => p.name1)
            .required().withMessageKey('please_enter')
          .ensure((p: PartnerItemViewModel) => p.name2)
            .required().withMessageKey('please_enter')
          .ensureObject().satisfies(p => p.address).withMessageKey('please_enter')
            .required().withMessageKey('please_enter')
            .then()
              .ensure((p: PartnerItemViewModel) => p.address.street)
              .required().withMessageKey('please_enter')
          .on(this)
          .rules;

    the error is

    Message: Unable to parse accessor function:
    function (p) { return p.address.street; }

    I'm having exactly the same issue. I prefer to keep my form bindings in a model as well, but the accessor function fails every time, forcing me to move the properties outside of a model. That is a solution, I guess, but shouldn't there be a simple way of doing this?

    Sajeetharan
    @sajeetharan
    hi guys
    Jason
    @jasonhjohnson
    Anyone know how I can use validation to validate that a radio button group selection is made for each of my dynamic Questions?
    elitemike
    @elitemike
    I need to load the validation plugin in karma, but I'm not testing a ui component. How do i properly load the plugin for a model validation test
    Tiago Mendes
    @tgmendes
    Hey everyone
    Don't know if this has been answered, but is there a way in the View to know if a given input field is required (i.e., defined as required when defining the field's validation rules?)
    thanks a lot for the help!
    elitemike
    @elitemike
    @tgmendes would firing validate immediately work for you to mark those required fields as invalid?
    Jason Sobell
    @jsobell
    @tgmendes It's been a long time since I worked on this, but essentially I think you'd have to examine the associated binding context to find out which property the field is bound to, then somehow (!) work out which rule on the validator is bound to that property
    Tiago Mendes
    @tgmendes

    @elitemike problem is, if you fire the validate, then all the fields will appear as having an error. You could have a workaround where you use a flag controlling whether you want to validate or not. It's not perfect, but it could work.

    @jsobell your solution seems exactly what we are looking for, but we still haven't figured out how to retrieve required fields from this context. Do you have any pointer or resource that could help?

    thanks a lot for the answers!
    Jason Sobell
    @jsobell
    @tgmendes Well the tricky thing is that validation is against the object, not a field. So what you really are asking is how to get the property that's associated with the field, then look at the ValidationController and find if it is referencing that property, and if so does it have any rules associated with that reference that are of the type you want :)
    I know this isn't what you want to hear, but I'd start with classes such as https://github.com/aurelia/validation/blob/master/src/validate-binding-behavior-base.ts and https://github.com/aurelia/validation/blob/master/src/validation-controller.ts and see if you can see the best approach.
    I worked on the design of this about 2 years ago, but @jdanyow did all the Aurelia coding and all of the binding magic.
    I remember him saying he was going to do a huge doco of how the binding works, and I suspect most of that is now in the official documentation, but I don't think the inner workings of the validation were given the same treatment.
    Eagle94T
    @Eagle94T
    Hi guys,
    I have a problem with the validation and IE11.
    I set the validationTrigger to blurOrChange, but in IE11 everytime the page is loaded, the validation has already take place.
    Since I'm not changing or focusing the value, and it works in chrome and firefox fine, there is an issue with IE11.
    Did anyone have the same problem, or knows how to solve this?
    Jürgen Wenzel
    @jwx
    Anyone had the issue that only the first validation work?
    Max
    @MaximBalaganskiy
    May be reset the controller on activate?
    Patrick Walters
    @PWKad
    @Eagle94T did you resolve this? I see the same behavior and am trouble-shooting now
    I may open a bug for tracking
    Patrick Walters
    @PWKad
    aurelia/validation#494
    doktordirk
    @doktordirk
    aurelia/validation#423 ?
    Eagle94T
    @Eagle94T
    @PWKad I wasn't able to fix the problem yet
    Patrick Walters
    @PWKad
    @doktordirk I saw that issue but wasn't sure if it was related.
    jbockle
    @jbockle
    hey everyone I built a plugin for creating forms using JSON schema & aurelia-validation, check it out here https://www.npmjs.com/package/aurelia-json-schema-form
    Charles Lindsay
    @VagyokC4
    @jbockle Looks nice. Is there a generator for the schema / form? i.e. I give it a model and it produces the two required schema's? How does one easily produce the form and schema json?
    jbockle
    @jbockle
    @VagyokC4 Thanks! Still working on creating documentation, you can create JSON schema through several online generators like https://jsonschema.net/. As for the form definition, anything you want to expose on the form works off of matching property keys with your schema. The sample/json-form.ts has an example of how that looks, and the sample/json-schema.ts has an example of its corresponding schema.
    jbockle
    @jbockle
    is there a way I can use display errors on entity validation using a custom renderer?
    jbockle
    @jbockle
    i.e. i have a rule: ValidationRules.ensureObject().. that I also added to controller with .addObject(...)
    I see it come up in render instruction, of course the element is null