Limiting allowed letters to A, C, G, U

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

Limiting allowed letters to A, C, G, U

MrAustin
In my Domain class, I have the variable 'sequence' (referring to RNA).  It starts out as an empty string, but when the client enters an RNA sequence into the correct text field, that sequence is loaded into the 'sequence' variable.

I need to permit the client only to input A, C, G, U, numerical values, and a greater-than sign (>), while refusing to accept all other characters.  
Reply | Threaded
Open this post in threaded view
|

Re: Limiting allowed letters to A, C, G, U

tomas lin
Seems like you want to write a custom constraint - check out the
constraints plugin and documentation

http://grails.org/plugin/constraints



On Fri, Oct 30, 2009 at 2:31 PM, AwTIn <[hidden email]> wrote:

>
> In my Domain class, I have the variable 'sequence' (referring to RNA).  It
> starts out as an empty string, but when the client enters an RNA sequence
> into the correct text field, that sequence is loaded into the 'sequence'
> variable.
>
> I need to permit the client only to input A, C, G, U, numerical values, and
> a greater-than sign (>), while refusing to accept all other characters.
> --
> View this message in context: http://old.nabble.com/Limiting-allowed-letters-to-A%2C-C%2C-G%2C-U-tp26131056p26131056.html
> Sent from the grails - user mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

RE: Limiting allowed letters to A, C, G, U

Matthew.Lachman
In reply to this post by MrAustin
You probably want to use a custom validator:
http://www.grails.org/doc/1.1.x/ref/Constraints/validator.html

Also, you can read up on how validation works in Grails here:
http://www.grails.org/doc/1.1.x/guide/7.%20Validation.html

Matt

-----Original Message-----
From: AwTIn [mailto:[hidden email]]
Sent: Friday, October 30, 2009 10:32 AM
To: [hidden email]
Subject: [grails-user] Limiting allowed letters to A, C, G, U


In my Domain class, I have the variable 'sequence' (referring to RNA).
It
starts out as an empty string, but when the client enters an RNA
sequence
into the correct text field, that sequence is loaded into the 'sequence'
variable.

I need to permit the client only to input A, C, G, U, numerical values,
and
a greater-than sign (>), while refusing to accept all other characters.

--
View this message in context:
http://old.nabble.com/Limiting-allowed-letters-to-A%2C-C%2C-G%2C-U-tp261
31056p26131056.html
Sent from the grails - user mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email




---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Limiting allowed letters to A, C, G, U

scryan
In reply to this post by MrAustin
you could use a custom validator and a regular expression to control  
the data entry.


Scott Ryan
President/CTO
Soaring Eagle L.L.C.
[hidden email]
(303) 263-3044

On Oct 30, 2009, at 8:31 AM, AwTIn wrote:

>
> In my Domain class, I have the variable 'sequence' (referring to  
> RNA).  It
> starts out as an empty string, but when the client enters an RNA  
> sequence
> into the correct text field, that sequence is loaded into the  
> 'sequence'
> variable.
>
> I need to permit the client only to input A, C, G, U, numerical  
> values, and
> a greater-than sign (>), while refusing to accept all other  
> characters.
> --
> View this message in context: http://old.nabble.com/Limiting-allowed-letters-to-A%2C-C%2C-G%2C-U-tp26131056p26131056.html
> Sent from the grails - user mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Limiting allowed letters to A, C, G, U

Nicolás Dijkstra
In reply to this post by MrAustin
It seems to me like you can use a regular expression to validate this.

Perhaps the "matches" validation constraint would work

On Fri, Oct 30, 2009 at 11:31 AM, AwTIn <[hidden email]> wrote:

In my Domain class, I have the variable 'sequence' (referring to RNA).  It
starts out as an empty string, but when the client enters an RNA sequence
into the correct text field, that sequence is loaded into the 'sequence'
variable.

I need to permit the client only to input A, C, G, U, numerical values, and
a greater-than sign (>), while refusing to accept all other characters.
--
View this message in context: http://old.nabble.com/Limiting-allowed-letters-to-A%2C-C%2C-G%2C-U-tp26131056p26131056.html
Sent from the grails - user mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email



Reply | Threaded
Open this post in threaded view
|

RE: Limiting allowed letters to A, C, G, U

Matthew.Lachman

That seems much more appropriate than a custom validator.  J

 

Here’s the link: http://grails.org/doc/1.1.x/ref/Constraints/matches.html

 

Matt

 

From: Nicolás Dijkstra [mailto:[hidden email]]
Sent: Friday, October 30, 2009 10:39 AM
To: [hidden email]
Subject: Re: [grails-user] Limiting allowed letters to A, C, G, U

 

It seems to me like you can use a regular expression to validate this.

Perhaps the "matches" validation constraint would work

On Fri, Oct 30, 2009 at 11:31 AM, AwTIn <[hidden email]> wrote:


In my Domain class, I have the variable 'sequence' (referring to RNA).  It
starts out as an empty string, but when the client enters an RNA sequence
into the correct text field, that sequence is loaded into the 'sequence'
variable.

I need to permit the client only to input A, C, G, U, numerical values, and
a greater-than sign (>), while refusing to accept all other characters.
--
View this message in context: http://old.nabble.com/Limiting-allowed-letters-to-A%2C-C%2C-G%2C-U-tp26131056p26131056.html
Sent from the grails - user mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email

 

Reply | Threaded
Open this post in threaded view
|

Re: Limiting allowed letters to A, C, G, U

MrAustin
In reply to this post by Nicolás Dijkstra
When I try the below code, I get an insanely long error message.
--------------
String sequence = ""

static constraints =
{
        sequence(nullable: true, maxLength: 10000, matches: "ACGU1234567890>")
}
-------------
Having 'sequence' initially be null rather than empty does nothing.  I also tried removing ">" because it is considered a "dangerous" character.  Still get the error.

I also tried removing the quotations, and I tried storing the list of characters in a variable and using that.  


ndijkstra wrote
It seems to me like you can use a regular expression to validate this.

Perhaps the "matches" validation constraint would work

On Fri, Oct 30, 2009 at 11:31 AM, AwTIn <tanner.kluth@gmail.com> wrote:

>
> In my Domain class, I have the variable 'sequence' (referring to RNA).  It
> starts out as an empty string, but when the client enters an RNA sequence
> into the correct text field, that sequence is loaded into the 'sequence'
> variable.
>
> I need to permit the client only to input A, C, G, U, numerical values, and
> a greater-than sign (>), while refusing to accept all other characters.
> --
> View this message in context:
> http://old.nabble.com/Limiting-allowed-letters-to-A%2C-C%2C-G%2C-U-tp26131056p26131056.html
> Sent from the grails - user mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>
>
Reply | Threaded
Open this post in threaded view
|

RE: Limiting allowed letters to A, C, G, U

Matthew.Lachman
Sometimes Grails creates insanely long error messages.  Try reading
through the stacktrace to find points in your code that could be
involved or clues to what you should search for online.

You could also post your stacktrace here.

Matt

-----Original Message-----
From: AwTIn [mailto:[hidden email]]
Sent: Friday, October 30, 2009 11:22 AM
To: [hidden email]
Subject: Re: [grails-user] Limiting allowed letters to A, C, G, U


When I try the below code, I get an insanely long error message.

String sequence = ""

static constraints =
{
        sequence(nullable: true, maxLength: 10000, matches:
"ACGU1234567890>"
}

Having 'sequence' be null rather than empty initially does nothing.  I
also
tried removing ">" because it is considered a "dangerous" character.
Still
get the error.



ndijkstra wrote:
>
> It seems to me like you can use a regular expression to validate this.
>
> Perhaps the "matches" validation constraint would work
>
> On Fri, Oct 30, 2009 at 11:31 AM, AwTIn <[hidden email]>
wrote:
>
>>
>> In my Domain class, I have the variable 'sequence' (referring to
RNA).
>> It
>> starts out as an empty string, but when the client enters an RNA
sequence
>> into the correct text field, that sequence is loaded into the
'sequence'
>> variable.
>>
>> I need to permit the client only to input A, C, G, U, numerical
values,
>> and
>> a greater-than sign (>), while refusing to accept all other
characters.
>> --
>> View this message in context:
>>
http://old.nabble.com/Limiting-allowed-letters-to-A%2C-C%2C-G%2C-U-tp261
31056p26131056.html

>> Sent from the grails - user mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>    http://xircles.codehaus.org/manage_email
>>
>>
>>
>
>

--
View this message in context:
http://old.nabble.com/Limiting-allowed-letters-to-A%2C-C%2C-G%2C-U-tp261
31056p26131900.html
Sent from the grails - user mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email




---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Limiting allowed letters to A, C, G, U

Nicolás Dijkstra
In reply to this post by MrAustin
I think it has to do with the regex you are using.

Please try with the following to and see if it works:

matches:"[[ACGU][0-9]\>]+"

On Fri, Oct 30, 2009 at 12:21 PM, AwTIn <[hidden email]> wrote:

When I try the below code, I get an insanely long error message.

String sequence = ""

static constraints =
{
       sequence(nullable: true, maxLength: 10000, matches:
"ACGU1234567890>"
}

Having 'sequence' be null rather than empty initially does nothing.  I also
tried removing ">" because it is considered a "dangerous" character.  Still
get the error.



ndijkstra wrote:
>
> It seems to me like you can use a regular expression to validate this.
>
> Perhaps the "matches" validation constraint would work
>
> On Fri, Oct 30, 2009 at 11:31 AM, AwTIn <[hidden email]> wrote:
>
>>
>> In my Domain class, I have the variable 'sequence' (referring to RNA).
>> It
>> starts out as an empty string, but when the client enters an RNA sequence
>> into the correct text field, that sequence is loaded into the 'sequence'
>> variable.
>>
>> I need to permit the client only to input A, C, G, U, numerical values,
>> and
>> a greater-than sign (>), while refusing to accept all other characters.
>> --
>> View this message in context:
>> http://old.nabble.com/Limiting-allowed-letters-to-A%2C-C%2C-G%2C-U-tp26131056p26131056.html
>> Sent from the grails - user mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>    http://xircles.codehaus.org/manage_email
>>
>>
>>
>
>

--
View this message in context: http://old.nabble.com/Limiting-allowed-letters-to-A%2C-C%2C-G%2C-U-tp26131056p26131900.html
Sent from the grails - user mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email



Reply | Threaded
Open this post in threaded view
|

RE: Limiting allowed letters to A, C, G, U

MrAustin
In reply to this post by Matthew.Lachman
Attachment:
stacktrace.log

I can't really gather much from it.
Reply | Threaded
Open this post in threaded view
|

RE: Limiting allowed letters to A, C, G, U

Matthew.Lachman
What's happening at "BootStrap.groovy:14"?

-----Original Message-----
From: AwTIn [mailto:[hidden email]]
Sent: Friday, October 30, 2009 11:36 AM
To: [hidden email]
Subject: RE: [grails-user] Limiting allowed letters to A, C, G, U


Attachment:
http://old.nabble.com/file/p26132142/stacktrace.log stacktrace.log

I can't really gather much from it.
--
View this message in context:
http://old.nabble.com/Limiting-allowed-letters-to-A%2C-C%2C-G%2C-U-tp261
31056p26132142.html
Sent from the grails - user mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email




---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email